master
huanghai 5 years ago
parent 03df17ee8d
commit 5fca70e954

@ -91,21 +91,24 @@ func UpdateBaseTeacher(model models.TBaseTeacher, ForceUpdateFields []string) (i
//分页查询
func PageBaseTeacher(in *BaseTeacherProto.QueryArg) ([]map[string]interface{}, int32, error) {
//所在单位ID
list := SqlKit.QueryByIds([]string{in.OrgId}, "t_base_organization")
if list == nil {
return nil, 0, errors.New("没有找到此单位代码!")
}
bureauId := list[0]["bureau_id"].(string)
//接收传入参数
var limit = int(in.Limit)
var offset = int((in.Page - 1) * in.Limit)
// 注意使用limit时要使用方言
// 注意两个表关联时的on用法
var myBuilder = builder.Dialect(builder.MYSQL).Select("t1.*,t2.bureau_id,t2.org_id").
var myBuilder = builder.Dialect(builder.MYSQL).Select(`t1.person_id,t1.identity_id,group_concat(t3.org_name) as org_name,t1.id_int,t1.xm,t1.xmpy,t1.cym,t1.xbm,t1.csrq,t1.mzm,t1.zzmmm,t1.sfzjlxm,t1.sfzjh,t1.xlm,t1.xwm,t1.zcm,t1.bzlbm,t1.cjny,t1.stage_id,t1.subject_id,t1.gwzym,t1.lxdh,t1.dzxx,t1.b_use,t1.state_id,t1.last_updated_time,t1.create_time,t2.bureau_id,t2.org_id`).
From("t_base_teacher as t1").
LeftJoin("t_base_teacher_org as t2", "t1.person_id=t2.person_id and t2.b_use=1").
LeftJoin("t_base_teacher_org as t2", "t1.person_id=t2.person_id and t2.b_use=1 and t2.bureau_id='"+bureauId+"'").
InnerJoin("t_base_organization as t3","t2.org_id=t3.org_id").
OrderBy("t2.sort_id")
//所在单位ID
list := SqlKit.QueryByIds([]string{in.OrgId}, "t_base_organization")
if list == nil {
return nil, 0, errors.New("没有找到此单位代码!")
}
bureauId := list[0]["bureau_id"].(string)
if in.OrgId == bureauId {
//如果是单位ID
myBuilder.And(builder.Eq{"t2.bureau_id": in.OrgId})
@ -119,6 +122,8 @@ func PageBaseTeacher(in *BaseTeacherProto.QueryArg) ([]map[string]interface{}, i
myBuilder.And(builder.Eq{"t1.b_use": 1})
//只要identity_id=2
myBuilder.And(builder.Eq{"t1.identity_id": 2})
//分组
myBuilder.GroupBy("t1.person_id")
//分页
myBuilder.Limit(limit, offset)
//获取拼接完成的SQL语句

@ -440,29 +440,6 @@ var doc = `{
]
}
},
"/oauth2/wxShowImg": {
"get": {
"description": "微信显示二维码",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"tags": [
"登录验证类"
],
"summary": "微信显示二维码",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/sso/addJoinApp": {
"post": {
"description": "增加一条接入系统的记录",

@ -424,29 +424,6 @@
]
}
},
"/oauth2/wxShowImg": {
"get": {
"description": "微信显示二维码",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"tags": [
"登录验证类"
],
"summary": "微信显示二维码",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/sso/addJoinApp": {
"post": {
"description": "增加一条接入系统的记录",

@ -317,21 +317,6 @@ paths:
- 登录验证类
x-emptylimit:
- code
/oauth2/wxShowImg:
get:
consumes:
- application/x-www-form-urlencoded
description: 微信显示二维码
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
summary: 微信显示二维码
tags:
- 登录验证类
/sso/addJoinApp:
post:
consumes:

Loading…
Cancel
Save