From a0f6a1e94bb051371e49ca0f04338b70bb6d9306 Mon Sep 17 00:00:00 2001 From: huanghai <10402852@qq.com> Date: Tue, 30 Jun 2020 16:37:55 +0800 Subject: [PATCH] 'commit' --- .../BaseStudentService/BaseStudentService.go | 16 +++++++++++++++- .../BaseTeacherService/BaseTeacherService.go | 16 ++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go b/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go index 62849b4b..b51dab0f 100644 --- a/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go +++ b/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go @@ -71,6 +71,13 @@ func (s *Rpc) AddBaseStudent(ctx context.Context, in *BaseStudentProto.ModelArg) model.Sfzjlxm = in.Sfzjlxm //如果是身份证 if model.Sfzjlxm == "1" { + //如果是身份证 + by := []byte(in.Sfzjh) + if !IdCardUtil.IsValidIdCardNo(&by) { + reply.Success = false + reply.Message = "身份证号不合法!" + return &reply, nil + } //根据身份证号,提取男女,出生日期 _, birthday, xbm := IdCardUtil.GetIdCardNoInfo(in.Sfzjh) model.Csrq = DateUtil.ConvertDateTime(birthday) @@ -231,7 +238,7 @@ func (s *Rpc) UpdateBaseStudent(ctx context.Context, in *BaseStudentProto.ModelA //========================================== //检查身份证的有效性 IdCardNo := []byte(in.Sfzjh) - if in.Sfzjlxm == "01" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { + if in.Sfzjlxm == "1" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { reply.Success = false reply.Message = "身份证号在不符合检查要求!" return &reply, nil @@ -249,6 +256,13 @@ func (s *Rpc) UpdateBaseStudent(ctx context.Context, in *BaseStudentProto.ModelA model.Sfzjlxm = in.Sfzjlxm //如果是身份证 if model.Sfzjlxm == "1" { + //如果是身份证 + by := []byte(in.Sfzjh) + if !IdCardUtil.IsValidIdCardNo(&by) { + reply.Success = false + reply.Message = "身份证号不合法!" + return &reply, nil + } //根据身份证号,提取男女,出生日期 _, birthday, xbm := IdCardUtil.GetIdCardNoInfo(in.Sfzjh) model.Csrq = DateUtil.ConvertDateTime(birthday) diff --git a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go index f568ed2b..223eda1f 100644 --- a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go +++ b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go @@ -93,14 +93,14 @@ func (s *Rpc) AddBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg) model.Cym = in.Cym model.Sfzjlxm = in.Sfzjlxm model.Sfzjh = in.Sfzjh - //如果是身份证 - by := []byte(in.Sfzjh) - if !IdCardUtil.IsValidIdCardNo(&by) { - reply.Success = false - reply.Message = "身份证号不合法!" - return &reply, nil - } if model.Sfzjlxm == "1" { + //如果是身份证 + by := []byte(in.Sfzjh) + if !IdCardUtil.IsValidIdCardNo(&by) { + reply.Success = false + reply.Message = "身份证号不合法!" + return &reply, nil + } //根据身份证号,提取男女,出生日期 _, birthday, xbm := IdCardUtil.GetIdCardNoInfo(in.Sfzjh) model.Csrq = DateUtil.ConvertDateTime(birthday) @@ -230,7 +230,7 @@ func (s *Rpc) UpdateBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelA //检查身份证的有效性 IdCardNo := []byte(in.Sfzjh) - if in.Sfzjlxm == "01" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { + if in.Sfzjlxm == "1" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { reply.Success = false reply.Message = "身份证号在不符合检查要求!" return &reply, nil