作者 yangfu

修改 1.草稿箱列表分页

... ... @@ -86,16 +86,16 @@ func DeleteChanceDraftById(id int64) (err error) {
}
//草稿项机会列表
func GetDraftByChance(uid int64, offset int, pageSize int, v interface{}) (total int, err error) {
func GetDraftByChance(uid int64, lastId int, pageSize int, v interface{}) (total int, err error) {
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos
from (
select b.id chance_id,b.user_id chance_user_id,b.source_content,b.enable_status,b.audit_template_id,
b.chance_type_id,b.create_at,b.update_at,b.department_id,b.self_checks
from chance_draft b
where b.user_id=%v and enable_status=1
where b.user_id=%v and enable_status=1 and (?=0 or UNIX_TIMESTAMP(b.update_at)<?)
)a left outer join chance_data b on a.chance_id =b.chance_id
order by a.update_at desc
limit %v,%v`, uid, offset, pageSize)
limit %v`, uid, pageSize)
sqlCount := fmt.Sprintf(`select count(0)
from chance_draft b
... ... @@ -105,7 +105,7 @@ limit %v,%v`, uid, offset, pageSize)
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql); err != nil {
if err = utils.ExecuteQueryAll(v, sql, lastId, lastId); err != nil {
return
}
}
... ...
... ... @@ -753,7 +753,10 @@ type DraftDeleteResponse struct {
/*DraftByChance 草稿箱-机会列表*/
type DraftByChanceRequest struct {
PageInfo
//PageInfo
LastId int `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"` //每页数量
}
type DraftByChanceResponse struct{ ChancePoolResponse }
... ...
... ... @@ -2465,10 +2465,18 @@ func DraftDelete(header *protocol.RequestHeader, request *protocol.DraftDeleteRe
func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChanceRequest) (rsp *protocol.DraftByChanceResponse, err error) {
var (
ormItems []protocol.DraftChanceItemOrm
draft *models.ChanceDraft
)
rsp = &protocol.DraftByChanceResponse{}
rsp.List = make([]protocol.CommonListItem, 0)
if rsp.Total, err = models.GetDraftByChance(header.UserId, request.Offset(), request.PageSize, &ormItems); err != nil {
if request.LastId > 0 {
if draft, err = models.GetChanceDraftById(int64(request.LastId)); err != nil {
log.Error(err)
return
}
request.LastId = int(draft.UpdateAt.Unix())
}
if rsp.Total, err = models.GetDraftByChance(header.UserId, request.LastId, request.PageSize, &ormItems); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ... @@ -2480,6 +2488,7 @@ func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChan
ormItem := ormItems[i]
commItem := agg.NewCommonListItem(header, ormItem.CommChanceItemOrm)
commItem.Chance.CreateTime = ormItem.UpdateTime.Unix() * 1000
commItem.Chance.RelatedDepartmentId = int64(ormItem.DepartmentId)
commItem.Chance.RelatedDepartmentInfo = agg.GetDepartment(ormItem.DepartmentId)
commItem.Chance.ApproveTime = 0
... ...