作者 yangfu

修改 我审核的(分页)

@@ -170,16 +170,15 @@ where user_id=? and company_id=? and review_status in (%v) and status=1 and enab @@ -170,16 +170,15 @@ where user_id=? and company_id=? and review_status in (%v) and status=1 and enab
170 return 170 return
171 } 171 }
172 172
173 -func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { 173 +func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, offset int, pageSize int, v interface{}) (total int, err error) {
174 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( 174 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
175 select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time,b.status from ( 175 select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time,b.status from (
176 select id,approve_time,approve_data,uid,chance_id,approve_message,update_at process_create_time 176 select id,approve_time,approve_data,uid,chance_id,approve_message,update_at process_create_time
177 from audit_flow_process where uid=? and review_status in (%v) 177 from audit_flow_process where uid=? and review_status in (%v)
178 )a left outer join chance b on a.chance_id = b.id 178 )a left outer join chance b on a.chance_id = b.id
179 )a left outer join chance_data b on a.chance_id =b.chance_id 179 )a left outer join chance_data b on a.chance_id =b.chance_id
180 -where (?=0 or unix_timestamp(a.update_at)<?)  
181 -order by a.update_at desc  
182 -LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) //备注:and enable_status =1 //就算已经删除了,列表上面还是要体现已经删除 180 +order by a.approve_time desc
  181 +LIMIT ?,?`, utils.JoinInt8s(reviewStatus, ",")) //备注:and enable_status =1 //就算已经删除了,列表上面还是要体现已经删除
183 182
184 sqlCount := fmt.Sprintf(`select count(0) 183 sqlCount := fmt.Sprintf(`select count(0)
185 from audit_flow_process where uid=? and review_status in (%v) `, utils.JoinInt8s(reviewStatus, ",")) //and enable_status =1 184 from audit_flow_process where uid=? and review_status in (%v) `, utils.JoinInt8s(reviewStatus, ",")) //and enable_status =1
@@ -187,7 +186,7 @@ from audit_flow_process where uid=? and review_status in (%v) `, utils.JoinInt8 @@ -187,7 +186,7 @@ from audit_flow_process where uid=? and review_status in (%v) `, utils.JoinInt8
187 return 186 return
188 } 187 }
189 if v != nil { 188 if v != nil {
190 - if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, pageSize); err != nil { 189 + if err = utils.ExecuteQueryAll(v, sql, uid, offset, pageSize); err != nil {
191 return 190 return
192 } 191 }
193 } 192 }
@@ -195,16 +194,15 @@ from audit_flow_process where uid=? and review_status in (%v) `, utils.JoinInt8 @@ -195,16 +194,15 @@ from audit_flow_process where uid=? and review_status in (%v) `, utils.JoinInt8
195 } 194 }
196 195
197 //获取有效的机会 196 //获取有效的机会
198 -func GetChanceMyApproveChanceEnable(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { 197 +func GetChanceMyApproveChanceEnable(uid, cid int64, reviewStatus []int8, offset int, pageSize int, v interface{}) (total int, err error) {
199 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( 198 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
200 select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time,b.status,b.update_at process_create_time,b.self_checks from ( 199 select a.*,b.user_id chance_user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time,b.status,b.update_at process_create_time,b.self_checks from (
201 select id,approve_time,approve_data,uid,chance_id,approve_message 200 select id,approve_time,approve_data,uid,chance_id,approve_message
202 from audit_flow_process where uid=? and review_status in (%v) and enable_status =1 201 from audit_flow_process where uid=? and review_status in (%v) and enable_status =1
203 )a left outer join chance b on a.chance_id = b.id 202 )a left outer join chance b on a.chance_id = b.id
204 )a left outer join chance_data b on a.chance_id =b.chance_id 203 )a left outer join chance_data b on a.chance_id =b.chance_id
205 -where (?=0 or unix_timestamp(a.update_at)<?)  
206 order by a.update_at desc 204 order by a.update_at desc
207 -LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) //,update_at process_create_time 205 +LIMIT ?,?`, utils.JoinInt8s(reviewStatus, ",")) //,update_at process_create_time
208 206
209 sqlCount := fmt.Sprintf(`select count(0) 207 sqlCount := fmt.Sprintf(`select count(0)
210 from audit_flow_process where uid=? and review_status in (%v) and enable_status =1`, utils.JoinInt8s(reviewStatus, ",")) //and enable_status =1 208 from audit_flow_process where uid=? and review_status in (%v) and enable_status =1`, utils.JoinInt8s(reviewStatus, ",")) //and enable_status =1
@@ -212,7 +210,7 @@ from audit_flow_process where uid=? and review_status in (%v) and enable_status @@ -212,7 +210,7 @@ from audit_flow_process where uid=? and review_status in (%v) and enable_status
212 return 210 return
213 } 211 }
214 if v != nil { 212 if v != nil {
215 - if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, pageSize); err != nil { 213 + if err = utils.ExecuteQueryAll(v, sql, uid, offset, pageSize); err != nil {
216 return 214 return
217 } 215 }
218 } 216 }
@@ -240,9 +240,10 @@ type ChanceItemOrm struct { @@ -240,9 +240,10 @@ type ChanceItemOrm struct {
240 240
241 /*MyApproveChance 我审核的机会*/ 241 /*MyApproveChance 我审核的机会*/
242 type MyApproveChanceRequest struct { 242 type MyApproveChanceRequest struct {
243 - LastId int64 `json:"lastId"`  
244 - PageSize int `json:"pageSize" valid:"Required"`  
245 - ReviewStatus int8 `json:"reviewStatus"` //审核状态 243 + PageInfo
  244 + //LastId int64 `json:"lastId"`
  245 + //PageSize int `json:"pageSize" valid:"Required"`
  246 + ReviewStatus int8 `json:"reviewStatus"` //审核状态
246 } 247 }
247 type MyApproveChanceResponse struct { 248 type MyApproveChanceResponse struct {
248 List []CommonListItem `json:"list"` 249 List []CommonListItem `json:"list"`
@@ -48,6 +48,7 @@ var errmessge ErrorMap = map[int]string{ @@ -48,6 +48,7 @@ var errmessge ErrorMap = map[int]string{
48 48
49 //模板相关 49 //模板相关
50 5301: "机会模板不存在", 50 5301: "机会模板不存在",
  51 + 5302: "该机会分类已被停用",
51 52
52 //消息相关 53 //消息相关
53 5401: "消息不存在", 54 5401: "消息不存在",
@@ -420,10 +420,12 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -420,10 +420,12 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
420 //1.模板是否存在 420 //1.模板是否存在
421 if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil { 421 if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil {
422 log.Error("模板不存在:", request.AuditTemplateId, err) 422 log.Error("模板不存在:", request.AuditTemplateId, err)
  423 + err = protocol.NewErrWithMessage(5302)
423 return 424 return
424 } 425 }
425 if chanceType, err = models.GetChanceTypeById(template.ChanceTypeId); err != nil { 426 if chanceType, err = models.GetChanceTypeById(template.ChanceTypeId); err != nil {
426 log.Error("一级分类不存在:", request.AuditTemplateId, err) 427 log.Error("一级分类不存在:", request.AuditTemplateId, err)
  428 + err = protocol.NewErrWithMessage(5302)
427 return 429 return
428 } 430 }
429 auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover} 431 auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
@@ -1637,18 +1639,10 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ @@ -1637,18 +1639,10 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
1637 func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) { 1639 func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) {
1638 var ( 1640 var (
1639 ormItems []protocol.ChanceApproveItemOrm 1641 ormItems []protocol.ChanceApproveItemOrm
1640 - chance *models.Chance  
1641 ) 1642 )
1642 rsp = &protocol.MyApproveChanceResponse{List: make([]protocol.CommonListItem, 0)} 1643 rsp = &protocol.MyApproveChanceResponse{List: make([]protocol.CommonListItem, 0)}
1643 - if request.LastId > 0 {  
1644 - if chance, err = models.GetChanceById(request.LastId); err != nil {  
1645 - log.Error("审批不存在", request.LastId, err)  
1646 - return  
1647 - }  
1648 - request.LastId = chance.UpdateAt.Unix()  
1649 - }  
1650 if request.ReviewStatus == protocol.ReviewStatusAuditging { 1644 if request.ReviewStatus == protocol.ReviewStatusAuditging {
1651 - if rsp.Total, err = models.GetChanceMyApproveChanceEnable(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &ormItems); err != nil { 1645 + if rsp.Total, err = models.GetChanceMyApproveChanceEnable(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.Offset(), request.PageSize, &ormItems); err != nil {
1652 if err == orm.ErrNoRows { 1646 if err == orm.ErrNoRows {
1653 err = nil 1647 err = nil
1654 return 1648 return
@@ -1657,7 +1651,7 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove @@ -1657,7 +1651,7 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
1657 return 1651 return
1658 } 1652 }
1659 } else { 1653 } else {
1660 - if rsp.Total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &ormItems); err != nil { 1654 + if rsp.Total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.Offset(), request.PageSize, &ormItems); err != nil {
1661 if err == orm.ErrNoRows { 1655 if err == orm.ErrNoRows {
1662 err = nil 1656 err = nil
1663 return 1657 return