1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package msg_m
import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/internal/enum/msg_e"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/sdk/emas"
"git.hilo.cn/hilo-common/utils"
)
type MsgUserRecord struct {
mysql.Entity
*domain.Model `gorm:"-"`
UserId mysql.ID
Type msg_e.MsgUserRecordType
Nick mysql.Str
NickUserId mysql.ID //用户的别名
DiamondIncome mysql.Str
DayNum mysql.Str //多少天
PropertyUrl mysql.Str //道具地址
BeanNum mysql.Str //多少豆子
GroupCode mysql.Str //群组code
}
type MsgSysRecord struct {
mysql.Entity
*domain.Model `gorm:"-"`
//Type msg_m.MsgSysRecordType
Type uint32
Status mysql.LogicDel
MsgSysId mysql.ID
}
//系统消息,用户最后已读的位置
type MsgSysUser struct {
mysql.Entity
*domain.Model `gorm:"-"`
Type msg_e.MsgSysUserType
UserId mysql.ID
MsgSysLastId mysql.ID
}
//删除
func (msgSysRecord *MsgSysRecord) Del() *MsgSysRecord {
msgSysRecord.Status = mysql.DEL
return msgSysRecord
}
type MsgReceive struct {
Type msg_e.MsgReceiveType `json:"type"`
//Timestamp mysql.Timestamp `json:"timestamp"`
}
func NewUserRecord(model *domain.Model, userId mysql.ID, t msg_e.MsgUserRecordType, nick mysql.Str, nickUserId mysql.ID, diamondIncome mysql.Str, dayNum mysql.Str, propertyUrl mysql.Str, beanNum mysql.Str, groupCode mysql.Str) *MsgUserRecord {
return &MsgUserRecord{
Model: model,
UserId: userId,
Type: t,
Nick: nick,
NickUserId: nickUserId,
DiamondIncome: diamondIncome,
DayNum: dayNum,
PropertyUrl: propertyUrl,
BeanNum: beanNum,
GroupCode: groupCode,
}
}
// 发给小助手的消息, 不需要抛出错误
func SendEmasMsgAssistant(model *domain.Model, externalId string, deviceType string) error {
str, _ := utils.ToString(MsgReceive{
Type: msg_e.UserMsgReceiveType,
})
err := emas.SendMsg(externalId, deviceType, str)
if err != nil {
model.Log.Errorf("emas.SendMsg err:%v", err)
}
return nil
}