作者 yangfu

修改 我审核的(分页)

... ... @@ -170,16 +170,15 @@ where user_id=? and company_id=? and review_status in (%v) and status=1 and enab
return
}
func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, offset int, pageSize int, v interface{}) (total int, err error) {
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
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 (
select id,approve_time,approve_data,uid,chance_id,approve_message,update_at process_create_time
from audit_flow_process where uid=? and review_status in (%v)
)a left outer join chance b on a.chance_id = b.id
)a left outer join chance_data b on a.chance_id =b.chance_id
where (?=0 or unix_timestamp(a.update_at)<?)
order by a.update_at desc
LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) //备注:and enable_status =1 //就算已经删除了,列表上面还是要体现已经删除
order by a.approve_time desc
LIMIT ?,?`, utils.JoinInt8s(reviewStatus, ",")) //备注:and enable_status =1 //就算已经删除了,列表上面还是要体现已经删除
sqlCount := fmt.Sprintf(`select count(0)
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
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, pageSize); err != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, offset, pageSize); err != nil {
return
}
}
... ... @@ -195,16 +194,15 @@ from audit_flow_process where uid=? and review_status in (%v) `, utils.JoinInt8
}
//获取有效的机会
func GetChanceMyApproveChanceEnable(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
func GetChanceMyApproveChanceEnable(uid, cid int64, reviewStatus []int8, offset int, pageSize int, v interface{}) (total int, err error) {
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
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 (
select id,approve_time,approve_data,uid,chance_id,approve_message
from audit_flow_process where uid=? and review_status in (%v) and enable_status =1
)a left outer join chance b on a.chance_id = b.id
)a left outer join chance_data b on a.chance_id =b.chance_id
where (?=0 or unix_timestamp(a.update_at)<?)
order by a.update_at desc
LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) //,update_at process_create_time
LIMIT ?,?`, utils.JoinInt8s(reviewStatus, ",")) //,update_at process_create_time
sqlCount := fmt.Sprintf(`select count(0)
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
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, pageSize); err != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, offset, pageSize); err != nil {
return
}
}
... ...
... ... @@ -240,9 +240,10 @@ type ChanceItemOrm struct {
/*MyApproveChance 我审核的机会*/
type MyApproveChanceRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
ReviewStatus int8 `json:"reviewStatus"` //审核状态
PageInfo
//LastId int64 `json:"lastId"`
//PageSize int `json:"pageSize" valid:"Required"`
ReviewStatus int8 `json:"reviewStatus"` //审核状态
}
type MyApproveChanceResponse struct {
List []CommonListItem `json:"list"`
... ...
... ... @@ -48,6 +48,7 @@ var errmessge ErrorMap = map[int]string{
//模板相关
5301: "机会模板不存在",
5302: "该机会分类已被停用",
//消息相关
5401: "消息不存在",
... ...
... ... @@ -420,10 +420,12 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
//1.模板是否存在
if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil {
log.Error("模板不存在:", request.AuditTemplateId, err)
err = protocol.NewErrWithMessage(5302)
return
}
if chanceType, err = models.GetChanceTypeById(template.ChanceTypeId); err != nil {
log.Error("一级分类不存在:", request.AuditTemplateId, err)
err = protocol.NewErrWithMessage(5302)
return
}
auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
... ... @@ -1637,18 +1639,10 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) {
var (
ormItems []protocol.ChanceApproveItemOrm
chance *models.Chance
)
rsp = &protocol.MyApproveChanceResponse{List: make([]protocol.CommonListItem, 0)}
if request.LastId > 0 {
if chance, err = models.GetChanceById(request.LastId); err != nil {
log.Error("审批不存在", request.LastId, err)
return
}
request.LastId = chance.UpdateAt.Unix()
}
if request.ReviewStatus == protocol.ReviewStatusAuditging {
if rsp.Total, err = models.GetChanceMyApproveChanceEnable(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &ormItems); err != nil {
if rsp.Total, err = models.GetChanceMyApproveChanceEnable(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.Offset(), request.PageSize, &ormItems); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ... @@ -1657,7 +1651,7 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
return
}
} else {
if rsp.Total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &ormItems); err != nil {
if rsp.Total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.Offset(), request.PageSize, &ormItems); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ...