wechat.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. package model
  2. import "time"
  3. // MaxWechatLen ...
  4. const MaxWechatLen = 254 //企业微信内容最大长度
  5. // AppConfig def
  6. type AppConfig struct {
  7. AppID int // 企业微信:SAGA应用的appId
  8. AppSecret string // 企业微信:SAGA应用的secret
  9. }
  10. // Notification def
  11. type Notification struct {
  12. ToUser string `json:"touser"`
  13. ToParty string `json:"toparty"`
  14. ToTag string `json:"totag"`
  15. MsgType string `json:"msgtype"`
  16. AgentID int `json:"agentid"`
  17. }
  18. // Text def
  19. type Text struct {
  20. Content string `json:"content"`
  21. }
  22. // TxtNotification 文本消息
  23. type TxtNotification struct {
  24. Notification
  25. Body Text `json:"text"`
  26. Safe int `json:"safe"`
  27. }
  28. // AllowUserInfo 应用可见名单列表
  29. type AllowUserInfo struct {
  30. Users []*UserInfo `json:"user"`
  31. }
  32. // UserInfo only contain userid now
  33. type UserInfo struct {
  34. UserID string `json:"userid"`
  35. }
  36. // QueryContactLogRequest Query Contact Log Request.
  37. type QueryContactLogRequest struct {
  38. Pagination
  39. UserID int64 `form:"user_id"`
  40. UserName string `form:"user_name"`
  41. OperateUser string `form:"operate_user"`
  42. OperateType string `form:"operate_type"`
  43. }
  44. // QueryContactRequest Query Contact Log Request.
  45. type QueryContactRequest struct {
  46. Pagination
  47. }
  48. // AboundContactLog Abound Contact Log.
  49. type AboundContactLog struct {
  50. ContactLog
  51. Name string `json:"machine_name"`
  52. }
  53. // ContactLog Contact Log.
  54. type ContactLog struct {
  55. ID int64 `json:"-" gorm:"column:id"`
  56. Username string `json:"username" gorm:"column:username"`
  57. MachineID int64 `json:"machine_id" gorm:"column:machine_id"`
  58. OperateType string `json:"operate_type" gorm:"column:operation_type"`
  59. OperateResult string `json:"operate_result" gorm:"column:operation_result"`
  60. OperateTime time.Time `json:"operate_time" gorm:"column:ctime;default:current_timestamp"`
  61. UTime time.Time `json:"-" gorm:"column:mtime;default:current_timestamp on update current_timestamp"`
  62. Type int `json:"type" gorm:"column:type"`
  63. }
  64. // Contact Contact info.
  65. type Contact struct {
  66. ID int64 `json:"-" gorm:"column:id"`
  67. Username string `json:"user_name" gorm:"column:user_name"`
  68. UserID string `json:"user_id" gorm:"column:user_id"`
  69. }
  70. // PaginateContactLog Paginate Contact Log.
  71. type PaginateContactLog struct {
  72. Total int64 `json:"total"`
  73. PageNum int `json:"page_num"`
  74. PageSize int `json:"page_size"`
  75. MachineLogs []*AboundContactLog `json:"machine_logs"`
  76. }
  77. // PaginateContact Paginate Contact.
  78. type PaginateContact struct {
  79. Total int64 `json:"total"`
  80. PageNum int `json:"page_num"`
  81. PageSize int `json:"page_size"`
  82. Contacts []*ContactInfo `json:"contacts"`
  83. }
  84. // CreateChatReq ...
  85. type CreateChatReq struct {
  86. Name string `json:"name" validate:"required"`
  87. Owner string `json:"owner" validate:"required"`
  88. UserList []string `json:"userlist" validate:"required"`
  89. ChatID string `json:"chatid" validate:"required"`
  90. }
  91. // WechatCreateLog ...
  92. type WechatCreateLog struct {
  93. ID int `json:"id" gorm:"column:id"`
  94. Name string `json:"name" gorm:"column:name"`
  95. Owner string `json:"owner" gorm:"column:owner"`
  96. ChatID string `json:"chatid" gorm:"column:chatid"`
  97. Cuser string `json:"cuser" gorm:"column:cuser"`
  98. Ctime time.Time `form:"ctime" json:"ctime" gorm:"column:ctime"`
  99. Status int `form:"status" json:"status" gorm:"column:status"` //1创建 2修改 3同步中 4同步完成 5同步失败
  100. }
  101. // WechatChatLog ...
  102. type WechatChatLog struct {
  103. ID int `json:"id" gorm:"column:id"`
  104. ChatID string `json:"chatid" gorm:"column:chatid"`
  105. MsgType string `json:"msgtype" gorm:"column:msgtype"`
  106. Content string `json:"content" gorm:"column:content"`
  107. Safe int `json:"safe" gorm:"column:safe"`
  108. Status int `form:"status" json:"status" gorm:"column:status"` //1成功 0失败
  109. }
  110. // WechatMessageLog ...
  111. type WechatMessageLog struct {
  112. ID int `json:"id" gorm:"column:id"`
  113. Touser string `json:"touser" gorm:"column:touser"`
  114. Content string `json:"content" gorm:"column:content"`
  115. Status int `form:"status" json:"status" gorm:"column:status"` //1成功 0失败
  116. }
  117. // ChatResp ...
  118. type ChatResp struct {
  119. ErrCode int `json:"errcode"`
  120. ErrMsg string `json:"errmsg"`
  121. }
  122. // CreateChatResp ...
  123. type CreateChatResp struct {
  124. *ChatResp
  125. ChatID string `json:"chatid"`
  126. }
  127. // CreateChatLog ...
  128. type CreateChatLog struct {
  129. *WechatCreateLog
  130. Buttons []string `json:"buttons"`
  131. }
  132. // CreateChatLogResp ...
  133. type CreateChatLogResp struct {
  134. Total int `json:"total"`
  135. *Pagination
  136. Logs []*CreateChatLog `json:"logs,omitempty"`
  137. }
  138. // GetChatResp ...
  139. type GetChatResp struct {
  140. *ChatResp
  141. ChatInfo *CreateChatReq `json:"chat_info"`
  142. }
  143. // SendChatReq ...
  144. type SendChatReq struct {
  145. ChatID string `json:"chatid"`
  146. MsgType string `json:"msgtype"`
  147. Text struct {
  148. Content string `json:"content"`
  149. } `json:"text"`
  150. Safe int `json:"safe"`
  151. }
  152. // SendMessageReq ...
  153. type SendMessageReq struct {
  154. Touser []string `json:"touser"`
  155. Content string `json:"content"`
  156. }
  157. // UpdateChatReq ...
  158. type UpdateChatReq struct {
  159. ChatID string `json:"chatid"`
  160. Name string `json:"name"`
  161. Owner string `json:"owner"`
  162. AddUserList []string `json:"add_user_list"`
  163. DelUserList []string `json:"del_user_list"`
  164. }