作者 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
total int
provider *protocol.BaseUserInfo
flag int
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,57 +1548,45 @@ 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{}
{
item := protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = clearEmptyForm(item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
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,
PageViewTotal: chance.ViewTotal,
}
if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.ChanceId); err != nil {
log.Error(err)
continue
}
chanceData.IsThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan
chanceData.IsCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect
commItem.ChanceData = chanceData
commItem.ReviewStatus = chance.ReviewStatus //审核状态
//机会数据
item := protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = clearEmptyForm(item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
//点赞评论数据
var chanceData = protocol.ChanceData{
ThumbsUpTotal: chance.ZanTotal,
CommentTotal: chance.CommentTotal,
PageViewTotal: chance.ViewTotal,
}
{
//做一次查询 查回所有的模板数据
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,
}
}
if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.ChanceId); err != nil {
log.Error(err)
continue
}
chanceData.IsThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan
chanceData.IsCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect
commItem.ChanceData = chanceData
//模板数据
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
... ...