...
|
...
|
@@ -1494,11 +1494,12 @@ func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceSt |
|
|
//我提交的机会
|
|
|
func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitChanceRequest) (rsp *protocol.MySubmitChanceResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.ChanceItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
ormItems []protocol.CommChanceItemOrm
|
|
|
chance *models.Chance
|
|
|
)
|
|
|
rsp = &protocol.MySubmitChanceResponse{
|
|
|
List: make([]protocol.CommonListItem, 0),
|
|
|
}
|
|
|
if request.LastId > 0 {
|
|
|
if chance, err = models.GetChanceById(request.LastId); err != nil {
|
|
|
log.Error("机会不存在", request.LastId, err)
|
...
|
...
|
@@ -1506,7 +1507,7 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh |
|
|
}
|
|
|
request.LastId = chance.UpdateAt.Unix()
|
|
|
}
|
|
|
if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
|
|
|
if rsp.Total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -1514,41 +1515,15 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh |
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.MySubmitChanceResponse{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{}
|
|
|
{
|
|
|
item := protocol.ChanceItem{
|
|
|
Id: chance.Id,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
UpdateTime: chance.UpdateTime.Unix() * 1000,
|
|
|
ApproveTime: chance.ApproveTime.Unix() * 1000,
|
|
|
}
|
|
|
if item.ApproveTime < 0 {
|
|
|
item.ApproveTime = 0
|
|
|
}
|
|
|
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
|
|
|
}
|
|
|
if chance.Status == models.ChanceStatusClose {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
}
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem)
|
|
|
commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
if request.ReviewStatus == protocol.ReviewStatusPass {
|
|
|
var approveData protocol.ApproveData
|
|
|
jsonUnmarshal(chance.ApproveData, &approveData)
|
|
|
//commItem.ApproveData = approveData //TODO:删除不需要
|
|
|
jsonUnmarshal(ormItem.ChanceApproveData, &approveData)
|
|
|
commItem.Score = approveData.Score
|
|
|
}
|
|
|
rsp.List = append(rsp.List, commItem)
|
...
|
...
|
@@ -1559,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
|
...
|
...
|
@@ -1573,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,
|
...
|
...
|
@@ -1592,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,
|
...
|
...
|
@@ -1607,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
|
...
|
...
|
@@ -1632,11 +1595,10 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ |
|
|
//我审核的机会
|
|
|
func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.ChanceApproveItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
ormItems []protocol.ChanceApproveItemOrm
|
|
|
chance *models.Chance
|
|
|
)
|
|
|
rsp = &protocol.MyApproveChanceResponse{List: make([]protocol.CommonListItem, 0)}
|
|
|
if request.LastId > 0 {
|
|
|
if chance, err = models.GetChanceById(request.LastId); err != nil {
|
|
|
log.Error("审批不存在", request.LastId, err)
|
...
|
...
|
@@ -1645,7 +1607,7 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove |
|
|
request.LastId = chance.UpdateAt.Unix()
|
|
|
}
|
|
|
if request.ReviewStatus == protocol.ReviewStatusAuditging {
|
|
|
if total, err = models.GetChanceMyApproveChanceEnable(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
|
|
|
if rsp.Total, err = models.GetChanceMyApproveChanceEnable(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -1654,7 +1616,7 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove |
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
|
|
|
if rsp.Total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -1663,65 +1625,45 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove |
|
|
return
|
|
|
}
|
|
|
}
|
|
|
rsp = &protocol.MyApproveChanceResponse{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
|
|
|
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(chance.ChanceUserId, header.CompanyId, err)
|
|
|
err = nil
|
|
|
} else {
|
|
|
item := protocol.ChanceItem{
|
|
|
Id: chance.ChanceId,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
UpdateTime: chance.UpdateTime.Unix() * 1000,
|
|
|
ApproveTime: chance.ChanceApproveTime.Unix() * 1000,
|
|
|
}
|
|
|
if item.ApproveTime < 0 {
|
|
|
item.ApproveTime = chance.UpdateTime.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.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{
|
|
|
ProcessId: chance.Id,
|
|
|
CreateTime: chance.ProcessCreateTime.Unix() * 1000,
|
|
|
ProcessId: ormItem.Id,
|
|
|
CreateTime: ormItem.ProcessCreateTime.Unix() * 1000,
|
|
|
}
|
|
|
//审核过的才有审核时间
|
|
|
//审核过的机会 有审核时间
|
|
|
if request.ReviewStatus != protocol.ReviewStatusAuditging {
|
|
|
approve.ApproveTime = chance.ApproveTime.Unix() * 1000
|
|
|
approve.ApproveTime = ormItem.ApproveTime.Unix() * 1000
|
|
|
if approve.ApproveTime < 0 {
|
|
|
approve.ApproveTime = chance.ChanceApproveTime.Unix() * 1000
|
|
|
approve.ApproveTime = ormItem.ChanceApproveTime.Unix() * 1000
|
|
|
}
|
|
|
}
|
|
|
commItem.Approve = approve
|
|
|
//审核完有审核数据
|
|
|
//审核中 有审核消息
|
|
|
if request.ReviewStatus == protocol.ReviewStatusAuditging {
|
|
|
commItem.Message = chance.ApproveMessage
|
|
|
commItem.Message = ormItem.ApproveMessage
|
|
|
}
|
|
|
//审核通过有审核评分数据
|
|
|
if request.ReviewStatus == protocol.ReviewStatusPass {
|
|
|
var approveData *protocol.ApproveData
|
|
|
jsonUnmarshal(chance.ApproveData, &approveData)
|
|
|
jsonUnmarshal(ormItem.ApproveData, &approveData)
|
|
|
if approveData != nil {
|
|
|
commItem.Score = approveData.Score
|
|
|
}
|
|
|
}
|
|
|
commItem.SelfCheckResult = protocol.NewSelfChecks(chance.SelfChecks).Static()
|
|
|
|
|
|
selfChecks := protocol.NewSelfChecks(ormItem.SelfChecks)
|
|
|
selfChecks.SetSelfChecksLevel1ByRule()
|
|
|
commItem.SelfCheckResult = selfChecks.Static() //自查统计数据
|
|
|
|
|
|
rsp.List = append(rsp.List, commItem)
|
|
|
}
|
|
|
return
|
...
|
...
|
@@ -1730,9 +1672,8 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove |
|
|
// 我的收藏
|
|
|
func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollectChanceRequest) (rsp *protocol.MyCollectChanceResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.ChanceCollectItemOrm
|
|
|
ormItems []protocol.ChanceCollectItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
favorite *models.ChanceFavorite
|
|
|
)
|
|
|
if request.LastId > 0 {
|
...
|
...
|
@@ -1742,7 +1683,7 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
|
|
}
|
|
|
request.LastId = favorite.CollectTime.Unix()
|
|
|
}
|
|
|
if total, err = models.GetChanceCollect(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
|
|
|
if total, err = models.GetChanceCollect(header.UserId, request.LastId, request.PageSize, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -1751,67 +1692,38 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect |
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.MyCollectChanceResponse{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
|
|
|
}
|
|
|
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
|
|
|
|
|
|
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
|
|
|
{
|
|
|
//chanceData
|
|
|
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)
|
|
|
|
|
|
//收藏数据
|
|
|
collect := protocol.CollectData{
|
|
|
Id: chance.CollectId,
|
|
|
CollectTime: chance.CollectTime.Unix() * 1000,
|
|
|
Id: ormItem.CollectId,
|
|
|
CollectTime: ormItem.CollectTime.Unix() * 1000,
|
|
|
}
|
|
|
if collect.CollectTime <= 0 && chance.UpdateTime.Unix() > 0 {
|
|
|
collect.CollectTime = chance.UpdateTime.Unix() * 1000
|
|
|
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)
|
...
|
...
|
@@ -1821,9 +1733,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 {
|
...
|
...
|
@@ -1833,7 +1744,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
|
...
|
...
|
@@ -1842,63 +1753,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)
|
...
|
...
|
@@ -1908,11 +1794,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
|
...
|
...
|
@@ -1925,47 +1811,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)
|
...
|
...
|
@@ -2105,7 +1974,8 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail |
|
|
UpdateTime: chance.UpdateAt.Unix() * 1000,
|
|
|
}
|
|
|
jsonUnmarshal(chance.SourceContent, &item.FormList)
|
|
|
jsonUnmarshal(chance.SelfChecks, &item.SelfChecks)
|
|
|
//jsonUnmarshal(chance.SelfChecks, &item.SelfChecks)
|
|
|
item.SelfChecks = agg.GetChanceSelfChecks(chance)
|
|
|
item.FormList = clearEmptyForm(item.FormList)
|
|
|
|
|
|
if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
|
...
|
...
|
@@ -2351,9 +2221,29 @@ func ChanceReviseDetail(header *protocol.RequestHeader, request *protocol.Chance |
|
|
func CheckQuestions(header *protocol.RequestHeader, request *protocol.CheckQuestionsRequest) (rsp *protocol.CheckQuestionsResponse, err error) {
|
|
|
var ()
|
|
|
rsp = &protocol.CheckQuestionsResponse{}
|
|
|
switch request.Type {
|
|
|
case 0: //自查问题列表
|
|
|
rsp.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId)
|
|
|
if err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
case 1: //筛选结果问题列表
|
|
|
rsp.Questions, err = agg.GetCheckQuestionsByChanceCheckResult(header, request.ChanceId)
|
|
|
if err == orm.ErrNoRows || len(rsp.Questions) == 0 {
|
|
|
rsp.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId)
|
|
|
if err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
err = nil
|
|
|
}
|
|
|
for i := range rsp.Questions {
|
|
|
rsp.Questions[i].CheckOptions = protocol.CheckOptionsApprove
|
|
|
//if rsp.Questions[i].ParentId!=0{
|
|
|
// rsp.Questions[i].Title= rsp.Questions[i].CheckItem
|
|
|
//}
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|