user_account.go 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. package forms
  2. import (
  3. "errors"
  4. "github.com/spf13/cast"
  5. "strings"
  6. )
  7. type UserAccountGetReq struct {
  8. ID int64 `form:"playerid" json:"playerid" binding:"required"`
  9. }
  10. type UserAccountListReq struct {
  11. ListReq
  12. ChannelId string `json:"channel_id" form:"channel_id"`
  13. ID int64 `json:"id" form:"id"`
  14. Nickname string `json:"nickname" form:"nickname"`
  15. OpenId string `json:"openId" form:"openId"`
  16. Ban int32 `json:"ban" form:"ban"`
  17. Createtime []int64 `json:"createtime" form:"createtime[]"`
  18. Diamond []string `json:"diamond" form:"diamond[]"`
  19. DiamondBetween []float64
  20. Coin []string `json:"coin" form:"coin[]"`
  21. CoinBetween []float64
  22. Level []string `json:"level" form:"level[]"`
  23. LevelBetween []int32
  24. Stamina []string `json:"stamina" form:"stamina[]"`
  25. StaminaBetween []int32
  26. Sorter []SorterModel `json:"sorter" form:"sorter[]"`
  27. ServerId int `json:"server_id" form:"server_id"`
  28. }
  29. type UserAccountBanReq struct {
  30. ID int64 `json:"playerid" form:"playerid"`
  31. Ban int32 `json:"ban" form:"ban"`
  32. Reason string `json:"reason" form:"reason"`
  33. }
  34. type GmSetPaySwitch struct {
  35. PlayerID int64 `json:"playerid"`
  36. Switch int `json:"switch"` //0:关 1:开
  37. Reason string `json:"reason"`
  38. }
  39. type BanChatReq struct {
  40. PlayerID int64 `json:"playerid" form:"playerid"`
  41. Ban int32 `json:"ban" form:"ban"`
  42. DeadlineTime int64 `json:"deadline_time" form:"deadline_time"`
  43. Reason string `json:"reason" form:"reason"`
  44. }
  45. func (req *UserAccountListReq) Check() error {
  46. if req.Diamond != nil && len(req.Diamond) != 2 {
  47. return errors.New("钻石必须选择一个区间或者留空")
  48. }
  49. if req.Coin != nil && len(req.Coin) != 2 {
  50. return errors.New("金币必须选择一个区间或者留空")
  51. }
  52. if req.Level != nil && len(req.Level) != 2 {
  53. return errors.New("等级必须选择一个区间或者留空")
  54. }
  55. if req.Createtime != nil && len(req.Createtime) != 2 {
  56. return errors.New("注册时间必须选择一个区间或者留空")
  57. }
  58. if len(req.Coin) == 2 {
  59. for i := 0; i < len(req.Coin); i++ {
  60. var (
  61. suffix string
  62. coin float64
  63. )
  64. req.Coin[i] = strings.TrimSpace(req.Coin[i])
  65. suffix = req.Coin[i][len(req.Coin[i])-1:]
  66. if suffix == "K" || suffix == "k" {
  67. coin = cast.ToFloat64(req.Coin[i][:len(req.Coin[i])-1])
  68. coin = coin * 1000
  69. } else if suffix == "M" || suffix == "m" {
  70. coin = cast.ToFloat64(req.Coin[i][:len(req.Coin[i])-1])
  71. coin = coin * 1000 * 1000
  72. } else {
  73. coin = cast.ToFloat64(req.Coin[i])
  74. }
  75. req.CoinBetween = append(req.CoinBetween, coin)
  76. }
  77. }
  78. if len(req.Diamond) == 2 {
  79. for i := 0; i < len(req.Diamond); i++ {
  80. var (
  81. suffix string
  82. diamond float64
  83. )
  84. req.Diamond[i] = strings.TrimSpace(req.Diamond[i])
  85. suffix = req.Diamond[i][len(req.Diamond[i])-1:]
  86. if suffix == "K" || suffix == "k" {
  87. diamond = cast.ToFloat64(req.Diamond[i][:len(req.Diamond[i])-1])
  88. diamond = diamond * 1000
  89. } else if suffix == "M" || suffix == "m" {
  90. diamond = cast.ToFloat64(req.Diamond[i][:len(req.Diamond[i])-1])
  91. diamond = diamond * 1000 * 1000
  92. } else {
  93. diamond = cast.ToFloat64(req.Diamond[i])
  94. }
  95. req.DiamondBetween = append(req.DiamondBetween, diamond)
  96. }
  97. }
  98. if len(req.Createtime) == 2 {
  99. if req.Createtime[0] > req.Createtime[1] {
  100. return errors.New("注册时间选择的区间值不合理")
  101. }
  102. req.Createtime[0] = req.Createtime[0] / 1000
  103. req.Createtime[1] = req.Createtime[1] / 1000
  104. }
  105. if len(req.Level) == 2 {
  106. if req.Level[0] > req.Level[1] {
  107. return errors.New("等级选择的区间值不合理")
  108. }
  109. req.LevelBetween = []int32{cast.ToInt32(req.Level[0]), cast.ToInt32(req.Level[1])}
  110. }
  111. if len(req.Stamina) == 2 {
  112. if req.Stamina[0] > req.Stamina[1] {
  113. return errors.New("体力选择的区间值不合理")
  114. }
  115. req.StaminaBetween = []int32{cast.ToInt32(req.Stamina[0]), cast.ToInt32(req.Stamina[1])}
  116. }
  117. return nil
  118. }
  119. type UserAccountListRes struct {
  120. ListRes
  121. }
  122. type UserAccountSearchReq struct {
  123. ListReq
  124. ID int64 `json:"id" form:"id"`
  125. OpenId string `json:"openId" form:"openId"`
  126. AccId int64 `json:"accId" form:"accId"`
  127. }
  128. func (req *UserAccountSearchReq) Check() error {
  129. if req.AccId > 0 {
  130. req.ID = 0
  131. req.OpenId = ""
  132. }
  133. if req.OpenId != "" {
  134. req.ID = 0
  135. }
  136. req.OpenId = strings.ReplaceAll(req.OpenId, "@wx", "")
  137. return nil
  138. }
  139. type UserAccountSearchRes struct {
  140. ListRes
  141. }
  142. type ChatReportListReq struct {
  143. ListReq
  144. ServerID int32 `json:"server_id" form:"server_id"`
  145. ClanServerID int32 `json:"clan_server_id" form:"clan_server_id"`
  146. ClanChatChannel int32 `json:"clan_chat_channel" form:"clan_chat_channel"`
  147. PlayerID int64 `json:"player_id" form:"player_id"`
  148. ClanPlayerID int64 `json:"clan_player_id" form:"clan_player_id"`
  149. CreateTime []int64 `json:"create_time" form:"create_time[]"`
  150. ClanTime []int64 `json:"clan_time" form:"clan_time[]"`
  151. Sorter []SorterModel `json:"sorter" form:"sorter[]"`
  152. IsExport int `json:"is_export" form:"is_export"`
  153. }
  154. type ChatLogListReq struct {
  155. ServerID int32 `json:"server_id" form:"server_id"`
  156. ChatChannel int32 `json:"chat_channel" form:"chat_channel"`
  157. BeforeID int64 `json:"before_id" form:"before_id"`
  158. CurrentID int64 `json:"current_id" form:"current_id"`
  159. LaterID int64 `json:"later_id" form:"later_id"`
  160. }
  161. type DownloadChatLogReq struct {
  162. Path string `json:"path" form:"path"`
  163. }
  164. type ChatMsgListReq struct {
  165. ListReq
  166. ServerID int32 `json:"server_id" form:"server_id"`
  167. ChatChannel []int32 `json:"chat_channel" form:"chat_channel[]"`
  168. PlayerID int64 `json:"player_id" form:"player_id"`
  169. CreateTime []int64 `json:"create_time" form:"create_time[]"`
  170. IsExport int `json:"is_export" form:"is_export"`
  171. }
  172. type ChatMsgListRet struct {
  173. ID int64 `json:"id"`
  174. PlayerID int64 `json:"player_id"` // 玩家id
  175. NickName string `json:"nick_name"` // 玩家昵称
  176. HeadID int32 `json:"head_id"` // 头像 -1 代表使用 AvatarURL 微信授权头像
  177. FrameID int32 `json:"frame_id"` // 头像框id
  178. HeadImg string `json:"head_img"` // 头像
  179. CreateTime int64 `json:"create_time"` // 产生时间(毫秒)
  180. ChatChannel int32 `json:"chat_channel"` // 频道类型
  181. ChannelName string `json:"channel_name"` // 频道名称
  182. ChatID string `json:"chat_id"` // 聊天Id
  183. Content string `json:"content"` // 聊天内容 [emoji:表情Id]
  184. SeverID int32 `json:"sever_id"` // 服务器Id
  185. ServerName string `json:"server_name"` // 服务器名称
  186. }
  187. type ChatLogContent struct {
  188. Key string `json:"key"`
  189. Size int64 `json:"size"`
  190. }
  191. type UpdateNicknameReq struct {
  192. UserId int64 `json:"userId" form:"userId"`
  193. Nickname string `json:"nickname" form:"nickname"`
  194. }
  195. func (req *UpdateNicknameReq) Check() error {
  196. if req.UserId <= 0 {
  197. return errors.New("玩家ID不能为空")
  198. }
  199. if req.Nickname == "" {
  200. return errors.New("玩家昵称不能为空")
  201. }
  202. return nil
  203. }
  204. type CompatibilityTestVerifyReq struct {
  205. ProduceUserId int64 `json:"produceUserId" form:"produceUserId"`
  206. Service int64 `json:"service" form:"service"`
  207. }
  208. func (req *CompatibilityTestVerifyReq) Check() error {
  209. if req.Service <= 0 {
  210. return errors.New("请先选择服务器")
  211. }
  212. if req.ProduceUserId <= 0 {
  213. return errors.New("正式服玩家ID不能为空")
  214. }
  215. return nil
  216. }
  217. type CompatibilityTestMigrateReq struct {
  218. ProduceUserId int64 `json:"produceUserId" form:"produceUserId"`
  219. UserId int64 `json:"userId" form:"userId"`
  220. Service int64 `json:"service" form:"service"`
  221. }
  222. func (req *CompatibilityTestMigrateReq) Check() error {
  223. if req.Service <= 0 {
  224. return errors.New("请先选择服务器")
  225. }
  226. if req.ProduceUserId <= 0 {
  227. return errors.New("正式服玩家ID不能为空")
  228. }
  229. if req.UserId <= 0 {
  230. return errors.New("玩家ID不能为空")
  231. }
  232. return nil
  233. }