|
|
|
@ -45,9 +45,11 @@ func (s *Rpc) GetBaseOrganization(ctx context.Context, in *BaseOrganizationProto
|
|
|
|
|
func (s *Rpc) AddBaseOrganization(ctx context.Context, in *BaseOrganizationProto.ModelArg) (*BaseOrganizationProto.Reply, error) {
|
|
|
|
|
//rpc响应
|
|
|
|
|
var reply BaseOrganizationProto.Reply
|
|
|
|
|
//是不是部门
|
|
|
|
|
isBuMen := false
|
|
|
|
|
|
|
|
|
|
//2:学校,7:教辅单位,8:大学区,不在2,7,8中,应该就是指部门
|
|
|
|
|
if in.OrgType == 2 || in.OrgType == 7 || in.OrgType == 8 {
|
|
|
|
|
//1:教育局,2:学校,7:教辅单位,8:大学区,不在1,2,7,8中,应该就是指部门
|
|
|
|
|
if in.OrgType == 1 || in.OrgType == 2 || in.OrgType == 7 || in.OrgType == 8 {
|
|
|
|
|
//1、检查非空
|
|
|
|
|
if len(in.OrgCode) == 0 {
|
|
|
|
|
reply.Success = false
|
|
|
|
@ -67,6 +69,8 @@ func (s *Rpc) AddBaseOrganization(ctx context.Context, in *BaseOrganizationProto
|
|
|
|
|
reply.Message = "区域代码不存在,不能创建!"
|
|
|
|
|
return &reply, nil
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isBuMen = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//3、指定的org_code是否存在
|
|
|
|
@ -95,7 +99,11 @@ func (s *Rpc) AddBaseOrganization(ctx context.Context, in *BaseOrganizationProto
|
|
|
|
|
}
|
|
|
|
|
if exist {
|
|
|
|
|
reply.Success = false
|
|
|
|
|
reply.Message = "单位/部门名称已存在,不能创建!"
|
|
|
|
|
if isBuMen {
|
|
|
|
|
reply.Message = "部门名称已存在,不能创建!"
|
|
|
|
|
} else {
|
|
|
|
|
reply.Message = "单位名称已存在,不能创建!"
|
|
|
|
|
}
|
|
|
|
|
return &reply, err
|
|
|
|
|
}
|
|
|
|
|
//5、调用dao
|
|
|
|
@ -230,7 +238,7 @@ func (s *Rpc) DeleteBaseOrganization(ctx context.Context, in *BaseOrganizationPr
|
|
|
|
|
//rpc响应
|
|
|
|
|
var reply BaseOrganizationProto.Reply
|
|
|
|
|
|
|
|
|
|
//遍历每一个单位/部门进行检查
|
|
|
|
|
//遍历每一个单位+部门进行检查
|
|
|
|
|
for i := range in.Ids {
|
|
|
|
|
//判断部门下是不是有可用的人员
|
|
|
|
|
var inTeacher BaseTeacherProto.QueryArg
|
|
|
|
@ -247,7 +255,12 @@ func (s *Rpc) DeleteBaseOrganization(ctx context.Context, in *BaseOrganizationPr
|
|
|
|
|
}
|
|
|
|
|
if count > 0 {
|
|
|
|
|
reply.Success = false
|
|
|
|
|
reply.Message = "单位/部门下存在教工数据,无法删除!"
|
|
|
|
|
//判断是单位还是部门
|
|
|
|
|
if BaseOrganizationDao.IsBuMen(inTeacher.OrgId){
|
|
|
|
|
reply.Message = "部门下存在教工数据,无法删除!"
|
|
|
|
|
}else{
|
|
|
|
|
reply.Message = "单位下存在教工数据,无法删除!"
|
|
|
|
|
}
|
|
|
|
|
return &reply, err
|
|
|
|
|
}
|
|
|
|
|
//判断部门下是不是有可用的子部门
|
|
|
|
@ -260,7 +273,12 @@ func (s *Rpc) DeleteBaseOrganization(ctx context.Context, in *BaseOrganizationPr
|
|
|
|
|
}
|
|
|
|
|
if count > 0 {
|
|
|
|
|
reply.Success = false
|
|
|
|
|
reply.Message = "单位/部门下存在子部门,无法删除!"
|
|
|
|
|
//判断是单位还是部门
|
|
|
|
|
if BaseOrganizationDao.IsBuMen(inTeacher.OrgId){
|
|
|
|
|
reply.Message = "部门下存在子部门,无法删除!"
|
|
|
|
|
}else{
|
|
|
|
|
reply.Message = "单位下存在子部门,无法删除!"
|
|
|
|
|
}
|
|
|
|
|
return &reply, err
|
|
|
|
|
}
|
|
|
|
|
//判断是不是有可用的班级
|
|
|
|
@ -277,7 +295,12 @@ func (s *Rpc) DeleteBaseOrganization(ctx context.Context, in *BaseOrganizationPr
|
|
|
|
|
}
|
|
|
|
|
if count > 0 {
|
|
|
|
|
reply.Success = false
|
|
|
|
|
reply.Message = "单位/部门下存在班级数据,无法删除!"
|
|
|
|
|
//判断是单位还是部门
|
|
|
|
|
if BaseOrganizationDao.IsBuMen(inTeacher.OrgId){
|
|
|
|
|
reply.Message = "部门下存在班级,无法删除!"
|
|
|
|
|
}else{
|
|
|
|
|
reply.Message = "单位下存在班级,无法删除!"
|
|
|
|
|
}
|
|
|
|
|
return &reply, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -348,7 +371,6 @@ func (s *Rpc) UpdateBaseOrganization(ctx context.Context, in *BaseOrganizationPr
|
|
|
|
|
return &reply, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if exist {
|
|
|
|
|
reply.Success = false
|
|
|
|
|
reply.Message = "编码已存在,无法修改!"
|
|
|
|
@ -364,7 +386,11 @@ func (s *Rpc) UpdateBaseOrganization(ctx context.Context, in *BaseOrganizationPr
|
|
|
|
|
}
|
|
|
|
|
if exist {
|
|
|
|
|
reply.Success = false
|
|
|
|
|
reply.Message = "单位/部门名称已存在,无法修改!"
|
|
|
|
|
if BaseOrganizationDao.IsBuMen(in.OrgId){
|
|
|
|
|
reply.Message = "部门名称已存在,无法修改!"
|
|
|
|
|
}else{
|
|
|
|
|
reply.Message = "单位名称已存在,无法修改!"
|
|
|
|
|
}
|
|
|
|
|
return &reply, err
|
|
|
|
|
}
|
|
|
|
|
//3、修改
|
|
|
|
|