params.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. // Package forms 原gm
  2. package forms
  3. import (
  4. "errors"
  5. "gadmin/internal/gorm/model"
  6. "math/rand"
  7. "time"
  8. )
  9. type Resp struct {
  10. Code int32 `json:"code"`
  11. Msg string `json:"msg"`
  12. Data interface{} `json:"data"`
  13. }
  14. type CommonReq struct {
  15. UserId int64 `form:"id"`
  16. }
  17. type UserQuery struct {
  18. Query string `form:"query"`
  19. }
  20. type UserInfo struct {
  21. UserId int64 `json:"user_id"`
  22. Exp int64 `json:"exp"`
  23. TalentPoint int64 `json:"talent_point"`
  24. Level int64 `json:"level"`
  25. Stamina int64 `json:"stamina"`
  26. Coin int64 `json:"coin"`
  27. Diamond int64 `json:"diamond"`
  28. }
  29. // UpdateRoleReq 更新经验、体力
  30. type UpdateRoleReq struct {
  31. UserId int64 `json:"user_id"`
  32. Exp int64 `json:"exp"`
  33. Stamina int64 `json:"stamina"`
  34. Energy int64 `json:"energy"`
  35. TalentPoint int64 `json:"talent_point"`
  36. }
  37. type UpgradeRoleReq struct {
  38. UserId int64 `json:"user_id"`
  39. RoleId int64 `json:"role_id"`
  40. NewRoleId int64 `json:"new_role_id"`
  41. }
  42. type GetRoleLevelReq struct {
  43. RoleName string `json:"role_name" `
  44. UserId int64 `json:"user_id"`
  45. RoleId int64 `json:"role_id"`
  46. NewRoleId int64 `json:"new_role_id"`
  47. }
  48. type AddCoinReq struct {
  49. UserId int64 `json:"user_id"`
  50. Coin int64 `json:"coin"`
  51. Diamond int64 `json:"diamond"`
  52. GoodId int `json:"good_id"` // 1 coin 2 diamond
  53. }
  54. type AddMaterialReq struct {
  55. UserId int64 `json:"user_id"`
  56. Id int64 `json:"id"` // 装备,或道具
  57. Count int64 `json:"count"`
  58. SuitName string `json:"name"`
  59. Equipments []int64 `json:"equipments"`
  60. }
  61. type DeleteUserAccountReq struct {
  62. AccId int64 `json:"accId"`
  63. }
  64. type DeleteUserPlayerReq struct {
  65. UserId int64 `json:"playerid"`
  66. }
  67. type OpenAccountReq struct {
  68. UserId int64 `json:"userId"`
  69. }
  70. type DropedRole struct {
  71. ID int `json:"id"`
  72. //HP int `json:"hp"`
  73. Wear bool `json:"wear"`
  74. }
  75. type UserItem struct {
  76. UID int64 `json:"userId"`
  77. Coin int `json:"coin"`
  78. Diamond int `json:"diamond"`
  79. Level int `json:"userLevel"`
  80. Exp int64 `json:"userExp"`
  81. TimeStamp int64 `json:"timeStamp"`
  82. Stamina int `json:"stamina"`
  83. LastLogoutTick int64 `json:"lastLogoutTick"`
  84. FirstWeapon bool `json:"firstGame"`
  85. Guide int `json:"guide"`
  86. Roles []DropedRole `json:"roles"`
  87. //Buff *model.DivinationBuff `json:"buff"`
  88. }
  89. var i int64 = 0
  90. func NewUserItem() *UserItem {
  91. i += 1
  92. return &UserItem{
  93. UID: i,
  94. Coin: 100,
  95. Diamond: rand.Int() % 100000000,
  96. Level: 8,
  97. Exp: 1000,
  98. TimeStamp: time.Now().Unix() - rand.Int63()%10000,
  99. Stamina: 30,
  100. LastLogoutTick: 0,
  101. FirstWeapon: false,
  102. Guide: 2,
  103. Roles: []DropedRole{{10001001, false}, {30001001, false}},
  104. }
  105. }
  106. // send notice
  107. type AddNoticeReq struct {
  108. Type string `json:"type"`
  109. Content string `json:"content"`
  110. StartAt int64 `json:"start_at"`
  111. EndAt int64 `json:"end_at"`
  112. Interval int64 `json:"interval"`
  113. MsgId string `json:"key"`
  114. }
  115. type NoticeListReq struct {
  116. }
  117. type DeleteNoticeReq struct {
  118. Id string `form:"id" json:"id"`
  119. }
  120. type NoticeItem struct {
  121. MsgId string `json:"key"`
  122. Type string `json:"type"`
  123. Content string `json:"content"`
  124. CreateAt int64 `json:"create_at"`
  125. UpdateAt int64 `json:"update_at"`
  126. StartAt int64 `json:"start_at"`
  127. EndAt int64 `json:"end_at"`
  128. Interval int64 `json:"interval"`
  129. }
  130. // session
  131. type LoginReq struct {
  132. UserName string `json:"username"`
  133. Password string `json:"password"`
  134. }
  135. type SetConfPathReq struct {
  136. Path string `json:"path"`
  137. }
  138. type UpdatePlayerElRankReq struct {
  139. PlayerId int `json:"playId"`
  140. RoomCount int `json:"roomCount"`
  141. MaxRoomCount int `json:"maxRoomCount"`
  142. ServerId int `json:"server_id"`
  143. }
  144. type UpdateSwitcherReq struct {
  145. ServerId int `json:"serverId"`
  146. IosPay int `json:"iosPay"`
  147. PlayerLevel int `json:"playerLevel"` // 支付开放等级
  148. // DoubleAd int `json:"doubleAd"` // 0关闭 5打开
  149. AndroidPay int `json:"andrPay"` //0:禁止支付 1:米大师支付 2:客服支付 3:混合支付
  150. AndroidOpenLevel int `json:"andrOpenLevel"` // 客服支付达到多少级开放
  151. DoubleAd int `json:"doubleAd"` // 双倍广告次数 默认呢5次
  152. AdOpenLevel int `json:"adOpenLevel"` // 广告开放等级 默认5级
  153. }
  154. type EmailListReq struct {
  155. Page int `json:"page" form:"page"`
  156. PerPage int `json:"pageSize" form:"pageSize"`
  157. }
  158. type EmailItemReq struct {
  159. Id int64 `json:"id"`
  160. Title string `json:"title"` // 标题
  161. Content string `json:"content"` // 内容
  162. Ext []struct {
  163. Id string `json:"id"`
  164. Count string `json:"count"`
  165. } `json:"ext"` // 奖励材料
  166. Sender string `json:"sender"`
  167. Recievers string `json:"recievers"`
  168. SendWay int `json:"sendWay"` // 1 立即发送 0 待发送
  169. SendAt string `json:"sendAt"` // 准备发送的时间
  170. Expired int `json:"expired"` // 过期天数
  171. Opt string `json:"opt"` // draft|send|delete
  172. OperatorId int64 `json:"operatorId"`
  173. RecieverType int64 `json:"recieverType"`
  174. }
  175. type EmailItem struct {
  176. Id int64 `json:"id"`
  177. Title string `json:"title"` // 标题
  178. Content string `json:"content"` // 内容
  179. Type int `json:"type"`
  180. Ext []struct {
  181. Id string `json:"id"`
  182. Count string `json:"count"`
  183. } `json:"ext"` // 奖励材料
  184. Sender string `json:"sender"`
  185. Recievers string `json:"recievers"`
  186. SendWay int `json:"sendWay"` // 1 立即发送 0 待发送
  187. SendAt int64 `json:"sendAt"` // 准备发送的时间
  188. SentAt int64 `json:"sentAt"` // 发送时间
  189. Expired int `json:"expired"` // 过期天数
  190. Opt string `json:"opt"` // draft|send|delete
  191. Status string `json:"status"` // 已发送|待发送
  192. Deleted bool `json:"deleted"`
  193. OperatorId int64 `json:"operatorId"`
  194. RecieverType int64 `json:"recieverType"`
  195. }
  196. type Interface interface {
  197. // Len is the number of elements in the collection.
  198. Len() int
  199. // Less reports whether the element with
  200. // index i should sort before the element with index j.
  201. Less(i, j int) bool
  202. // Swap swaps the elements with indexes i and j.
  203. Swap(i, j int)
  204. }
  205. type EmailList []*EmailItem
  206. func (s EmailList) Len() int { return len(s) }
  207. func (s EmailList) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
  208. func (s EmailList) Less(i, j int) bool {
  209. if s[i].Status == "待发送" {
  210. return true
  211. } else if s[j].Status == "待发送" {
  212. return false
  213. } else {
  214. return s[i].Id > s[j].Id
  215. }
  216. }
  217. func (item *EmailItem) ID() int64 {
  218. return item.Id
  219. }
  220. func (item *EmailItem) SetID(val int64) {
  221. item.Id = val
  222. }
  223. type EmailListResp struct {
  224. Code int `json:"code"`
  225. Data EmailList `json:"data"`
  226. Pagination Paginate `json:"pagination"`
  227. }
  228. type Paginate struct {
  229. Page int `json:"page"`
  230. PerPage int `json:"pageSize"`
  231. Total int `json:"total"`
  232. }
  233. type QueryPayOrderReq struct {
  234. PlayerID int `form:"playerId"`
  235. Type int `form:"type"` // 1 安卓,2 IOS
  236. Begin string `form:"begin"`
  237. End string `form:"end"`
  238. Page int `form:"page"`
  239. PerPage int `form:"pageSize"`
  240. }
  241. type PayOrder struct {
  242. ID int `json:"id"`
  243. PlayerID int `json:"playerID"`
  244. Amount int `json:"amount"`
  245. CreateTime string `json:"createAt"`
  246. Status int `json:"status"`
  247. Platform string `json:"platform"`
  248. }
  249. type PayOrderResp struct {
  250. Code int `json:"code"`
  251. Data []PayOrder `json:"data"`
  252. Pagination Paginate `json:"pagination"`
  253. }
  254. type GuidesItem struct {
  255. Name string `json:"name"`
  256. Val int `json:"index"`
  257. Pass bool `json:"pass"`
  258. }
  259. type ToolsRestartReq struct {
  260. Version string `json:"version"`
  261. }
  262. // ToolsRestartLogReq 重启记录
  263. type ToolsRestartLogReq struct {
  264. Page int `json:"page"`
  265. Limit int `json:"pageSize"`
  266. }
  267. type ToolsRestartLogRes struct {
  268. List []*model.ToolsRestartLog `json:"list"`
  269. Page int `json:"page"`
  270. Limit int `json:"limit"`
  271. TotalCount int64 `json:"total_count"`
  272. }
  273. // ToolsRestartViewReq 重启行数据
  274. type ToolsRestartViewReq struct {
  275. ID int64 `form:"id" json:"id"`
  276. }
  277. type LevelProgressReq struct {
  278. PlayerId int64 `form:"player_id" json:"player_id"`
  279. }
  280. type GetPVPRankingListReq struct {
  281. ServerId int `json:"server_id" form:"server_id"`
  282. }
  283. type GetCurioRankingListReq struct {
  284. ServerId int `json:"server_id" form:"server_id"`
  285. }
  286. type GetIdiomRankingListReq struct {
  287. ServerId int `json:"server_id" form:"server_id"`
  288. }
  289. type GetBossRankingListReq struct {
  290. ServerId int `json:"server_id" form:"server_id"`
  291. }
  292. type ClearPVPRankReq struct {
  293. UserID int64 `json:"user_id"`
  294. ServerId int `json:"server_id" form:"server_id"`
  295. }
  296. type ClearCurioRankReq struct {
  297. UserID int64 `json:"user_id"`
  298. ServerId int `json:"server_id" form:"server_id"`
  299. }
  300. type ClearIdiomRankReq struct {
  301. UserID int64 `json:"user_id"`
  302. ServerId int `json:"server_id" form:"server_id"`
  303. }
  304. type ClearBossRankReq struct {
  305. UserID int64 `json:"user_id"`
  306. ServerId int `json:"server_id" form:"server_id"`
  307. }
  308. type AlarmGameDataListReq struct {
  309. ListReq
  310. ServerID int `json:"server_id" form:"server_id"`
  311. UserID int64 `json:"player_id" form:"player_id"`
  312. CreatedAt []int64 `json:"created_at" form:"created_at[]"`
  313. }
  314. func (req *AlarmGameDataListReq) Check() error {
  315. if req.ServerID == 0 {
  316. return errors.New("服务器ID不能为空")
  317. }
  318. if len(req.CreatedAt) == 2 {
  319. req.CreatedAt[0] = req.CreatedAt[0] / 1000
  320. req.CreatedAt[1] = req.CreatedAt[1] / 1000
  321. }
  322. return nil
  323. }
  324. type AlarmGameDataInfo struct {
  325. ID int64 `json:"id"`
  326. PlayerID int64 `json:"playerId"`
  327. Attrs string `json:"attrs"`
  328. ServerID int32 `json:"serverId"`
  329. Msg string `json:"msg"`
  330. Time int64 `json:"time"`
  331. Module string `json:"module"`
  332. CreatedAt time.Time `json:"createdAt"`
  333. Ban int `json:"ban"`
  334. }
  335. type AlarmGameDataListResp struct {
  336. ListRes
  337. }
  338. type AlarmAttrReq struct {
  339. ListReq
  340. ChapterID int `json:"chapter_id" form:"chapter_id"`
  341. RoomID int `json:"room_id" form:"room_id"`
  342. Level int `json:"level" form:"level"`
  343. UserID int64 `json:"player_id" form:"player_id"`
  344. Time []int64 `json:"time" form:"time[]"`
  345. }
  346. func (req *AlarmAttrReq) Check() error {
  347. if req.UserID <= 0 {
  348. return errors.New("玩家ID不能为空")
  349. }
  350. if len(req.Time) == 2 {
  351. req.Time[0] = req.Time[0] / 1000
  352. req.Time[1] = req.Time[1] / 1000
  353. }
  354. return nil
  355. }
  356. type AlarmAttrResp struct {
  357. ListRes
  358. }
  359. type AlarmCheatingReq struct {
  360. ListReq
  361. PlayerId int64 `json:"player_id" form:"player_id"`
  362. ServerId int64 `json:"server_id" form:"server_id"`
  363. OriginTime []int64 `json:"origin_time" form:"origin_time"`
  364. YearMonth int64 `json:"year_month" form:"year_month"`
  365. Ratio float64 `json:"ratio" form:"ratio"`
  366. }
  367. func (req *AlarmCheatingReq) Check() error {
  368. if len(req.OriginTime) == 2 {
  369. //数据库中是纳秒 参数是毫秒
  370. req.OriginTime[0] = req.OriginTime[0] * 1000 * 1000
  371. req.OriginTime[1] = req.OriginTime[1] * 1000 * 1000
  372. }
  373. return nil
  374. }
  375. type AlarmCheatingInfo struct {
  376. ID int64 `json:"id"`
  377. OriginId int64 `json:"origin_id"`
  378. OriginTime string `json:"origin_time"`
  379. YearMonth string `json:"year_month"`
  380. PlayerId int64 `json:"player_id"`
  381. ServerId int `json:"server_id"`
  382. Dps float64 `json:"dps"`
  383. Rate float64 `json:"rate"`
  384. Valuation float64 `json:"valuation"`
  385. Damage float64 `json:"damage"`
  386. Ratio float64 `json:"ratio"`
  387. RoleInfo string `json:"role_info"`
  388. AlarmData string `json:"alarm_data"`
  389. Ban int `json:"ban"`
  390. }
  391. type AlarmCheatingResp struct {
  392. ListRes
  393. }
  394. type AddGiftReq struct {
  395. PlayerId int64 `json:"player_id"`
  396. GiftId int64 `json:"gift_id"` // 装备,或道具
  397. }
  398. type GmSendGift struct {
  399. MsgId string `json:"msgId"`
  400. PlayerID int64 `json:"userId"`
  401. Gift int64 `json:"gift"`
  402. }
  403. type ResponseGmSendGift struct {
  404. ErrCode int `json:"errCode"`
  405. MsgId string `json:"msgId"`
  406. }
  407. // GmChatForbid 用户禁言的nats消息结构
  408. type GmChatForbid struct {
  409. MsgId string `json:"msgId"`
  410. PlayerID int64 `json:"userId"`
  411. ForbidTime int64 `json:"forbidTime"`
  412. }
  413. type ResponseGmChatForbid struct {
  414. ErrCode int `json:"errCode"`
  415. MsgId string `json:"msgId"`
  416. }