diff --git a/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go b/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go index 68bc93b3..fea78212 100644 --- a/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go +++ b/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go @@ -55,17 +55,19 @@ func (s *Rpc) AddBaseStudent(ctx context.Context, in *BaseStudentProto.ModelArg) var reply BaseStudentProto.Reply //========================================== //检查身份证的有效性 - IdCardNo := []byte(in.Sfzjh) - if in.Sfzjlxm == "01" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { - reply.Success = false - reply.Message = "身份证号在不符合检查要求!" - return &reply, nil - } - //是不是重复 - if !SysLoginpersonDao.IsValidIdCardNo(in.Sfzjh, "") { - reply.Success = false - reply.Message = "证件号在系统中已存在,无法创建!" - return &reply, nil + if len(in.Sfzjh) > 0 { + IdCardNo := []byte(in.Sfzjh) + if in.Sfzjlxm == "01" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { + reply.Success = false + reply.Message = "身份证号在不符合检查要求!" + return &reply, nil + } + //是不是重复 + if !SysLoginpersonDao.IsValidIdCardNo(in.Sfzjh, "") { + reply.Success = false + reply.Message = "证件号在系统中已存在,无法创建!" + return &reply, nil + } } //========================================== //调用dao @@ -261,17 +263,19 @@ func (s *Rpc) UpdateBaseStudent(ctx context.Context, in *BaseStudentProto.ModelA //========================================== //检查身份证的有效性 - IdCardNo := []byte(in.Sfzjh) - if in.Sfzjlxm == "1" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { - reply.Success = false - reply.Message = "身份证号在不符合检查要求!" - return &reply, nil - } - //是不是重复 - if !SysLoginpersonDao.IsValidIdCardNo(in.Sfzjh, in.PersonId) { - reply.Success = false - reply.Message = "证件号在系统中已存在,无法创建!" - return &reply, nil + if len(in.Sfzjh) > 0 { + IdCardNo := []byte(in.Sfzjh) + if in.Sfzjlxm == "1" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { + reply.Success = false + reply.Message = "身份证号在不符合检查要求!" + return &reply, nil + } + //是不是重复 + if !SysLoginpersonDao.IsValidIdCardNo(in.Sfzjh, in.PersonId) { + reply.Success = false + reply.Message = "证件号在系统中已存在,无法创建!" + return &reply, nil + } } //========================================== model := new(models.TBaseStudent) diff --git a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go index ec924500..6e426271 100644 --- a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go +++ b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go @@ -92,17 +92,19 @@ func (s *Rpc) AddBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg) var reply BaseTeacherProto.Reply //========================================== //检查身份证的有效性 - IdCardNo := []byte(in.Sfzjh) - if in.Sfzjlxm == "01" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { - reply.Success = false - reply.Message = "身份证号在不符合检查要求!" - return &reply, nil - } - //是不是重复 - if !SysLoginpersonDao.IsValidIdCardNo(in.Sfzjh, "") { - reply.Success = false - reply.Message = "证件号在系统中已存在,无法创建!" - return &reply, nil + if len(in.Sfzjh) > 0 { + IdCardNo := []byte(in.Sfzjh) + if in.Sfzjlxm == "01" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { + reply.Success = false + reply.Message = "身份证号在不符合检查要求!" + return &reply, nil + } + //是不是重复 + if !SysLoginpersonDao.IsValidIdCardNo(in.Sfzjh, "") { + reply.Success = false + reply.Message = "证件号在系统中已存在,无法创建!" + return &reply, nil + } } //========================================== //如果是手机号,是不是合法 @@ -260,17 +262,19 @@ func (s *Rpc) UpdateBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelA var reply BaseTeacherProto.Reply //检查身份证的有效性 - IdCardNo := []byte(in.Sfzjh) - if in.Sfzjlxm == "1" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { - reply.Success = false - reply.Message = "身份证号在不符合检查要求!" - return &reply, nil - } - //是不是重复 - if !SysLoginpersonDao.IsValidIdCardNo(in.Sfzjh, in.PersonId) { - reply.Success = false - reply.Message = "证件号在系统中已存在,无法创建!" - return &reply, nil + if len(in.Sfzjh) > 0 { + IdCardNo := []byte(in.Sfzjh) + if in.Sfzjlxm == "1" && !IdCardUtil.IsValidIdCardNo(&IdCardNo) { + reply.Success = false + reply.Message = "身份证号在不符合检查要求!" + return &reply, nil + } + //是不是重复 + if !SysLoginpersonDao.IsValidIdCardNo(in.Sfzjh, in.PersonId) { + reply.Success = false + reply.Message = "证件号在系统中已存在,无法创建!" + return &reply, nil + } } //如果是手机号,是不是合法 @@ -540,7 +544,7 @@ func (s *Rpc) DeleteTeacherMultipleBureau(ctx context.Context, in *BaseTeacherPr } //设置主单位 -func (s *Rpc) SettingMainOrg (ctx context.Context, in *BaseTeacherProto.SettingMainOrgArg) (*BaseTeacherProto.Reply, error){ +func (s *Rpc) SettingMainOrg(ctx context.Context, in *BaseTeacherProto.SettingMainOrgArg) (*BaseTeacherProto.Reply, error) { //异常处理 defer func() { if err := recover(); err != nil { @@ -560,4 +564,4 @@ func (s *Rpc) SettingMainOrg (ctx context.Context, in *BaseTeacherProto.Setting reply.Success = success reply.Message = message return &reply, nil -} \ No newline at end of file +}