正在显示
3 个修改的文件
包含
18 行增加
和
6 行删除
@@ -86,16 +86,16 @@ func DeleteChanceDraftById(id int64) (err error) { | @@ -86,16 +86,16 @@ func DeleteChanceDraftById(id int64) (err error) { | ||
86 | } | 86 | } |
87 | 87 | ||
88 | //草稿项机会列表 | 88 | //草稿项机会列表 |
89 | -func GetDraftByChance(uid int64, offset int, pageSize int, v interface{}) (total int, err error) { | 89 | +func GetDraftByChance(uid int64, lastId int, pageSize int, v interface{}) (total int, err error) { |
90 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos | 90 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos |
91 | from ( | 91 | from ( |
92 | select b.id chance_id,b.user_id chance_user_id,b.source_content,b.enable_status,b.audit_template_id, | 92 | select b.id chance_id,b.user_id chance_user_id,b.source_content,b.enable_status,b.audit_template_id, |
93 | b.chance_type_id,b.create_at,b.update_at,b.department_id,b.self_checks | 93 | b.chance_type_id,b.create_at,b.update_at,b.department_id,b.self_checks |
94 | from chance_draft b | 94 | from chance_draft b |
95 | - where b.user_id=%v and enable_status=1 | 95 | + where b.user_id=%v and enable_status=1 and (?=0 or UNIX_TIMESTAMP(b.update_at)<?) |
96 | )a left outer join chance_data b on a.chance_id =b.chance_id | 96 | )a left outer join chance_data b on a.chance_id =b.chance_id |
97 | order by a.update_at desc | 97 | order by a.update_at desc |
98 | -limit %v,%v`, uid, offset, pageSize) | 98 | +limit %v`, uid, pageSize) |
99 | 99 | ||
100 | sqlCount := fmt.Sprintf(`select count(0) | 100 | sqlCount := fmt.Sprintf(`select count(0) |
101 | from chance_draft b | 101 | from chance_draft b |
@@ -105,7 +105,7 @@ limit %v,%v`, uid, offset, pageSize) | @@ -105,7 +105,7 @@ limit %v,%v`, uid, offset, pageSize) | ||
105 | return | 105 | return |
106 | } | 106 | } |
107 | if v != nil { | 107 | if v != nil { |
108 | - if err = utils.ExecuteQueryAll(v, sql); err != nil { | 108 | + if err = utils.ExecuteQueryAll(v, sql, lastId, lastId); err != nil { |
109 | return | 109 | return |
110 | } | 110 | } |
111 | } | 111 | } |
@@ -753,7 +753,10 @@ type DraftDeleteResponse struct { | @@ -753,7 +753,10 @@ type DraftDeleteResponse struct { | ||
753 | 753 | ||
754 | /*DraftByChance 草稿箱-机会列表*/ | 754 | /*DraftByChance 草稿箱-机会列表*/ |
755 | type DraftByChanceRequest struct { | 755 | type DraftByChanceRequest struct { |
756 | - PageInfo | 756 | + //PageInfo |
757 | + | ||
758 | + LastId int `json:"lastId"` | ||
759 | + PageSize int `json:"pageSize" valid:"Required"` //每页数量 | ||
757 | } | 760 | } |
758 | type DraftByChanceResponse struct{ ChancePoolResponse } | 761 | type DraftByChanceResponse struct{ ChancePoolResponse } |
759 | 762 |
@@ -2465,10 +2465,18 @@ func DraftDelete(header *protocol.RequestHeader, request *protocol.DraftDeleteRe | @@ -2465,10 +2465,18 @@ func DraftDelete(header *protocol.RequestHeader, request *protocol.DraftDeleteRe | ||
2465 | func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChanceRequest) (rsp *protocol.DraftByChanceResponse, err error) { | 2465 | func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChanceRequest) (rsp *protocol.DraftByChanceResponse, err error) { |
2466 | var ( | 2466 | var ( |
2467 | ormItems []protocol.DraftChanceItemOrm | 2467 | ormItems []protocol.DraftChanceItemOrm |
2468 | + draft *models.ChanceDraft | ||
2468 | ) | 2469 | ) |
2469 | rsp = &protocol.DraftByChanceResponse{} | 2470 | rsp = &protocol.DraftByChanceResponse{} |
2470 | rsp.List = make([]protocol.CommonListItem, 0) | 2471 | rsp.List = make([]protocol.CommonListItem, 0) |
2471 | - if rsp.Total, err = models.GetDraftByChance(header.UserId, request.Offset(), request.PageSize, &ormItems); err != nil { | 2472 | + if request.LastId > 0 { |
2473 | + if draft, err = models.GetChanceDraftById(int64(request.LastId)); err != nil { | ||
2474 | + log.Error(err) | ||
2475 | + return | ||
2476 | + } | ||
2477 | + request.LastId = int(draft.UpdateAt.Unix()) | ||
2478 | + } | ||
2479 | + if rsp.Total, err = models.GetDraftByChance(header.UserId, request.LastId, request.PageSize, &ormItems); err != nil { | ||
2472 | if err == orm.ErrNoRows { | 2480 | if err == orm.ErrNoRows { |
2473 | err = nil | 2481 | err = nil |
2474 | return | 2482 | return |
@@ -2480,6 +2488,7 @@ func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChan | @@ -2480,6 +2488,7 @@ func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChan | ||
2480 | ormItem := ormItems[i] | 2488 | ormItem := ormItems[i] |
2481 | commItem := agg.NewCommonListItem(header, ormItem.CommChanceItemOrm) | 2489 | commItem := agg.NewCommonListItem(header, ormItem.CommChanceItemOrm) |
2482 | commItem.Chance.CreateTime = ormItem.UpdateTime.Unix() * 1000 | 2490 | commItem.Chance.CreateTime = ormItem.UpdateTime.Unix() * 1000 |
2491 | + commItem.Chance.RelatedDepartmentId = int64(ormItem.DepartmentId) | ||
2483 | commItem.Chance.RelatedDepartmentInfo = agg.GetDepartment(ormItem.DepartmentId) | 2492 | commItem.Chance.RelatedDepartmentInfo = agg.GetDepartment(ormItem.DepartmentId) |
2484 | commItem.Chance.ApproveTime = 0 | 2493 | commItem.Chance.ApproveTime = 0 |
2485 | 2494 |
-
请 注册 或 登录 后发表评论