...
|
...
|
@@ -864,7 +864,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ |
|
|
commItem := protocol.CommonListItem{}
|
|
|
{
|
|
|
item := protocol.ChanceItem{
|
|
|
Id: chance.Id,
|
|
|
Id: chance.ChanceId,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
}
|
...
|
...
|
@@ -882,7 +882,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ |
|
|
CommentTotal: chance.CommentTotal,
|
|
|
PageViewTotal: chance.ViewTotal,
|
|
|
}
|
|
|
if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.Id); err != nil {
|
|
|
if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.ChanceId); err != nil {
|
|
|
log.Error(err)
|
|
|
continue
|
|
|
}
|
...
|
...
|
@@ -918,7 +918,6 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove |
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
)
|
|
|
rsp = &protocol.MyApproveChanceResponse{}
|
|
|
if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
...
|
...
|
@@ -981,6 +980,186 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove |
|
|
return
|
|
|
}
|
|
|
|
|
|
// 我的收藏
|
|
|
func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollectChanceRequest) (rsp *protocol.MyCollectChanceResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.ChanceCollectItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
)
|
|
|
if total, err = models.GetChanceCollect(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
|
|
}
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.MyCollectChanceResponse{Total: total}
|
|
|
for i := 0; i < len(myChances); i++ {
|
|
|
chance := myChances[i]
|
|
|
commItem := protocol.CommonListItem{}
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
if len(chance.SourceContent) == 0 { //机会删除
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
} else if chance.ChanceEnableStatus == 0 { //机会关闭
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
} else {
|
|
|
if provider, err = agg.GetUserBaseInfo(header.UserId, 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,
|
|
|
}
|
|
|
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,
|
|
|
}
|
|
|
chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, chance.ChanceId)
|
|
|
commItem.ChanceData = chanceData
|
|
|
}
|
|
|
{
|
|
|
//做一次查询 查回所有的模板数据
|
|
|
commItem.ChanceTemplate = getTemplate(chance.TemplateId)
|
|
|
commItem.ChanceType = getChanceType(chance.ChanceTypeId)
|
|
|
}
|
|
|
{
|
|
|
//收藏数据
|
|
|
commItem.CollectData = protocol.CollectData{
|
|
|
Id: chance.CollectId,
|
|
|
CollectTime: chance.CollectTime.Unix() * 1000,
|
|
|
}
|
|
|
}
|
|
|
rsp.List = append(rsp.List, commItem)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//我点赞的机会
|
|
|
func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUpChanceRequest) (rsp *protocol.MyThumbUpChanceResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.ChanceThumbUpItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
)
|
|
|
if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
|
|
}
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.MyThumbUpChanceResponse{Total: total}
|
|
|
for i := 0; i < len(myChances); i++ {
|
|
|
chance := myChances[i]
|
|
|
commItem := protocol.CommonListItem{}
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
if len(chance.SourceContent) == 0 { //机会删除
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
} else if chance.ChanceEnableStatus == 0 { //机会关闭
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
} else {
|
|
|
if provider, err = agg.GetUserBaseInfo(header.UserId, 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,
|
|
|
}
|
|
|
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,
|
|
|
}
|
|
|
chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, chance.ChanceId)
|
|
|
commItem.ChanceData = chanceData
|
|
|
}
|
|
|
{
|
|
|
//做一次查询 查回所有的模板数据
|
|
|
commItem.ChanceTemplate = getTemplate(chance.TemplateId)
|
|
|
commItem.ChanceType = getChanceType(chance.ChanceTypeId)
|
|
|
}
|
|
|
{
|
|
|
//收藏数据
|
|
|
commItem.ThumbUpData = protocol.ThumbUpData{
|
|
|
Id: chance.CollectId,
|
|
|
ThumbUpTime: chance.CollectTime.Unix() * 1000,
|
|
|
}
|
|
|
}
|
|
|
rsp.List = append(rsp.List, commItem)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//获取机会点赞/收藏状态
|
|
|
func getChanceMarkFlag(header *protocol.RequestHeader, chanceId int64) (isThumbsUp, isCollect bool, err error) {
|
|
|
var flag int
|
|
|
if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chanceId); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
isThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan
|
|
|
isCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//获取模板
|
|
|
func getTemplate(templateId int) protocol.NameItem {
|
|
|
if template, e := models.GetAuditTemplateById(int64(templateId)); e == nil {
|
|
|
item := protocol.NameItem{
|
|
|
Id: int(template.Id),
|
|
|
Name: template.Name,
|
|
|
}
|
|
|
return item
|
|
|
} else {
|
|
|
log.Error(templateId, e)
|
|
|
}
|
|
|
return protocol.NameItem{}
|
|
|
}
|
|
|
|
|
|
//获取机会一级分类
|
|
|
func getChanceType(chanceTypeId int) protocol.NameItem {
|
|
|
if template, e := models.GetChanceTypeById(chanceTypeId); e == nil {
|
|
|
item := protocol.NameItem{
|
|
|
Id: int(template.Id),
|
|
|
Name: template.Name,
|
|
|
}
|
|
|
return item
|
|
|
} else {
|
|
|
log.Error(chanceTypeId, e)
|
|
|
}
|
|
|
return protocol.NameItem{}
|
|
|
}
|
|
|
|
|
|
func jsonUnmarshal(jsonData string, v interface{}) {
|
|
|
if len(jsonData) == 0 {
|
|
|
return
|
...
|
...
|
|