...
|
...
|
@@ -1704,36 +1704,10 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
|
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
|
|
commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
commItem.ChanceId = ormItem.ChanceId
|
|
|
//if len(ormItem.SourceContent) == 0 || ormItem.ChanceEnableStatus == 0 { //机会删除
|
|
|
// commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
//}
|
|
|
//if ormItem.Status == models.ChanceStatusClose { //机会关闭
|
|
|
// commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
//}
|
|
|
//
|
|
|
//if ormItem.ChanceUserId > 0 {
|
|
|
// if provider, err = agg.GetUserBaseInfo(ormItem.ChanceUserId, header.CompanyId); err != nil {
|
|
|
// commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
// log.Error(err)
|
|
|
// //return
|
|
|
// } else {
|
|
|
// item := protocol.ChanceItem{
|
|
|
// Id: ormItem.ChanceId,
|
|
|
// Provider: provider,
|
|
|
// CreateTime: ormItem.CreateTime.Unix() * 1000,
|
|
|
// PublicStatus: ormItem.PublishStatus,
|
|
|
// }
|
|
|
// jsonUnmarshal(ormItem.SourceContent, &item.FormList)
|
|
|
// item.FormList = clearEmptyForm(item.FormList)
|
|
|
// jsonUnmarshal(ormItem.Images, &item.Pictures)
|
|
|
// jsonUnmarshal(ormItem.Voices, &item.Speechs)
|
|
|
// jsonUnmarshal(ormItem.Videos, &item.Videos)
|
|
|
// commItem.Chance = item
|
|
|
// }
|
|
|
//}
|
|
|
//
|
|
|
//commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
{
|
|
|
commItem.Chance.UpdateTime = 0
|
|
|
commItem.Chance.ApproveTime = 0
|
|
|
|
|
|
//chanceData
|
|
|
var chanceData = protocol.ChanceData{
|
|
|
ThumbsUpTotal: ormItem.ZanTotal,
|
|
|
CommentTotal: ormItem.CommentTotal,
|
...
|
...
|
@@ -1741,13 +1715,12 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
|
|
}
|
|
|
chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, ormItem.ChanceId)
|
|
|
commItem.ChanceData = chanceData
|
|
|
}
|
|
|
{
|
|
|
|
|
|
//做一次查询 查回所有的模板数据
|
|
|
commItem.ChanceTemplate = getTemplate(ormItem.TemplateId)
|
|
|
commItem.ChanceType = getChanceType(ormItem.ChanceTypeId)
|
|
|
}
|
|
|
{
|
|
|
|
|
|
//收藏数据
|
|
|
collect := protocol.CollectData{
|
|
|
Id: ormItem.CollectId,
|
|
|
CollectTime: ormItem.CollectTime.Unix() * 1000,
|
...
|
...
|
@@ -1755,11 +1728,8 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
|
|
if collect.CollectTime <= 0 && ormItem.UpdateTime.Unix() > 0 {
|
|
|
collect.CollectTime = ormItem.UpdateTime.Unix() * 1000
|
|
|
}
|
|
|
//收藏数据
|
|
|
commItem.CollectData = collect
|
|
|
|
|
|
//commItem.ChanceId = chance.ChanceId
|
|
|
}
|
|
|
rsp.List = append(rsp.List, commItem)
|
|
|
}
|
|
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.List)
|
...
|
...
|
@@ -1769,9 +1739,8 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
|
|
//我点赞的机会
|
|
|
func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUpChanceRequest) (rsp *protocol.MyThumbUpChanceResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.ChanceThumbUpItemOrm
|
|
|
ormItems []protocol.ChanceThumbUpItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
favorite *models.ChanceFavorite
|
|
|
)
|
|
|
if request.LastId > 0 {
|
...
|
...
|
@@ -1781,7 +1750,7 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp |
|
|
}
|
|
|
request.LastId = favorite.ZanTime.Unix()
|
|
|
}
|
|
|
if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
|
|
|
if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -1790,63 +1759,38 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp |
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.MyThumbUpChanceResponse{Total: total}
|
|
|
for i := 0; i < len(myChances); i++ {
|
|
|
chance := myChances[i]
|
|
|
for i := 0; i < len(ormItems); i++ {
|
|
|
ormItem := ormItems[i]
|
|
|
commItem := &protocol.CommonListItem{}
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
commItem.ChanceId = chance.ChanceId
|
|
|
if len(chance.SourceContent) == 0 || chance.ChanceEnableStatus == 0 { //机会删除
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
}
|
|
|
if chance.Status == models.ChanceStatusClose { //机会关闭
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
}
|
|
|
if chance.ChanceUserId > 0 {
|
|
|
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
log.Error(err)
|
|
|
//return
|
|
|
} else {
|
|
|
item := protocol.ChanceItem{
|
|
|
Id: chance.ChanceId,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
PublicStatus: chance.PublishStatus,
|
|
|
}
|
|
|
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
|
|
|
{
|
|
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
|
|
commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
commItem.ChanceId = ormItem.ChanceId
|
|
|
commItem.Chance.UpdateTime = 0
|
|
|
commItem.Chance.ApproveTime = 0
|
|
|
|
|
|
//点赞收藏数据
|
|
|
var chanceData = protocol.ChanceData{
|
|
|
ThumbsUpTotal: chance.ZanTotal,
|
|
|
CommentTotal: chance.CommentTotal,
|
|
|
PageViewTotal: chance.ViewTotal,
|
|
|
ThumbsUpTotal: ormItem.ZanTotal,
|
|
|
CommentTotal: ormItem.CommentTotal,
|
|
|
PageViewTotal: ormItem.ViewTotal,
|
|
|
}
|
|
|
chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, chance.ChanceId)
|
|
|
chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, ormItem.ChanceId)
|
|
|
commItem.ChanceData = chanceData
|
|
|
}
|
|
|
{
|
|
|
//做一次查询 查回所有的模板数据
|
|
|
commItem.ChanceTemplate = getTemplate(chance.TemplateId)
|
|
|
commItem.ChanceType = getChanceType(chance.ChanceTypeId)
|
|
|
}
|
|
|
{
|
|
|
|
|
|
//模板数据
|
|
|
commItem.ChanceTemplate = getTemplate(ormItem.TemplateId)
|
|
|
commItem.ChanceType = getChanceType(ormItem.ChanceTypeId)
|
|
|
|
|
|
//点赞数据
|
|
|
thumb := protocol.ThumbUpData{
|
|
|
Id: chance.CollectId,
|
|
|
ThumbUpTime: chance.ZanTime.Unix() * 1000,
|
|
|
Id: ormItem.CollectId,
|
|
|
ThumbUpTime: ormItem.ZanTime.Unix() * 1000,
|
|
|
}
|
|
|
if thumb.ThumbUpTime <= 0 && chance.UpdateTime.Unix() > 0 {
|
|
|
thumb.ThumbUpTime = chance.UpdateTime.Unix() * 1000
|
|
|
if thumb.ThumbUpTime <= 0 && ormItem.UpdateTime.Unix() > 0 {
|
|
|
thumb.ThumbUpTime = ormItem.UpdateTime.Unix() * 1000
|
|
|
}
|
|
|
//收藏数据
|
|
|
commItem.ThumbUpData = thumb
|
|
|
}
|
|
|
|
|
|
rsp.List = append(rsp.List, commItem)
|
|
|
}
|
|
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.List)
|
...
|
...
|
@@ -1856,11 +1800,11 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp |
|
|
//我的评论
|
|
|
func MyComment(header *protocol.RequestHeader, request *protocol.MyCommentRequest) (rsp *protocol.MyCommentResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.ChanceCommentItemOrm
|
|
|
ormItems []protocol.ChanceCommentItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
)
|
|
|
if total, err = models.GetChanceComment(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
|
|
|
if total, err = models.GetChanceComment(header.UserId, request.LastId, request.PageSize, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -1873,47 +1817,30 @@ func MyComment(header *protocol.RequestHeader, request *protocol.MyCommentReques |
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
for i := 0; i < len(myChances); i++ {
|
|
|
chance := myChances[i]
|
|
|
for i := 0; i < len(ormItems); i++ {
|
|
|
ormItem := ormItems[i]
|
|
|
commItem := &protocol.CommonListItem{}
|
|
|
commItem.ChanceId = chance.SourceId
|
|
|
if chance.SourceType == protocol.SourceTypeChance {
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
if len(chance.SourceContent) == 0 { //机会删除
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
} else if chance.ChanceEnableStatus == 0 { //机会关闭
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
}
|
|
|
if chance.Status == models.ChanceStatusClose { //机会关闭
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
}
|
|
|
item := protocol.ChanceItem{
|
|
|
Id: chance.SourceId,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
PublicStatus: chance.PublishStatus,
|
|
|
}
|
|
|
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
|
|
|
}
|
|
|
if chance.SourceType == protocol.SourceTypeComment {
|
|
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
|
|
commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
commItem.ChanceId = ormItem.SourceId
|
|
|
commItem.Chance.UpdateTime = 0
|
|
|
commItem.Chance.ApproveTime = 0
|
|
|
commItem.Chance.Provider = provider
|
|
|
//被评论的数据内容
|
|
|
if ormItem.SourceType == protocol.SourceTypeComment {
|
|
|
commItem.CommentedData = protocol.CommentData{
|
|
|
Id: chance.SourceId,
|
|
|
Content: chance.CommentedContent,
|
|
|
CommentTime: chance.CommentedTime.Unix() * 1000,
|
|
|
Id: ormItem.SourceId,
|
|
|
Content: ormItem.CommentedContent,
|
|
|
CommentTime: ormItem.CommentedTime.Unix() * 1000,
|
|
|
}
|
|
|
}
|
|
|
//评论内容
|
|
|
commItem.CommentData = protocol.CommentData{
|
|
|
Id: chance.CommentId,
|
|
|
CommentTime: chance.CommentTime.Unix() * 1000,
|
|
|
Content: chance.CommentContent,
|
|
|
Id: ormItem.CommentId,
|
|
|
CommentTime: ormItem.CommentTime.Unix() * 1000,
|
|
|
Content: ormItem.CommentContent,
|
|
|
}
|
|
|
commItem.SourceType = chance.SourceType
|
|
|
commItem.SourceType = ormItem.SourceType
|
|
|
rsp.List = append(rsp.List, commItem)
|
|
|
}
|
|
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.List)
|
...
|
...
|
|