作者 yangfu

点赞人

... ... @@ -105,9 +105,9 @@ func DeleteUserMsg(id int64) (err error) {
func GetUserMsgTotals(userId int64, companyId int64, msgType int, v interface{}) (err error) {
o := orm.NewOrm()
sql := `select COUNT(*) as total,msg_type from user_msg
where (msg_type & ?)>0 and receive_user_id = ? and is_public=1 and is_read=0 and company_id=?
where (msg_type & ?)>0 and receive_user_id = ? and is_read=0 and company_id=?
GROUP BY msg_type`
if _, err = o.Raw(sql, msgType, userId, companyId).QueryRows(v); err == nil {
if err = utils.ExecuteQueryAllWithOrmer(o, v, sql, msgType, userId, companyId); err == nil {
return
}
return
... ...
... ... @@ -15,9 +15,43 @@ import (
)
func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCenterRequest) (rsp *protocol.MessageCenterResponse, err error) {
var ()
var (
list []*protocol.MessageTotal
interactionCount int
)
rsp = &protocol.MessageCenterResponse{}
if request.MsgType&protocol.MsgTypeInteraction > 0 {
if request.MsgType&protocol.MsgTypeThumbUp == 0 {
request.MsgType |= protocol.MsgTypeThumbUp
}
if request.MsgType&protocol.MsgTypeComment == 0 {
request.MsgType |= protocol.MsgTypeComment
}
if request.MsgType&protocol.MsgTypeAuditBy == 0 {
request.MsgType |= protocol.MsgTypeAuditBy
}
}
err = models.GetUserMsgTotals(header.UserId, header.CompanyId, request.MsgType, &rsp.Totals)
for i := range rsp.Totals {
item := rsp.Totals[i]
if item.MsgType == protocol.MsgTypeThumbUp {
interactionCount += item.MsgTotal
continue
}
if item.MsgType == protocol.MsgTypeComment {
interactionCount += item.MsgTotal
continue
}
if item.MsgType == protocol.MsgTypeAuditBy {
interactionCount += item.MsgTotal
continue
}
list = append(list, item)
}
if interactionCount > 0 {
list = append(list, &protocol.MessageTotal{MsgType: protocol.MsgTypeInteraction, MsgTotal: interactionCount})
}
rsp.Totals = list
return
}
... ...