作者 yangfu

重构-消息中心 点赞/评论/机会提交/审核消息

@@ -1534,12 +1534,12 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh @@ -1534,12 +1534,12 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh
1534 //机会池 1534 //机会池
1535 func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequest) (rsp *protocol.ChancePoolResponse, err error) { 1535 func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequest) (rsp *protocol.ChancePoolResponse, err error) {
1536 var ( 1536 var (
1537 - myChances []protocol.ChancePoolItemOrm 1537 + chanceItems []protocol.ChancePoolItemOrm
1538 total int 1538 total int
1539 provider *protocol.BaseUserInfo 1539 provider *protocol.BaseUserInfo
1540 flag int 1540 flag int
1541 ) 1541 )
1542 - if total, err = agg.GetChancePool(header.UserId, header.CompanyId, request.ChanceTypeId, request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &myChances); err != nil { 1542 + if total, err = agg.GetChancePool(header.UserId, header.CompanyId, request.ChanceTypeId, request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &chanceItems); err != nil {
1543 if err == orm.ErrNoRows { 1543 if err == orm.ErrNoRows {
1544 err = nil 1544 err = nil
1545 return 1545 return
@@ -1548,14 +1548,16 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ @@ -1548,14 +1548,16 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
1548 return 1548 return
1549 } 1549 }
1550 rsp = &protocol.ChancePoolResponse{Total: total, List: make([]protocol.CommonListItem, 0)} 1550 rsp = &protocol.ChancePoolResponse{Total: total, List: make([]protocol.CommonListItem, 0)}
1551 - for i := 0; i < len(myChances); i++ {  
1552 - chance := myChances[i] 1551 + for i := 0; i < len(chanceItems); i++ {
  1552 + chance := chanceItems[i]
1553 if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil { 1553 if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {
1554 log.Error(err) 1554 log.Error(err)
1555 return 1555 return
1556 } 1556 }
1557 commItem := protocol.CommonListItem{} 1557 commItem := protocol.CommonListItem{}
1558 - { 1558 + commItem.ReviewStatus = chance.ReviewStatus //审核状态
  1559 +
  1560 + //机会数据
1559 item := protocol.ChanceItem{ 1561 item := protocol.ChanceItem{
1560 Id: chance.ChanceId, 1562 Id: chance.ChanceId,
1561 Provider: provider, 1563 Provider: provider,
@@ -1567,9 +1569,8 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ @@ -1567,9 +1569,8 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
1567 jsonUnmarshal(chance.Voices, &item.Speechs) 1569 jsonUnmarshal(chance.Voices, &item.Speechs)
1568 jsonUnmarshal(chance.Videos, &item.Videos) 1570 jsonUnmarshal(chance.Videos, &item.Videos)
1569 commItem.Chance = item 1571 commItem.Chance = item
1570 - }  
1571 - commItem.ReviewStatus = chance.ReviewStatus  
1572 - { 1572 +
  1573 + //点赞评论数据
1573 var chanceData = protocol.ChanceData{ 1574 var chanceData = protocol.ChanceData{
1574 ThumbsUpTotal: chance.ZanTotal, 1575 ThumbsUpTotal: chance.ZanTotal,
1575 CommentTotal: chance.CommentTotal, 1576 CommentTotal: chance.CommentTotal,
@@ -1582,23 +1583,10 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ @@ -1582,23 +1583,10 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
1582 chanceData.IsThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan 1583 chanceData.IsThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan
1583 chanceData.IsCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect 1584 chanceData.IsCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect
1584 commItem.ChanceData = chanceData 1585 commItem.ChanceData = chanceData
1585 - }  
1586 1586
1587 - {  
1588 - //做一次查询 查回所有的模板数据  
1589 - if template, e := models.GetAuditTemplateById(int64(chance.TemplateId)); e == nil {  
1590 - commItem.ChanceTemplate = protocol.NameItem{  
1591 - Id: int(template.Id),  
1592 - Name: template.Name,  
1593 - }  
1594 - }  
1595 - if chanceType, e := models.GetChanceTypeById(chance.ChanceTypeId); e == nil {  
1596 - commItem.ChanceType = protocol.NameItem{  
1597 - Id: int(chanceType.Id),  
1598 - Name: chanceType.Name,  
1599 - }  
1600 - }  
1601 - } 1587 + //模板数据
  1588 + commItem.ChanceTemplate = getTemplate(chance.TemplateId)
  1589 + commItem.ChanceType = getChanceType(chance.ChanceTypeId)
1602 rsp.List = append(rsp.List, commItem) 1590 rsp.List = append(rsp.List, commItem)
1603 } 1591 }
1604 return 1592 return
@@ -1642,6 +1630,9 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove @@ -1642,6 +1630,9 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
1642 commItem := protocol.CommonListItem{} 1630 commItem := protocol.CommonListItem{}
1643 commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm) 1631 commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
1644 commItem.ReviewStatus = ormItem.ReviewStatus 1632 commItem.ReviewStatus = ormItem.ReviewStatus
  1633 + if commItem.Chance.ApproveTime <= 0 {
  1634 + commItem.Chance.ApproveTime = ormItem.UpdateTime.Unix() * 1000
  1635 + }
1645 1636
1646 //审核流数据 1637 //审核流数据
1647 approve := protocol.Approve{ 1638 approve := protocol.Approve{
@@ -1656,7 +1647,6 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove @@ -1656,7 +1647,6 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
1656 } 1647 }
1657 } 1648 }
1658 commItem.Approve = approve 1649 commItem.Approve = approve
1659 -  
1660 //审核中 有审核消息 1650 //审核中 有审核消息
1661 if request.ReviewStatus == protocol.ReviewStatusAuditging { 1651 if request.ReviewStatus == protocol.ReviewStatusAuditging {
1662 commItem.Message = ormItem.ApproveMessage 1652 commItem.Message = ormItem.ApproveMessage