|
@@ -15,9 +15,43 @@ import ( |
|
@@ -15,9 +15,43 @@ import ( |
15
|
)
|
15
|
)
|
16
|
|
16
|
|
17
|
func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCenterRequest) (rsp *protocol.MessageCenterResponse, err error) {
|
17
|
func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCenterRequest) (rsp *protocol.MessageCenterResponse, err error) {
|
18
|
- var ()
|
18
|
+ var (
|
|
|
19
|
+ list []*protocol.MessageTotal
|
|
|
20
|
+ interactionCount int
|
|
|
21
|
+ )
|
19
|
rsp = &protocol.MessageCenterResponse{}
|
22
|
rsp = &protocol.MessageCenterResponse{}
|
|
|
23
|
+ if request.MsgType&protocol.MsgTypeInteraction > 0 {
|
|
|
24
|
+ if request.MsgType&protocol.MsgTypeThumbUp == 0 {
|
|
|
25
|
+ request.MsgType |= protocol.MsgTypeThumbUp
|
|
|
26
|
+ }
|
|
|
27
|
+ if request.MsgType&protocol.MsgTypeComment == 0 {
|
|
|
28
|
+ request.MsgType |= protocol.MsgTypeComment
|
|
|
29
|
+ }
|
|
|
30
|
+ if request.MsgType&protocol.MsgTypeAuditBy == 0 {
|
|
|
31
|
+ request.MsgType |= protocol.MsgTypeAuditBy
|
|
|
32
|
+ }
|
|
|
33
|
+ }
|
20
|
err = models.GetUserMsgTotals(header.UserId, header.CompanyId, request.MsgType, &rsp.Totals)
|
34
|
err = models.GetUserMsgTotals(header.UserId, header.CompanyId, request.MsgType, &rsp.Totals)
|
|
|
35
|
+ for i := range rsp.Totals {
|
|
|
36
|
+ item := rsp.Totals[i]
|
|
|
37
|
+ if item.MsgType == protocol.MsgTypeThumbUp {
|
|
|
38
|
+ interactionCount += item.MsgTotal
|
|
|
39
|
+ continue
|
|
|
40
|
+ }
|
|
|
41
|
+ if item.MsgType == protocol.MsgTypeComment {
|
|
|
42
|
+ interactionCount += item.MsgTotal
|
|
|
43
|
+ continue
|
|
|
44
|
+ }
|
|
|
45
|
+ if item.MsgType == protocol.MsgTypeAuditBy {
|
|
|
46
|
+ interactionCount += item.MsgTotal
|
|
|
47
|
+ continue
|
|
|
48
|
+ }
|
|
|
49
|
+ list = append(list, item)
|
|
|
50
|
+ }
|
|
|
51
|
+ if interactionCount > 0 {
|
|
|
52
|
+ list = append(list, &protocol.MessageTotal{MsgType: protocol.MsgTypeInteraction, MsgTotal: interactionCount})
|
|
|
53
|
+ }
|
|
|
54
|
+ rsp.Totals = list
|
21
|
return
|
55
|
return
|
22
|
}
|
56
|
}
|
23
|
|
57
|
|