作者 yangfu

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

... ... @@ -1534,12 +1534,12 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh
//机会池
func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequest) (rsp *protocol.ChancePoolResponse, err error) {
var (
myChances []protocol.ChancePoolItemOrm
chanceItems []protocol.ChancePoolItemOrm
total int
provider *protocol.BaseUserInfo
flag int
)
if total, err = agg.GetChancePool(header.UserId, header.CompanyId, request.ChanceTypeId, request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &myChances); err != nil {
if total, err = agg.GetChancePool(header.UserId, header.CompanyId, request.ChanceTypeId, request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &chanceItems); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ... @@ -1548,14 +1548,16 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
return
}
rsp = &protocol.ChancePoolResponse{Total: total, List: make([]protocol.CommonListItem, 0)}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
for i := 0; i < len(chanceItems); i++ {
chance := chanceItems[i]
if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {
log.Error(err)
return
}
commItem := protocol.CommonListItem{}
{
commItem.ReviewStatus = chance.ReviewStatus //审核状态
//机会数据
item := protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
... ... @@ -1567,9 +1569,8 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
commItem.ReviewStatus = chance.ReviewStatus
{
//点赞评论数据
var chanceData = protocol.ChanceData{
ThumbsUpTotal: chance.ZanTotal,
CommentTotal: chance.CommentTotal,
... ... @@ -1582,23 +1583,10 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
chanceData.IsThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan
chanceData.IsCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect
commItem.ChanceData = chanceData
}
{
//做一次查询 查回所有的模板数据
if template, e := models.GetAuditTemplateById(int64(chance.TemplateId)); e == nil {
commItem.ChanceTemplate = protocol.NameItem{
Id: int(template.Id),
Name: template.Name,
}
}
if chanceType, e := models.GetChanceTypeById(chance.ChanceTypeId); e == nil {
commItem.ChanceType = protocol.NameItem{
Id: int(chanceType.Id),
Name: chanceType.Name,
}
}
}
//模板数据
commItem.ChanceTemplate = getTemplate(chance.TemplateId)
commItem.ChanceType = getChanceType(chance.ChanceTypeId)
rsp.List = append(rsp.List, commItem)
}
return
... ... @@ -1642,6 +1630,9 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
commItem := protocol.CommonListItem{}
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
commItem.ReviewStatus = ormItem.ReviewStatus
if commItem.Chance.ApproveTime <= 0 {
commItem.Chance.ApproveTime = ormItem.UpdateTime.Unix() * 1000
}
//审核流数据
approve := protocol.Approve{
... ... @@ -1656,7 +1647,6 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
}
}
commItem.Approve = approve
//审核中 有审核消息
if request.ReviewStatus == protocol.ReviewStatusAuditging {
commItem.Message = ormItem.ApproveMessage
... ...