作者 yangfu

我的机会 - 我的评论

... ... @@ -38,7 +38,7 @@ user_center_app_secret ="cykbjnfqgctn"
#Html5
h5_host = "https://web-open-test.fjmaimaimai.com"
h5_host = "http://mmm-web-open-test.fjmaimaimai.com"
#审核中心
suplus_approve_host ="http://suplus-approve-dev.fjmaimaimai.com"
... ...
... ... @@ -510,6 +510,27 @@ func (this *ChanceController) MyThumbUpChance() {
msg = protocol.NewReturnResponse(chance.MyThumbUpChance(header, request))
}
//MyComment 我的评论
//@router /myComment [post]
func (this *ChanceController) MyComment() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.MyCommentRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.MyComment(header, request))
}
//ChancePool 机会池
//@router /chancePool [post]
func (this *ChanceController) ChancePool() {
... ...
... ... @@ -159,7 +159,7 @@ func (this *MessageController) MsgCompanyNotice() {
msg = protocol.NewReturnResponse(message.MsgCompanyNotice(header, request))
}
//MsgChanceApprove 机会审核消息
//MsgChanceApprove 消息中心-机会审核消息
//@router /msgChanceApprove [post]
func (this *MessageController) MsgChanceApprove() {
var msg *protocol.ResponseMessage
... ... @@ -179,3 +179,24 @@ func (this *MessageController) MsgChanceApprove() {
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(message.MsgChanceApprove(header, request))
}
//MsgChanceSubmit 消息中心-我提交的
//@router /msgChanceSubmit [post]
func (this *MessageController) MsgChanceSubmit() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.MsgChanceSubmitRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(message.MsgChanceSubmit(header, request))
}
... ...
... ... @@ -219,3 +219,30 @@ limit ?`)
}
return
}
//我的评论
func GetChanceComment(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := fmt.Sprintf(`select a.*,b.content commented_content,b.create_at commented_time,b.user_id commented_user_id
from (
select a.*,b.images,b.speechs,b.videos from (
select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from (
select id,content,view_total,zan_total,comment_total,source_type,source_id,create_at comment_time from comment
where user_id =? and (?=0 or id>?)
)a left outer join chance b on a.source_id = b.id and source_type=1
)a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1
)a left outer join comment b on a.source_id = b.id and a.source_type=2
order by create_at desc
limit ?`)
sqlCount := `select count(0) from comment
where user_id =?`
if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, pageSize); err != nil {
return
}
}
return
}
... ...
... ... @@ -155,7 +155,7 @@ func GetUserMsgs(userId, companyId int64, msgType int, sourceType int, lastId in
//获取公告消息列表
func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := `select b.id,b.title,unix_timestamp(b.update_at) update_at,a.is_read `
sql := `select b.id,b.title,unix_timestamp(b.update_at)*1000 update_at,a.is_read `
sqlCount := `select count(0) `
where := `from user_msg a,bulletin b where a.receive_user_id =? and a.company_id=? and a.source_id = b.id and a.msg_type=? and a.company_id=? and b.status=2 `
sqlCount += where
... ...
... ... @@ -218,6 +218,16 @@ type MyThumbUpChanceResponse struct {
Total int `json:"total"`
}
/*MyComment 我的评论*/
type MyCommentRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
}
type MyCommentResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
//机会池列表
type ChancePoolItemOrm struct {
ChanceId int64 `orm:"column(id)"`
... ... @@ -286,6 +296,40 @@ type ChanceThumbUpItemOrm struct {
CollectTime time.Time `orm:"column(collect_time)"` //收藏时间
}
//我的评论
type ChanceCommentItemOrm struct {
//ChanceId int64 `orm:"column(id)"`
Uid int64 `orm:"column(chance_user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
//ApproveData string `json:"approveData"` //审核数据
//TemplateId int `orm:"column(audit_template_id)"`
//ChanceTypeId int `orm:"column(chance_type_id)"`
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
CommentId int64 `orm:"column(id)"`
CommentContent string `orm:"column(content)"`
CommentTime time.Time `orm:"column(comment_time)"`
//被评论的对象
CommentedUserId int64 `orm:"column(commented_user_id)"`
CommentedContent string `orm:"column(commented_content)"`
CommentedTime time.Time `orm:"column(commented_time)"` //收藏时间
//评论对象类型
SourceType int `orm:"column(source_type)"`
SourceId int64 `orm:"column(source_id)"`
}
/*ChanceDetail 机会详情*/
type ChanceDetailRequest struct {
Id int64 `json:"id"` //机会编号
... ... @@ -430,6 +474,10 @@ type CommonListItem struct {
ChanceType interface{} `json:"chanceType,omitempty"` //机会类型
ChanceTemplate interface{} `json:"template,omitempty"` //机会模板
//我评论的 评论数据
CommentedData interface{} `json:"commentedData,omitempty"`
SourceType int `json:"sourceType,omitempty"` //类型 1:机会 2:评论
ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
ReviewStatus int `json:"reviewStatus"` //审核状态
}
... ... @@ -462,3 +510,10 @@ type ThumbUpData struct {
Id int64 `json:"id"`
ThumbUpTime int64 `json:"thumbUpTime"` //收藏时间
}
//评论内容
type CommentData struct {
Id int64 `json:"id"` //评论编号
Content string `json:"content"` //评论内容
CommentTime int64 `json:"commentTime"` //评论时间
}
... ...
... ... @@ -55,7 +55,7 @@ const (
MsgTypeCommend = 2 //表彰
MsgTypeInteraction = 4 //互动消息
MsgTypeAudit = 8 //机会审核
MsgTypeAuditBy = 16 //机会被审核消息
MsgTypeAuditBy = 16 //机会被审核消息-我提交的
MsgTypeComment = 32 //评论
MsgTypeThumbUp = 64 //点赞
)
... ... @@ -116,6 +116,7 @@ type UserMsg struct {
CreateAt int64 `json:"msgTime"`
IsRead int `json:"isRead"`
//机会 //评论
Link string `json:"link,omitempty"`
}
type Message struct {
... ... @@ -212,6 +213,16 @@ type MsgChanceApproveResponse struct {
Total int `json:"total"`
}
/*MsgChanceSubmit 我提交的*/
type MsgChanceSubmitRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
}
type MsgChanceSubmitResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
//我的审核机会列表
type MsgChanceApproveItemOrm struct {
ChanceUserId int64 `orm:"column(chance_user_id)"`
... ...
... ... @@ -185,6 +185,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "MyComment",
Router: `/myComment`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "MySubmitChance",
Router: `/mySubmitChance`,
AllowHTTPMethods: []string{"post"},
... ... @@ -313,6 +321,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgChanceSubmit",
Router: `/msgChanceSubmit`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgCompanyNotice",
Router: `/msgCompanyNotice`,
AllowHTTPMethods: []string{"post"},
... ...
... ... @@ -344,8 +344,8 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
for i := range approveItemResponse.MessageData.ApplyUserMessage {
message := approveItemResponse.MessageData.ApplyUserMessage[i]
nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus); err != nil {
if err = agg.SendApprovedMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
log.Error(err)
return
}
... ...
... ... @@ -1120,6 +1120,84 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp
return
}
//我的评论
func MyComment(header *protocol.RequestHeader, request *protocol.MyCommentRequest) (rsp *protocol.MyCommentResponse, err error) {
var (
myChances []protocol.ChanceCommentItemOrm
total int
provider *protocol.BaseUserInfo
)
if total, err = models.GetChanceComment(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
rsp = &protocol.MyCommentResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
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
} 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.SourceId,
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.SourceType)
// commItem.ChanceData = chanceData
//}
//{
// //做一次查询 查回所有的模板数据
// commItem.ChanceTemplate = getTemplate(chance.TemplateId)
// commItem.ChanceType = getChanceType(chance.ChanceTypeId)
//}
}
if chance.SourceType == protocol.SourceTypeComment {
commItem.CommentedData = protocol.CommentData{
Id: chance.SourceId,
Content: chance.CommentedContent,
CommentTime: chance.CommentedTime.Unix() * 1000,
}
}
commItem.CommentData = protocol.CommentData{
Id: chance.CommentId,
CommentTime: chance.CommentTime.Unix() * 1000,
Content: chance.CommentContent,
}
commItem.SourceType = chance.SourceType
rsp.List = append(rsp.List, commItem)
}
return
}
//获取机会点赞/收藏状态
func getChanceMarkFlag(header *protocol.RequestHeader, chanceId int64) (isThumbsUp, isCollect bool, err error) {
var flag int
... ...
... ... @@ -189,6 +189,7 @@ func MsgCompanyNotice(header *protocol.RequestHeader, request *protocol.MsgCompa
Content: tmp.Title,
CreateAt: tmp.UpdateTime,
IsRead: int(tmp.IsRead),
Link: fmt.Sprintf("%v/#/ability/announcement?id=%v&uid=%v&oppo=", beego.AppConfig.String("h5_host"), tmp.Id, header.UserId),
})
}
return
... ... @@ -252,6 +253,64 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc
return
}
// 消息中心-我提交的
func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChanceSubmitRequest) (rsp *protocol.MsgChanceSubmitResponse, err error) {
var (
myChances []protocol.MsgChanceApproveItemOrm
total int
provider *protocol.BaseUserInfo
)
if total, err = models.GetChanceMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeAuditBy, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
rsp = &protocol.MsgChanceSubmitResponse{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(chance.ChanceUserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
continue
} else {
item := protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
}
utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = agg.ClearEmptyForm(item.FormList)
utils.JsonUnmarshal(chance.Images, &item.Pictures)
utils.JsonUnmarshal(chance.Voices, &item.Speechs)
utils.JsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
}
if chance.ReviewStatus == protocol.ReviewStatusPass {
var approveData *protocol.ApproveData
utils.JsonUnmarshal(chance.ApproveData, &approveData)
if approveData != nil {
commItem.Score = approveData.Score
}
}
//审核完有审核数据
commItem.Message = chance.Message
rsp.List = append(rsp.List, commItem)
}
return
}
//H5公告详情
func H5Announcement(header *protocol.RequestHeader, request *protocol.AnnouncementRequest) (rsp *protocol.AnnouncementResponse, err error) {
var (
... ...
... ... @@ -383,6 +383,11 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis
log.Error(err)
}
break
case protocol.CommentStatic: //评论
if total, err = models.GetChanceComment(header.UserId, 0, 0, nil); err != nil {
log.Error(err)
}
break
case protocol.MyCommitChance:
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil {
log.Error(err)
... ...