From 60d0549af667143d62b7190dbb47b92a99e3466b Mon Sep 17 00:00:00 2001 From: huanghai <10402852@qq.com> Date: Wed, 24 Jun 2020 14:18:11 +0800 Subject: [PATCH] 'commit' --- dsBaseRpc/RpcService/BaseClass/BaseClassDao/BaseClassDao.go | 6 +++++- .../BaseClass/BaseClassService/BaseClassService.go | 4 ++-- .../BaseGlobal/BaseGlobalService/BaseGlobalService.go | 2 +- .../BaseOrganizationDao/BaseOrganizationDao.go | 4 ++-- .../BaseOrganizationService/BaseOrganizationService.go | 6 +++--- .../BaseOrganizationManagerDao.go | 2 +- .../BasePurview/BasePurviewService/BasePurviewService.go | 2 +- .../BaseRolePersonService/BaseRolePersonService.go | 6 +++--- .../BaseStudent/BaseStudentService/BaseStudentService.go | 6 +++--- .../RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go | 2 +- .../BaseTeacher/BaseTeacherService/BaseTeacherService.go | 4 ++-- .../RpcService/GovArea/GovAreaService/GovAreaService.go | 2 +- .../RpcService/SysDict/SysDictService/SysDictService.go | 2 +- .../SysLoginpersonService/SysLoginpersonService.go | 2 +- dsBaseRpc/Test/TestOutIndex/TestOutIndex.go | 2 +- dsBaseRpc/Utils/SqlKit/SqlKit.go | 2 +- 16 files changed, 29 insertions(+), 25 deletions(-) diff --git a/dsBaseRpc/RpcService/BaseClass/BaseClassDao/BaseClassDao.go b/dsBaseRpc/RpcService/BaseClass/BaseClassDao/BaseClassDao.go index a9c1f345..c4690b3f 100644 --- a/dsBaseRpc/RpcService/BaseClass/BaseClassDao/BaseClassDao.go +++ b/dsBaseRpc/RpcService/BaseClass/BaseClassDao/BaseClassDao.go @@ -6,6 +6,7 @@ import ( "dsBaseRpc/Utils/DbUtil" "dsBaseRpc/Utils/SqlKit" "dsBaseRpc/models" + "errors" "github.com/xormplus/builder" "time" ) @@ -99,7 +100,10 @@ func PageBaseClass(in *BaseClassProto.QueryArg) ([]map[string]interface{}, int32 //根据学校ID获取学部(学段)信息 func GetStage(schoolId string) ([]map[string]interface{}, int32, error) { //1、获取办学类型 - list := SqlKit.QueryIds([]string{schoolId}, "t_base_organization") + list := SqlKit.QueryListMapByIds([]string{schoolId}, "t_base_organization") + if list == nil || len(list) == 0 { + return nil, 0, errors.New("无法找到此学校id。") + } xxbxlxm := list[0]["xxbxlxm"].(string) //2、根据办学类型,查找所有的学段 var myBuilder = builder.Dialect(builder.MYSQL).Select("t1.stage_id,t2.stage_name"). diff --git a/dsBaseRpc/RpcService/BaseClass/BaseClassService/BaseClassService.go b/dsBaseRpc/RpcService/BaseClass/BaseClassService/BaseClassService.go index 149bb761..aa003236 100644 --- a/dsBaseRpc/RpcService/BaseClass/BaseClassService/BaseClassService.go +++ b/dsBaseRpc/RpcService/BaseClass/BaseClassService/BaseClassService.go @@ -24,7 +24,7 @@ func (s *Rpc) GetBaseClass(ctx context.Context, in *BaseClassProto.ModelArg) (*B //rpc响应 var reply BaseClassProto.Reply //通用获取单条 - list := SqlKit.QueryIds([]string{in.ClassId}, "t_base_class") + list := SqlKit.QueryListMapByIds([]string{in.ClassId}, "t_base_class") //将结果序列化 reply.Success = true reply.Count = 1 @@ -38,7 +38,7 @@ func (s *Rpc) AddBaseClass(ctx context.Context, in *BaseClassProto.ModelArg) (*B //rpc响应 var reply BaseClassProto.Reply //检查单位号是不是存在 - list := SqlKit.QueryIds([]string{in.BureauId}, "t_base_organization") + list := SqlKit.QueryListMapByIds([]string{in.BureauId}, "t_base_organization") if list == nil || len(list) == 0 { reply.Success = false reply.Message = "输入的学校编号不存在,无法创建班级!" diff --git a/dsBaseRpc/RpcService/BaseGlobal/BaseGlobalService/BaseGlobalService.go b/dsBaseRpc/RpcService/BaseGlobal/BaseGlobalService/BaseGlobalService.go index 0155929c..3e8c7742 100644 --- a/dsBaseRpc/RpcService/BaseGlobal/BaseGlobalService/BaseGlobalService.go +++ b/dsBaseRpc/RpcService/BaseGlobal/BaseGlobalService/BaseGlobalService.go @@ -18,7 +18,7 @@ func (s *Rpc) GetBaseGlobal(ctx context.Context, in *BaseGlobalProto.ModelArg) ( //rpc响应 var reply BaseGlobalProto.Reply //通用获取单条 - list := SqlKit.QueryIds([]string{in.GlobalId}, "t_base_global") + list := SqlKit.QueryListMapByIds([]string{in.GlobalId}, "t_base_global") //将结果序列化 reply.Success = true reply.Count = 1 diff --git a/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationDao/BaseOrganizationDao.go b/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationDao/BaseOrganizationDao.go index f5a886bc..77a13577 100644 --- a/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationDao/BaseOrganizationDao.go +++ b/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationDao/BaseOrganizationDao.go @@ -265,7 +265,7 @@ func GetChildSchoolCount(mainSchoolId string) (int64, error) { 时间:2020-06-03 */ func GetBureauAdministrativeDivision(BureauId string) (string, string, string, string, string, error) { - list := SqlKit.QueryIds([]string{BureauId}, "t_base_organization") + list := SqlKit.QueryListMapByIds([]string{BureauId}, "t_base_organization") if len(list) > 0 { return list[0]["area_code"].(string), list[0]["province_code"].(string), list[0]["city_code"].(string), list[0]["district_code"].(string), list[0]["main_school_id"].(string), nil @@ -280,7 +280,7 @@ func GetBureauAdministrativeDivision(BureauId string) (string, string, string, s 时间:2020-06-03 */ func GetMultipleBaseOrganization(Ids []string) ([]map[string]interface{}, int32, error) { - list := SqlKit.QueryIds(Ids, "t_base_organization") + list := SqlKit.QueryListMapByIds(Ids, "t_base_organization") return list, int32(len(list)), nil } diff --git a/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationService/BaseOrganizationService.go b/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationService/BaseOrganizationService.go index 83ea78a1..ec47837b 100644 --- a/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationService/BaseOrganizationService.go +++ b/dsBaseRpc/RpcService/BaseOrganization/BaseOrganizationService/BaseOrganizationService.go @@ -30,7 +30,7 @@ func (s *Rpc) GetBaseOrganization(ctx context.Context, in *BaseOrganizationProto //rpc响应 var reply BaseOrganizationProto.Reply //使用通用方法获取单条记录 - list := SqlKit.QueryIds([]string{in.OrgId}, "t_base_organization") + list := SqlKit.QueryListMapByIds([]string{in.OrgId}, "t_base_organization") //将结果序列化 reply.Success = true @@ -373,7 +373,7 @@ func (s *Rpc) UpdateBaseOrganization(ctx context.Context, in *BaseOrganizationPr //普通学校 model.MainSchoolType = 1 //查看它有没有父校? - list := SqlKit.QueryIds([]string{in.OrgId}, "t_base_organization") + list := SqlKit.QueryListMapByIds([]string{in.OrgId}, "t_base_organization") mainSchoolId := list[0]["main_school_id"] if mainSchoolId != "" { @@ -596,7 +596,7 @@ func (s *Rpc) GetOrgManager(ctx context.Context, in *BaseOrganizationProto.Multi */ func UpdateManager(bureauId string, bUse int32) error { //使用通用方法获取单条记录 - list := SqlKit.QueryIds([]string{bureauId}, "t_base_organization") + list := SqlKit.QueryListMapByIds([]string{bureauId}, "t_base_organization") bureauName := list[0]["org_name"].(string) orgType := int32(list[0]["org_type"].(float64)) //组织机构类型 1:教育局 2:学校 3:部门 4:院 5:系 6:专业 7:教辅单位,8:大学区 diff --git a/dsBaseRpc/RpcService/BaseOrganizationManager/BaseOrganizationManagerDao/BaseOrganizationManagerDao.go b/dsBaseRpc/RpcService/BaseOrganizationManager/BaseOrganizationManagerDao/BaseOrganizationManagerDao.go index 6f82ee0c..e9a21614 100644 --- a/dsBaseRpc/RpcService/BaseOrganizationManager/BaseOrganizationManagerDao/BaseOrganizationManagerDao.go +++ b/dsBaseRpc/RpcService/BaseOrganizationManager/BaseOrganizationManagerDao/BaseOrganizationManagerDao.go @@ -22,7 +22,7 @@ func UpdateOrgManager(OrgId string, OrgManagerIds []string) error { //2、后插入 //部门所在的单位 - list := SqlKit.QueryIds([]string{OrgId}, "t_base_organization") + list := SqlKit.QueryListMapByIds([]string{OrgId}, "t_base_organization") BureauId := list[0]["bureau_id"].(string) //事务声明 diff --git a/dsBaseRpc/RpcService/BasePurview/BasePurviewService/BasePurviewService.go b/dsBaseRpc/RpcService/BasePurview/BasePurviewService/BasePurviewService.go index 5ae727ee..db9517b5 100644 --- a/dsBaseRpc/RpcService/BasePurview/BasePurviewService/BasePurviewService.go +++ b/dsBaseRpc/RpcService/BasePurview/BasePurviewService/BasePurviewService.go @@ -20,7 +20,7 @@ func (s *Rpc) GetBasePurview(ctx context.Context, in *BasePurviewProto.ModelArg) //统一返回的结构体 var reply BasePurviewProto.Reply //通用获取单条 - list := SqlKit.QueryIds([]string{in.PurviewId}, "t_base_purview") + list := SqlKit.QueryListMapByIds([]string{in.PurviewId}, "t_base_purview") //将结果序列化 reply.Success = true reply.Count = 1 diff --git a/dsBaseRpc/RpcService/BaseRolePerson/BaseRolePersonService/BaseRolePersonService.go b/dsBaseRpc/RpcService/BaseRolePerson/BaseRolePersonService/BaseRolePersonService.go index 3ad7536b..17985a6d 100644 --- a/dsBaseRpc/RpcService/BaseRolePerson/BaseRolePersonService/BaseRolePersonService.go +++ b/dsBaseRpc/RpcService/BaseRolePerson/BaseRolePersonService/BaseRolePersonService.go @@ -20,7 +20,7 @@ func (s *Rpc) GetBaseRolePerson(ctx context.Context, in *BaseRolePersonProto.Mod //rpc响应 var reply BaseRolePersonProto.Reply //通用获取单条 - list := SqlKit.QueryIds([]string{in.Id}, "t_base_role_person") + list := SqlKit.QueryListMapByIds([]string{in.Id}, "t_base_role_person") //将结果序列化 reply.Success = true reply.Count = 1 @@ -269,7 +269,7 @@ func (s *Rpc) CheckDataPrivilege(ctx context.Context, in *BaseRolePersonProto.Ch orgIds := in.OrgId if len(orgIds) > 0 { found = true - l2 := SqlKit.QueryIds(orgIds, "t_base_organization") + l2 := SqlKit.QueryListMapByIds(orgIds, "t_base_organization") if l2 == nil { reply.Success = false reply.Message = "传入的单位或部门ID没有找到!!" @@ -296,7 +296,7 @@ func (s *Rpc) CheckDataPrivilege(ctx context.Context, in *BaseRolePersonProto.Ch classIds := in.ClassId if len(classIds) > 0 { found = true - listClass := SqlKit.QueryIds(classIds, "t_base_class") + listClass := SqlKit.QueryListMapByIds(classIds, "t_base_class") if listClass == nil { reply.Success = false reply.Message = "传入的班级ID没有找到!!" diff --git a/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go b/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go index c8df7260..ffe06c34 100644 --- a/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go +++ b/dsBaseRpc/RpcService/BaseStudent/BaseStudentService/BaseStudentService.go @@ -27,7 +27,7 @@ func (s *Rpc) GetBaseStudent(ctx context.Context, in *BaseStudentProto.ModelArg) //rpc响应 var reply BaseStudentProto.Reply //通用获取单条 - list := SqlKit.QueryIds([]string{in.PersonId}, "t_base_student") + list := SqlKit.QueryListMapByIds([]string{in.PersonId}, "t_base_student") //将结果序列化 reply.Success = true reply.Count = 1 @@ -102,7 +102,7 @@ func (s *Rpc) AddBaseStudent(ctx context.Context, in *BaseStudentProto.ModelArg) model.BUse = 1 //状态码 model.StateId = 1 - list := SqlKit.QueryIds([]string{in.ClassId}, "t_base_class") + list := SqlKit.QueryListMapByIds([]string{in.ClassId}, "t_base_class") if list == nil || len(list) == 0 { reply.Success = false reply.Message = "没有找到对应的班级!" @@ -282,7 +282,7 @@ func (s *Rpc) UpdateBaseStudent(ctx context.Context, in *BaseStudentProto.ModelA //残疾标志 0:不是 1:是 model.Cjbz = in.Cjbz //查找此学生所在的班级 - list := SqlKit.QueryIds([]string{in.PersonId}, "t_base_student") + list := SqlKit.QueryListMapByIds([]string{in.PersonId}, "t_base_student") if list == nil || len(list) == 0 { reply.Success = false reply.Message = "没有找到对应的学生!" diff --git a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go index f7b67a8d..d20c0e02 100644 --- a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go +++ b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go @@ -101,7 +101,7 @@ func PageBaseTeacher(in *BaseTeacherProto.QueryArg) ([]map[string]interface{}, i From("t_base_teacher as t1"). LeftJoin("t_base_teacher_org as t2", "t1.person_id=t2.person_id") //所在单位ID - list := SqlKit.QueryIds([]string{in.OrgId}, "t_base_organization") + list := SqlKit.QueryListMapByIds([]string{in.OrgId}, "t_base_organization") if list == nil { return nil, 0, errors.New("没有找到此单位编码!") } diff --git a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go index 97541e76..d65afa44 100644 --- a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go +++ b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go @@ -30,7 +30,7 @@ func (s *Rpc) GetBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg) //rpc响应 var reply BaseTeacherProto.Reply //通用获取单条 - list := SqlKit.QueryIds([]string{in.PersonId}, "t_base_teacher") + list := SqlKit.QueryListMapByIds([]string{in.PersonId}, "t_base_teacher") //将结果序列化 reply.Success = true @@ -151,7 +151,7 @@ func (s *Rpc) AddBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg) //排序号 model.SortId = int32(BaseTeacherDao.GetMaxSortId(in.OrgId)) + 1 //主单位与主部门 - list := SqlKit.QueryIds([]string{in.OrgId}, "t_base_organization") + list := SqlKit.QueryListMapByIds([]string{in.OrgId}, "t_base_organization") if list == nil || len(list) == 0 { reply.Success = false reply.Message = "没有找到指定的组织机构ID!" diff --git a/dsBaseRpc/RpcService/GovArea/GovAreaService/GovAreaService.go b/dsBaseRpc/RpcService/GovArea/GovAreaService/GovAreaService.go index ea50fb9b..0ee3ab91 100644 --- a/dsBaseRpc/RpcService/GovArea/GovAreaService/GovAreaService.go +++ b/dsBaseRpc/RpcService/GovArea/GovAreaService/GovAreaService.go @@ -25,7 +25,7 @@ func (s *Rpc) GetGovArea(ctx context.Context, in *GovAreaProto.ModelArg) (*GovAr return &reply, nil } //通用获取单条 - list := SqlKit.QueryIds([]string{in.AreaCode}, "t_gov_area") + list := SqlKit.QueryListMapByIds([]string{in.AreaCode}, "t_gov_area") //将结果序列化 reply.Success = true reply.Count = 1 diff --git a/dsBaseRpc/RpcService/SysDict/SysDictService/SysDictService.go b/dsBaseRpc/RpcService/SysDict/SysDictService/SysDictService.go index 972fcb7d..13defa6b 100644 --- a/dsBaseRpc/RpcService/SysDict/SysDictService/SysDictService.go +++ b/dsBaseRpc/RpcService/SysDict/SysDictService/SysDictService.go @@ -19,7 +19,7 @@ func (s *Rpc) GetSysDict(ctx context.Context, in *SysDictProto.ModelArg) (*SysDi //统一返回的结构体 var reply SysDictProto.Reply //通用获取单条 - list := SqlKit.QueryIds([]string{CommonUtil.ConvertInt32ToString(in.DictId)}, "t_sys_dict") + list := SqlKit.QueryListMapByIds([]string{CommonUtil.ConvertInt32ToString(in.DictId)}, "t_sys_dict") //将结果序列化 reply.Success = true reply.Count = 1 diff --git a/dsBaseRpc/RpcService/SysLoginperson/SysLoginpersonService/SysLoginpersonService.go b/dsBaseRpc/RpcService/SysLoginperson/SysLoginpersonService/SysLoginpersonService.go index f06672fa..b31084af 100644 --- a/dsBaseRpc/RpcService/SysLoginperson/SysLoginpersonService/SysLoginpersonService.go +++ b/dsBaseRpc/RpcService/SysLoginperson/SysLoginpersonService/SysLoginpersonService.go @@ -21,7 +21,7 @@ func (s *Rpc) GetSysLoginperson(ctx context.Context, in *SysLoginpersonProto.Mod //rpc响应 var reply SysLoginpersonProto.Reply //通用获取单条 - list := SqlKit.QueryIds([]string{in.Id}, "t_sys_loginperson") + list := SqlKit.QueryListMapByIds([]string{in.Id}, "t_sys_loginperson") //将结果序列化 reply.Success = true reply.Count = 1 diff --git a/dsBaseRpc/Test/TestOutIndex/TestOutIndex.go b/dsBaseRpc/Test/TestOutIndex/TestOutIndex.go index 00dc8ce0..1289de93 100644 --- a/dsBaseRpc/Test/TestOutIndex/TestOutIndex.go +++ b/dsBaseRpc/Test/TestOutIndex/TestOutIndex.go @@ -8,7 +8,7 @@ import ( func main(){ var ClassId="1" - list := SqlKit.QueryIds([]string{ClassId}, "t_base_class") + list := SqlKit.QueryListMapByIds([]string{ClassId}, "t_base_class") list2:=make([]map[string]interface{},0) fmt.Println(list) fmt.Println(list2) diff --git a/dsBaseRpc/Utils/SqlKit/SqlKit.go b/dsBaseRpc/Utils/SqlKit/SqlKit.go index 690a81d9..50776098 100644 --- a/dsBaseRpc/Utils/SqlKit/SqlKit.go +++ b/dsBaseRpc/Utils/SqlKit/SqlKit.go @@ -43,7 +43,7 @@ func DeleteIds(tableName string, ids []string) error { 作者:黄海 时间:2020-02-05 */ -func QueryIds(ids []string, tableName string) []map[string]interface{} { +func QueryListMapByIds(ids []string, tableName string) []map[string]interface{} { return getListByIds(ids, GetBean(tableName)) } func getListByIds(ids []string, m Selector) []map[string]interface{} {