正在显示
8 个修改的文件
包含
233 行增加
和
22 行删除
| @@ -201,3 +201,53 @@ func (c *CommonController) SelectorChanceType() { | @@ -201,3 +201,53 @@ func (c *CommonController) SelectorChanceType() { | ||
| 201 | msg = protocol.NewReturnResponse(data, nil) | 201 | msg = protocol.NewReturnResponse(data, nil) |
| 202 | return | 202 | return |
| 203 | } | 203 | } |
| 204 | + | ||
| 205 | +//SelectCompanyUserList 下拉选择框 获取公司成员列表 | ||
| 206 | +func (c *CommonController) SelectCompanyUserList() { | ||
| 207 | + var msg *protocol.ResponseMessage | ||
| 208 | + defer func() { | ||
| 209 | + c.ResposeJson(msg) | ||
| 210 | + }() | ||
| 211 | + type Parameter struct { | ||
| 212 | + protocol.RequestPageInfo | ||
| 213 | + UserName string `json:"user_name"` | ||
| 214 | + } | ||
| 215 | + var param Parameter | ||
| 216 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
| 217 | + log.Error("json 解析失败 err:%s", err) | ||
| 218 | + msg = protocol.BadRequestParam("1") | ||
| 219 | + return | ||
| 220 | + } | ||
| 221 | + companyid := c.GetCompanyId() | ||
| 222 | + listData := servecommon.SelectCompanyUserList(param.PageIndex, param.PageSize, companyid, param.UserName) | ||
| 223 | + rspData := map[string]interface{}{ | ||
| 224 | + "gridResult": listData, | ||
| 225 | + } | ||
| 226 | + msg = protocol.NewReturnResponse(rspData, nil) | ||
| 227 | + return | ||
| 228 | +} | ||
| 229 | + | ||
| 230 | +//SelectChanceList 下拉选择框 获取机会列表 | ||
| 231 | +func (c *CommonController) SelectChanceList() { | ||
| 232 | + var msg *protocol.ResponseMessage | ||
| 233 | + defer func() { | ||
| 234 | + c.ResposeJson(msg) | ||
| 235 | + }() | ||
| 236 | + type Parameter struct { | ||
| 237 | + protocol.RequestPageInfo | ||
| 238 | + ChanceCode string `json:"chance_code"` | ||
| 239 | + } | ||
| 240 | + var param Parameter | ||
| 241 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
| 242 | + log.Error("json 解析失败 err:%s", err) | ||
| 243 | + msg = protocol.BadRequestParam("1") | ||
| 244 | + return | ||
| 245 | + } | ||
| 246 | + // companyid := c.GetCompanyId() | ||
| 247 | + // listData := servecommon.SelectCompanyUserList(param.PageIndex, param.PageSize, companyid, param.UserName) | ||
| 248 | + // rspData := map[string]interface{}{ | ||
| 249 | + // "gridResult": listData, | ||
| 250 | + // } | ||
| 251 | + // msg = protocol.NewReturnResponse(rspData, nil) | ||
| 252 | + return | ||
| 253 | +} |
| @@ -45,6 +45,12 @@ func (c RankController) EditRankType() { | @@ -45,6 +45,12 @@ func (c RankController) EditRankType() { | ||
| 45 | msg = protocol.BadRequestParam("1") | 45 | msg = protocol.BadRequestParam("1") |
| 46 | return | 46 | return |
| 47 | } | 47 | } |
| 48 | + param.Name = strings.TrimSpace(param.Name) | ||
| 49 | + n := []rune(param.Name) | ||
| 50 | + if len(n) > 5 || len(n) == 0 { | ||
| 51 | + msg = protocol.BadRequestParam("10103") | ||
| 52 | + return | ||
| 53 | + } | ||
| 48 | companyid := c.GetCompanyId() | 54 | companyid := c.GetCompanyId() |
| 49 | err := serverank.UpdateRankType(param.Id, param.Name, companyid) | 55 | err := serverank.UpdateRankType(param.Id, param.Name, companyid) |
| 50 | msg = protocol.NewReturnResponse(nil, err) | 56 | msg = protocol.NewReturnResponse(nil, err) |
| @@ -126,7 +132,17 @@ func (c RankController) RankSeasonAdd() { | @@ -126,7 +132,17 @@ func (c RankController) RankSeasonAdd() { | ||
| 126 | } | 132 | } |
| 127 | param.Name = strings.TrimSpace(param.Name) | 133 | param.Name = strings.TrimSpace(param.Name) |
| 128 | if len(param.Name) == 0 { | 134 | if len(param.Name) == 0 { |
| 129 | - msg = protocol.BadRequestParam("1") | 135 | + msg = protocol.BadRequestParam("10104") |
| 136 | + return | ||
| 137 | + } | ||
| 138 | + param.BeginTime = strings.TrimSpace(param.BeginTime) | ||
| 139 | + if len(param.BeginTime) == 0 { | ||
| 140 | + msg = protocol.BadRequestParam("10105") | ||
| 141 | + return | ||
| 142 | + } | ||
| 143 | + param.EndTime = strings.TrimSpace(param.EndTime) | ||
| 144 | + if len(param.EndTime) == 0 { | ||
| 145 | + msg = protocol.BadRequestParam("10106") | ||
| 130 | return | 146 | return |
| 131 | } | 147 | } |
| 132 | var ( | 148 | var ( |
| @@ -135,13 +151,13 @@ func (c RankController) RankSeasonAdd() { | @@ -135,13 +151,13 @@ func (c RankController) RankSeasonAdd() { | ||
| 135 | ) | 151 | ) |
| 136 | t1, err := time.ParseInLocation("2006-01-02", param.BeginTime, time.Local) | 152 | t1, err := time.ParseInLocation("2006-01-02", param.BeginTime, time.Local) |
| 137 | if err != nil { | 153 | if err != nil { |
| 138 | - msg = protocol.BadRequestParam("1") | 154 | + msg = protocol.BadRequestParam("10105") |
| 139 | return | 155 | return |
| 140 | } | 156 | } |
| 141 | beginTime = t1.Unix() | 157 | beginTime = t1.Unix() |
| 142 | t2, err := time.ParseInLocation("2006-01-02", param.EndTime, time.Local) | 158 | t2, err := time.ParseInLocation("2006-01-02", param.EndTime, time.Local) |
| 143 | if err != nil { | 159 | if err != nil { |
| 144 | - msg = protocol.BadRequestParam("1") | 160 | + msg = protocol.BadRequestParam("10106") |
| 145 | return | 161 | return |
| 146 | } | 162 | } |
| 147 | endTime = t2.Unix() + 86399 //60*60*24-1 | 163 | endTime = t2.Unix() + 86399 //60*60*24-1 |
| @@ -185,6 +201,16 @@ func (c RankController) RankSeasonEdit() { | @@ -185,6 +201,16 @@ func (c RankController) RankSeasonEdit() { | ||
| 185 | msg = protocol.BadRequestParam("1") | 201 | msg = protocol.BadRequestParam("1") |
| 186 | return | 202 | return |
| 187 | } | 203 | } |
| 204 | + param.BeginTime = strings.TrimSpace(param.BeginTime) | ||
| 205 | + if len(param.BeginTime) == 0 { | ||
| 206 | + msg = protocol.BadRequestParam("10105") | ||
| 207 | + return | ||
| 208 | + } | ||
| 209 | + param.EndTime = strings.TrimSpace(param.EndTime) | ||
| 210 | + if len(param.EndTime) == 0 { | ||
| 211 | + msg = protocol.BadRequestParam("10106") | ||
| 212 | + return | ||
| 213 | + } | ||
| 188 | var ( | 214 | var ( |
| 189 | beginTime int64 | 215 | beginTime int64 |
| 190 | endTime int64 | 216 | endTime int64 |
| @@ -192,14 +218,14 @@ func (c RankController) RankSeasonEdit() { | @@ -192,14 +218,14 @@ func (c RankController) RankSeasonEdit() { | ||
| 192 | t1, err := time.ParseInLocation("2006-01-02", param.BeginTime, time.Local) | 218 | t1, err := time.ParseInLocation("2006-01-02", param.BeginTime, time.Local) |
| 193 | if err != nil { | 219 | if err != nil { |
| 194 | log.Error(err.Error()) | 220 | log.Error(err.Error()) |
| 195 | - msg = protocol.BadRequestParam("1") | 221 | + msg = protocol.BadRequestParam("10105") |
| 196 | return | 222 | return |
| 197 | } | 223 | } |
| 198 | beginTime = t1.Unix() | 224 | beginTime = t1.Unix() |
| 199 | t2, err := time.ParseInLocation("2006-01-02", param.EndTime, time.Local) | 225 | t2, err := time.ParseInLocation("2006-01-02", param.EndTime, time.Local) |
| 200 | if err != nil { | 226 | if err != nil { |
| 201 | log.Error(err.Error()) | 227 | log.Error(err.Error()) |
| 202 | - msg = protocol.BadRequestParam("1") | 228 | + msg = protocol.BadRequestParam("10106") |
| 203 | return | 229 | return |
| 204 | } | 230 | } |
| 205 | 231 | ||
| @@ -261,6 +287,12 @@ func (c RankController) RankRangeAdd() { | @@ -261,6 +287,12 @@ func (c RankController) RankRangeAdd() { | ||
| 261 | msg = protocol.BadRequestParam("1") | 287 | msg = protocol.BadRequestParam("1") |
| 262 | return | 288 | return |
| 263 | } | 289 | } |
| 290 | + param.Name = strings.TrimSpace(param.Name) | ||
| 291 | + n := []rune(param.Name) | ||
| 292 | + if len(n) == 0 || len(n) > 5 { | ||
| 293 | + msg = protocol.BadRequestParam("10107") | ||
| 294 | + return | ||
| 295 | + } | ||
| 264 | switch param.RangeType { | 296 | switch param.RangeType { |
| 265 | case 1: | 297 | case 1: |
| 266 | //员工 | 298 | //员工 |
| @@ -306,6 +338,14 @@ func (c RankController) RankRangeEdit() { | @@ -306,6 +338,14 @@ func (c RankController) RankRangeEdit() { | ||
| 306 | msg = protocol.BadRequestParam("1") | 338 | msg = protocol.BadRequestParam("1") |
| 307 | return | 339 | return |
| 308 | } | 340 | } |
| 341 | + | ||
| 342 | + param.Name = strings.TrimSpace(param.Name) | ||
| 343 | + n := []rune(param.Name) | ||
| 344 | + if len(n) == 0 || len(n) > 5 { | ||
| 345 | + msg = protocol.BadRequestParam("10107") | ||
| 346 | + return | ||
| 347 | + } | ||
| 348 | + | ||
| 309 | switch param.RangeType { | 349 | switch param.RangeType { |
| 310 | case 1: | 350 | case 1: |
| 311 | //员工 | 351 | //员工 |
| @@ -498,8 +538,8 @@ func (c RankController) RankTypeConfigSet() { | @@ -498,8 +538,8 @@ func (c RankController) RankTypeConfigSet() { | ||
| 498 | }() | 538 | }() |
| 499 | type Parameter struct { | 539 | type Parameter struct { |
| 500 | RankTypeId int64 `json:"rank_type_id"` | 540 | RankTypeId int64 `json:"rank_type_id"` |
| 501 | - AutoCreate int `json:"auto_create"` //【0:不自动创建】【1:自动创建】 | ||
| 502 | - AutoCreateDay int64 `json:"auto_create_day"` //赛季时间, 单位:天 | 541 | + AutoCreate int8 `json:"auto_create"` //【0:不自动创建】【1:自动创建】 |
| 542 | + AutoCreateDay int `json:"auto_create_day"` //赛季时间, 单位:天 | ||
| 503 | } | 543 | } |
| 504 | var param Parameter | 544 | var param Parameter |
| 505 | if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | 545 | if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { |
| @@ -525,13 +565,14 @@ func (c RankController) RankTypeConfigSet() { | @@ -525,13 +565,14 @@ func (c RankController) RankTypeConfigSet() { | ||
| 525 | msg = protocol.NewReturnResponse(nil, e) | 565 | msg = protocol.NewReturnResponse(nil, e) |
| 526 | return | 566 | return |
| 527 | } | 567 | } |
| 528 | - v := models.RankTypeConfigSet{ | ||
| 529 | - AutoCreate: param.AutoCreate, | ||
| 530 | - AutoCreateLength: param.AutoCreateDay, | 568 | + if param.AutoCreate > 1 || param.AutoCreate < 0 { |
| 569 | + e := protocol.NewErrWithMessage("1") | ||
| 570 | + msg = protocol.NewReturnResponse(nil, e) | ||
| 571 | + return | ||
| 531 | } | 572 | } |
| 532 | - bt, _ := json.Marshal(v) | ||
| 533 | - rankType.ConfigSet = string(bt) | ||
| 534 | - err = models.UpdateRankById(rankType, []string{"ConfigSet"}) | 573 | + rankType.AutoCreate = param.AutoCreate |
| 574 | + rankType.AutoPeriod = param.AutoCreateDay | ||
| 575 | + err = models.UpdateRankById(rankType, []string{"AutoCreate", "AutoCreateDay"}) | ||
| 535 | if err != nil { | 576 | if err != nil { |
| 536 | log.Error("更新rank_type数据失败;%s", err) | 577 | log.Error("更新rank_type数据失败;%s", err) |
| 537 | e := protocol.NewErrWithMessage("1") | 578 | e := protocol.NewErrWithMessage("1") |
| @@ -576,8 +617,13 @@ func (c RankController) RankTypeConfigShow() { | @@ -576,8 +617,13 @@ func (c RankController) RankTypeConfigShow() { | ||
| 576 | msg = protocol.NewReturnResponse(nil, e) | 617 | msg = protocol.NewReturnResponse(nil, e) |
| 577 | return | 618 | return |
| 578 | } | 619 | } |
| 579 | - v := &models.RankTypeConfigSet{} | ||
| 580 | - json.Unmarshal([]byte(rankType.ConfigSet), v) | 620 | + v := struct { |
| 621 | + AutoCreate int8 `json:"auto_create"` | ||
| 622 | + AutoCreateDay int `json:"auto_create_day"` | ||
| 623 | + }{ | ||
| 624 | + AutoCreate: rankType.AutoCreate, | ||
| 625 | + AutoCreateDay: rankType.AutoPeriod, | ||
| 626 | + } | ||
| 581 | msg = protocol.NewReturnResponse(v, nil) | 627 | msg = protocol.NewReturnResponse(v, nil) |
| 582 | return | 628 | return |
| 583 | } | 629 | } |
| @@ -15,7 +15,8 @@ type RankType struct { | @@ -15,7 +15,8 @@ type RankType struct { | ||
| 15 | CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"` | 15 | CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"` |
| 16 | UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"` | 16 | UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"` |
| 17 | Type int8 `orm:"column(type)"` | 17 | Type int8 `orm:"column(type)"` |
| 18 | - ConfigSet string `orm:"column(config_set)"` | 18 | + AutoCreate int8 `orm:"column(auto_create)"` //是否自动创建赛季 【0:否】【1:是】 |
| 19 | + AutoPeriod int `orm:"column(auto_period)"` | ||
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | func (t *RankType) TableName() string { | 22 | func (t *RankType) TableName() string { |
| @@ -38,11 +39,6 @@ const ( | @@ -38,11 +39,6 @@ const ( | ||
| 38 | RANK_STATUS_NO int8 = 2 //禁用 | 39 | RANK_STATUS_NO int8 = 2 //禁用 |
| 39 | ) | 40 | ) |
| 40 | 41 | ||
| 41 | -type RankTypeConfigSet struct { | ||
| 42 | - AutoCreate int `json:"auto_create"` //【0:不自动创建】【1:自动创建】 | ||
| 43 | - AutoCreateLength int64 `json:"auto_create_length"` //【创建的赛季间隔,单位:天】 | ||
| 44 | -} | ||
| 45 | - | ||
| 46 | // AddRank insert a new Rank into database and returns | 42 | // AddRank insert a new Rank into database and returns |
| 47 | // last inserted Id on success. | 43 | // last inserted Id on success. |
| 48 | func AddRank(m *RankType) (id int64, err error) { | 44 | func AddRank(m *RankType) (id int64, err error) { |
| @@ -271,6 +271,7 @@ type RspAuditList struct { | @@ -271,6 +271,7 @@ type RspAuditList struct { | ||
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | type ChanceFlowLog struct { | 273 | type ChanceFlowLog struct { |
| 274 | + Id int64 `json:"id" orm:"column(id)"` | ||
| 274 | ChanceId string `json:"chance_id" orm:"column(chance_id)"` | 275 | ChanceId string `json:"chance_id" orm:"column(chance_id)"` |
| 275 | CreateAt string `json:"create_at" orm:"column(create_at)"` | 276 | CreateAt string `json:"create_at" orm:"column(create_at)"` |
| 276 | Content string `json:"content" orm:"column(content)"` | 277 | Content string `json:"content" orm:"column(content)"` |
| @@ -77,3 +77,16 @@ type ChanceTypeBase struct { | @@ -77,3 +77,16 @@ type ChanceTypeBase struct { | ||
| 77 | ChanceTypeId int64 `orm:"column(chance_type_id)" json:"chance_type_id"` | 77 | ChanceTypeId int64 `orm:"column(chance_type_id)" json:"chance_type_id"` |
| 78 | Name string `orm:"column(name)" json:"name"` | 78 | Name string `orm:"column(name)" json:"name"` |
| 79 | } | 79 | } |
| 80 | + | ||
| 81 | +type SelectCompanyUserListItem struct { | ||
| 82 | + UserCompanyId int64 `json:"user_company_id"` | ||
| 83 | + UserName string `json:"user_name"` | ||
| 84 | + DepartmentId int64 `json:"department_id"` | ||
| 85 | + DepartmentName string `json:"department_name"` | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +//下拉选择公司员工 | ||
| 89 | +type SelectCompanyUserList struct { | ||
| 90 | + ResponsePageInfo | ||
| 91 | + List []SelectCompanyUserListItem `json:"list"` | ||
| 92 | +} |
| @@ -109,6 +109,11 @@ var errmessge ErrorMap = map[string]string{ | @@ -109,6 +109,11 @@ var errmessge ErrorMap = map[string]string{ | ||
| 109 | //榜单设置 | 109 | //榜单设置 |
| 110 | "10101": "赛季周期设置与其他赛季重叠", | 110 | "10101": "赛季周期设置与其他赛季重叠", |
| 111 | "10102": "参与人类型不一致", | 111 | "10102": "参与人类型不一致", |
| 112 | + "10103": "排行榜名称最多5个字符", | ||
| 113 | + "10104": "赛季名称最多输入20个字符", | ||
| 114 | + "10105": "赛季开始时间必填", | ||
| 115 | + "10106": "赛季结束时间必填", | ||
| 116 | + "10107": "参与范围名称最多输入5个字符", | ||
| 112 | } | 117 | } |
| 113 | 118 | ||
| 114 | //错误码转换 ,兼容需要 | 119 | //错误码转换 ,兼容需要 |
| @@ -425,7 +425,7 @@ func getAuditFlowLog(chanceid int64) ([]protocol.ChanceFlowLog, error) { | @@ -425,7 +425,7 @@ func getAuditFlowLog(chanceid int64) ([]protocol.ChanceFlowLog, error) { | ||
| 425 | flowLogs = make([]protocol.ChanceFlowLog, 0) | 425 | flowLogs = make([]protocol.ChanceFlowLog, 0) |
| 426 | err error | 426 | err error |
| 427 | ) | 427 | ) |
| 428 | - const datasql string = `SELECT a.chance_id,a.content,a.create_at,c.nick_name,a.code | 428 | + const datasql string = `SELECT a.id, a.chance_id,a.content,a.create_at,c.nick_name,a.code |
| 429 | FROM audit_flow_log AS a | 429 | FROM audit_flow_log AS a |
| 430 | LEFT JOIN user_company AS b ON a.approve_user_id=b.id | 430 | LEFT JOIN user_company AS b ON a.approve_user_id=b.id |
| 431 | LEFT JOIN user AS c ON b.user_id = c.id | 431 | LEFT JOIN user AS c ON b.user_id = c.id |
| @@ -182,3 +182,103 @@ func SeleteGetChanceTypeList(companyid int64) []protocol.ChanceTypeBase { | @@ -182,3 +182,103 @@ func SeleteGetChanceTypeList(companyid int64) []protocol.ChanceTypeBase { | ||
| 182 | } | 182 | } |
| 183 | return data | 183 | return data |
| 184 | } | 184 | } |
| 185 | + | ||
| 186 | +func SelectCompanyUserList(pageIndex int, pageSize int, companyid int64, userName string) protocol.SelectCompanyUserList { | ||
| 187 | + datasql := `SELECT a.id,d.nick_name,c.name AS department_name,c.id AS department_id | ||
| 188 | + FROM user_company AS a | ||
| 189 | + LEFT JOIN user_department AS b ON a.id = b.user_company_id | ||
| 190 | + LEFT JOIN department AS c ON b.department_id = c.id | ||
| 191 | + LEFT JOIN user AS d ON a.user_id = d.id | ||
| 192 | + WHERE a.delete_at = 0 AND c.company_id = ? ` | ||
| 193 | + countsql := `SELECT count(*) | ||
| 194 | + FROM user_company AS a | ||
| 195 | + LEFT JOIN user_department AS b ON a.id = b.user_company_id | ||
| 196 | + LEFT JOIN department AS c ON b.department_id = c.id | ||
| 197 | + LEFT JOIN user AS d ON a.user_id = d.id | ||
| 198 | + WHERE a.delete_at = 0 AND c.company_id =? ` | ||
| 199 | + cond := []interface{}{companyid} | ||
| 200 | + where := "" | ||
| 201 | + if len(userName) > 0 { | ||
| 202 | + where += ` And d.nick_name like ? ` | ||
| 203 | + cond = append(cond, "%"+userName+"%") | ||
| 204 | + } | ||
| 205 | + datasql += where | ||
| 206 | + countsql += where | ||
| 207 | + pageStart := (pageIndex - 1) * pageSize | ||
| 208 | + datasql += fmt.Sprintf(` limit %d,%d `, pageStart, pageSize) | ||
| 209 | + var ( | ||
| 210 | + err error | ||
| 211 | + cnt int | ||
| 212 | + ) | ||
| 213 | + rspData := protocol.SelectCompanyUserList{ | ||
| 214 | + ResponsePageInfo: protocol.ResponsePageInfo{ | ||
| 215 | + TotalPage: 0, CurrentPage: pageIndex, | ||
| 216 | + }, | ||
| 217 | + List: make([]protocol.SelectCompanyUserListItem, 0), | ||
| 218 | + } | ||
| 219 | + err = utils.ExecuteQueryOne(&cnt, countsql, cond...) | ||
| 220 | + if err != nil { | ||
| 221 | + log.Error("SQL EXECUTE ERR:%s", err) | ||
| 222 | + return rspData | ||
| 223 | + } | ||
| 224 | + if cnt == 0 { | ||
| 225 | + return rspData | ||
| 226 | + } | ||
| 227 | + err = utils.ExecuteQueryAll(&rspData, datasql, cond...) | ||
| 228 | + if err != nil { | ||
| 229 | + log.Error("SQL EXECUTE ERR:%s", err) | ||
| 230 | + return rspData | ||
| 231 | + } | ||
| 232 | + return rspData | ||
| 233 | +} | ||
| 234 | + | ||
| 235 | +func SelectChanceList(pageIndex int, pageSize int, companyid int64, chanceCode string) protocol.SelectCompanyUserList { | ||
| 236 | + datasql := ` SELECT id ,department_id,chance_type_id,audit_template_id,user_id,create_at,code | ||
| 237 | + FROM chance WHERE company_id =? ` | ||
| 238 | + countsql := `SELECT count(*) | ||
| 239 | + FROM chance WHERE company_id =? | ||
| 240 | + ` | ||
| 241 | + cond := []interface{}{companyid} | ||
| 242 | + where := "" | ||
| 243 | + if len(chanceCode) > 0 { | ||
| 244 | + where += ` And code like ? ` | ||
| 245 | + cond = append(cond, "%"+chanceCode+"%") | ||
| 246 | + } | ||
| 247 | + datasql += where | ||
| 248 | + countsql += where | ||
| 249 | + pageStart := (pageIndex - 1) * pageSize | ||
| 250 | + datasql += fmt.Sprintf(` ORDER BY create_at DESC limit %d,%d `, pageStart, pageSize) | ||
| 251 | + type SqlData struct { | ||
| 252 | + Id int64 `orm:"column(id)"` | ||
| 253 | + DeparmentId int64 `orm:"column(DeparmentId)"` | ||
| 254 | + ChanceType int64 `orm:"column(ChanceType)"` | ||
| 255 | + AuditTemplate int64 `orm:"column(AuditTemplate)"` | ||
| 256 | + UserId int64 `orm:"column(UserId)"` | ||
| 257 | + CreateAt string `orm:"column(CreateAt)"` | ||
| 258 | + Code string `orm:"column(Code)"` | ||
| 259 | + } | ||
| 260 | + var ( | ||
| 261 | + err error | ||
| 262 | + cnt int | ||
| 263 | + ) | ||
| 264 | + rspData := protocol.SelectCompanyUserList{ | ||
| 265 | + ResponsePageInfo: protocol.ResponsePageInfo{ | ||
| 266 | + TotalPage: 0, CurrentPage: pageIndex, | ||
| 267 | + }, | ||
| 268 | + List: make([]protocol.SelectCompanyUserListItem, 0), | ||
| 269 | + } | ||
| 270 | + err = utils.ExecuteQueryOne(&cnt, countsql, cond...) | ||
| 271 | + if err != nil { | ||
| 272 | + log.Error("SQL EXECUTE ERR:%s", err) | ||
| 273 | + return rspData | ||
| 274 | + } | ||
| 275 | + if cnt == 0 { | ||
| 276 | + return rspData | ||
| 277 | + } | ||
| 278 | + err = utils.ExecuteQueryAll(&rspData, datasql, cond...) | ||
| 279 | + if err != nil { | ||
| 280 | + log.Error("SQL EXECUTE ERR:%s", err) | ||
| 281 | + return rspData | ||
| 282 | + } | ||
| 283 | + return rspData | ||
| 284 | +} |
-
请 注册 或 登录 后发表评论