user.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. package user
  2. import (
  3. "encoding/hex"
  4. "fmt"
  5. "mtp2_if/global/app"
  6. "mtp2_if/global/e"
  7. "mtp2_if/logger"
  8. "mtp2_if/models"
  9. "mtp2_if/utils"
  10. "net/http"
  11. "github.com/gin-gonic/gin"
  12. )
  13. // QueryUserReferNumReq 获取用户邀请码请求参数
  14. type QueryUserReferNumReq struct {
  15. UserID int `form:"userID" binding:"required"`
  16. }
  17. // QueryUserReferNum 获取用户邀请码
  18. // @Summary 获取用户邀请码
  19. // @Produce json
  20. // @Param userID query int true "用户ID"
  21. // @Success 200 {object} app.Response
  22. // @Failure 500 {object} app.Response
  23. // @Router /User/QueryUserReferNum [get]
  24. // @Tags 用户信息
  25. func QueryUserReferNum(c *gin.Context) {
  26. appG := app.Gin{C: c}
  27. // 获取请求参数
  28. var req QueryUserReferNumReq
  29. if err := appG.C.ShouldBindQuery(&req); err != nil {
  30. logger.GetLogger().Errorf("QueryUserReferNum failed: %s", err.Error())
  31. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  32. return
  33. }
  34. var (
  35. userAccount *models.Useraccount
  36. err error
  37. )
  38. if userAccount, err = models.GetUserAccount(req.UserID); err != nil {
  39. // 查询失败
  40. logger.GetLogger().Errorf("QueryUserReferNum failed: %s", err.Error())
  41. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  42. return
  43. }
  44. // 查询成功
  45. logger.GetLogger().Debugln("QueryUserReferNum successed: %v", userAccount.Refernum)
  46. appG.Response(http.StatusOK, e.SUCCESS, userAccount.Refernum)
  47. }
  48. // QueryUserInfoReq 获取用户信息请求参数
  49. type QueryUserInfoReq struct {
  50. UserID int `form:"userID" binding:"required"`
  51. IsDecrypt bool `form:"isDecrypt"`
  52. }
  53. // QueryUserInfo 获取用户信息
  54. // @Summary 获取用户信息
  55. // @Produce json
  56. // @Security ApiKeyAuth
  57. // @Param userID query int true "用户ID"
  58. // @Param isDecrypt query bool false "是否解密"
  59. // @Success 200 {object} models.Userinfo
  60. // @Failure 500 {object} app.Response
  61. // @Router /User/QueryUserInfo [get]
  62. // @Tags 用户信息
  63. func QueryUserInfo(c *gin.Context) {
  64. appG := app.Gin{C: c}
  65. // 获取请求参数
  66. var req QueryUserInfoReq
  67. if err := appG.C.ShouldBindQuery(&req); err != nil {
  68. logger.GetLogger().Errorf("QueryUserInfo failed: %s", err.Error())
  69. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  70. return
  71. }
  72. // 查询数据
  73. var (
  74. data *models.Userinfo
  75. err error
  76. )
  77. if data, err = models.GetUserInfo(req.UserID); err != nil {
  78. // 查询失败
  79. logger.GetLogger().Errorf("QueryUserInfo failed: %s", err.Error())
  80. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  81. return
  82. }
  83. // 解密
  84. if req.IsDecrypt {
  85. key, _ := hex.DecodeString(utils.AESSecretKey)
  86. // 手机号码解密
  87. if len(data.Mobile) > 0 {
  88. if phonenum, err := hex.DecodeString(data.Mobile); err == nil { // hex -> []byte
  89. if mobile, err := utils.AESDecrypt(phonenum, key); err == nil {
  90. // 脱敏
  91. tmp := string(mobile)
  92. l := len(tmp)
  93. if l > 7 {
  94. tmp = fmt.Sprintf("%s****%s", tmp[:3], tmp[l-4:])
  95. } else {
  96. tmp = fmt.Sprintf("%s****", tmp[:3])
  97. }
  98. data.Mobile = tmp
  99. }
  100. }
  101. }
  102. // 证件号码解密
  103. if len(data.Cardnum) > 0 {
  104. if cardnum, err := hex.DecodeString(data.Cardnum); err == nil { // hex -> []byte
  105. if c, err := utils.AESDecrypt(cardnum, key); err == nil {
  106. // 脱敏
  107. tmp := string(c)
  108. l := len(tmp)
  109. if l > 7 {
  110. tmp = fmt.Sprintf("%s****%s", tmp[:3], tmp[l-4:])
  111. } else {
  112. tmp = fmt.Sprintf("%s****", tmp[:3])
  113. }
  114. data.Cardnum = tmp
  115. }
  116. }
  117. }
  118. }
  119. // 查询成功
  120. logger.GetLogger().Debugln("QueryUserInfo successed: %v", data)
  121. appG.Response(http.StatusOK, e.SUCCESS, data)
  122. }
  123. // GetUserAuthStatusReq 获取用户实名认证状态请求参数
  124. type GetUserAuthStatusReq struct {
  125. UserID int `form:"userID" binding:"required"` // 用户ID
  126. }
  127. // GetUserAuthStatus 获取用户实名认证状态
  128. // @Summary 获取用户实名认证状态
  129. // @Produce json
  130. // @Security ApiKeyAuth
  131. // @Param userID query int true "用户ID"
  132. // @Success 200 {object} app.Response
  133. // @Failure 500 {object} app.Response
  134. // @Router /User/GetUserAuthStatus [get]
  135. // @Tags 用户信息
  136. func GetUserAuthStatus(c *gin.Context) {
  137. appG := app.Gin{C: c}
  138. // 获取请求参数
  139. var req GetUserAuthStatusReq
  140. if err := appG.C.ShouldBindQuery(&req); err != nil {
  141. logger.GetLogger().Errorf("GetUserAuthStatus failed: %s", err.Error())
  142. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  143. return
  144. }
  145. isAuth := false
  146. var (
  147. userAccount *models.Useraccount
  148. err error
  149. )
  150. if userAccount, err = models.GetUserAccount(req.UserID); err != nil {
  151. // 查询失败
  152. logger.GetLogger().Errorf("GetUserAuthStatus failed: %s", err.Error())
  153. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  154. return
  155. }
  156. if userAccount != nil {
  157. if userAccount.Hasauth == 1 {
  158. isAuth = true
  159. }
  160. }
  161. // 查询成功
  162. logger.GetLogger().Debugln("GetUserAuthStatus successed: %v", isAuth)
  163. appG.Response(http.StatusOK, e.SUCCESS, isAuth)
  164. }
  165. // GetUserAccountReq 获取用户账号信息请求参数
  166. type GetUserAccountReq struct {
  167. UserID int `form:"userID" binding:"required"` // 用户ID
  168. }
  169. // GetUserAccount 获取用户账号信息
  170. // @Summary 获取用户账号信息
  171. // @Produce json
  172. // @Security ApiKeyAuth
  173. // @Param userID query int true "用户ID"
  174. // @Success 200 {object} models.Useraccount
  175. // @Failure 500 {object} app.Response
  176. // @Router /User/GetUserAccount [get]
  177. // @Tags 用户信息
  178. func GetUserAccount(c *gin.Context) {
  179. appG := app.Gin{C: c}
  180. // 获取请求参数
  181. var req GetUserAccountReq
  182. if err := appG.C.ShouldBindQuery(&req); err != nil {
  183. logger.GetLogger().Errorf("GetUserAccount failed: %s", err.Error())
  184. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  185. return
  186. }
  187. var (
  188. userAccount *models.Useraccount
  189. err error
  190. )
  191. if userAccount, err = models.GetUserAccount(req.UserID); err != nil {
  192. // 查询失败
  193. logger.GetLogger().Errorf("GetUserAccount failed: %s", err.Error())
  194. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  195. return
  196. }
  197. // 查询成功
  198. logger.GetLogger().Debugln("GetUserAccount successed: %v", userAccount)
  199. appG.Response(http.StatusOK, e.SUCCESS, userAccount)
  200. }
  201. // LoginQueryReq 账户登录后信息查询请求参数
  202. type LoginQueryReq struct {
  203. LoginID int `form:"loginID" binding:"required"`
  204. }
  205. // LoginQueryRsp 账户登录后信息查询返回模型
  206. type LoginQueryRsp struct {
  207. UserName string `json:"username"` // 用户姓名
  208. LoginAccount models.Loginaccount `json:"loginAccount"` // 登录账号
  209. UserAccount models.Useraccount `json:"userAccount"` // 用户账号
  210. UserInfo models.Userinfo `json:"userInfo"` // 用户信息
  211. Markets []models.Market `json:"markets"` // 市场
  212. Goodsgroups []models.Goodsgroup `json:"goodsgroups"` // 商品组
  213. ExternalExchanges []models.Externalexchange `json:"externalExchanges"` // 外部交易所
  214. SystemParams []models.Systemparam `json:"systemParams"` // 系统参数
  215. }
  216. // LoginQuery 账户登录后信息查询
  217. // @Summary 账户登录后信息查询
  218. // @Produce json
  219. // @Security ApiKeyAuth
  220. // @Param loginID query int true "登录账号"
  221. // @Success 200 {object} LoginQueryRsp
  222. // @Failure 500 {object} app.Response
  223. // @Router /User/LoginQuery [get]
  224. // @Tags 用户信息
  225. func LoginQuery(c *gin.Context) {
  226. appG := app.Gin{C: c}
  227. // 获取请求参数
  228. var req LoginQueryReq
  229. if err := appG.C.ShouldBindQuery(&req); err != nil {
  230. logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
  231. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  232. return
  233. }
  234. var rsp LoginQueryRsp
  235. // 登录账号
  236. loginAccount, err := models.GetLoginAccount(req.LoginID)
  237. if err != nil {
  238. // 查询失败
  239. logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
  240. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  241. return
  242. }
  243. rsp.LoginAccount = *loginAccount
  244. // 用户账号
  245. userAccount, err := models.GetUserAccount(int(loginAccount.Userid))
  246. if err != nil {
  247. // 查询失败
  248. logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
  249. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  250. return
  251. }
  252. rsp.UserAccount = *userAccount
  253. // 用户信息
  254. userInfo, err := models.GetUserInfo(int(loginAccount.Userid))
  255. if err != nil {
  256. // 查询失败
  257. logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
  258. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  259. return
  260. }
  261. rsp.UserInfo = *userInfo
  262. // 有权限的市场
  263. markets, err := models.GetMarketsByLoginID(req.LoginID)
  264. if err != nil {
  265. // 查询失败
  266. logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
  267. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  268. return
  269. }
  270. rsp.Markets = markets
  271. // 商品组
  272. rsp.Goodsgroups = make([]models.Goodsgroup, 0)
  273. if len(rsp.Markets) > 0 {
  274. marketIDs := make([]int, 0)
  275. for _, v := range rsp.Markets {
  276. marketIDs = append(marketIDs, int(v.Marketid))
  277. }
  278. goodsgroups, err := models.GetGoodsgroupInMarketIDs(marketIDs)
  279. if err != nil {
  280. // 查询失败
  281. logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
  282. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  283. return
  284. }
  285. rsp.Goodsgroups = goodsgroups
  286. }
  287. // 外部交易所
  288. rsp.ExternalExchanges = make([]models.Externalexchange, 0)
  289. if len(rsp.Goodsgroups) > 0 {
  290. exchangeIDs := make([]int, 0)
  291. for _, v := range rsp.Goodsgroups {
  292. exchangeIDs = append(exchangeIDs, int(v.Exexchangeid))
  293. }
  294. exExchanges, err := models.GetExExchangeByIDs(exchangeIDs)
  295. if err != nil {
  296. // 查询失败
  297. logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
  298. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  299. return
  300. }
  301. rsp.ExternalExchanges = exExchanges
  302. }
  303. // 系统参数
  304. systemParams, err := models.GetSystemParams()
  305. if err != nil {
  306. // 查询失败
  307. logger.GetLogger().Errorf("LoginQuery failed: %s", err.Error())
  308. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  309. return
  310. }
  311. rsp.SystemParams = systemParams
  312. // 用户姓名
  313. if len(rsp.LoginAccount.Logincode) > 0 {
  314. systemManager, _ := models.GetSysteMmanagerByLoginCode(rsp.LoginAccount.Logincode)
  315. if systemManager != nil {
  316. rsp.UserName = systemManager.Username
  317. }
  318. }
  319. // 查询成功
  320. logger.GetLogger().Debugln("LoginQuery successed: %v", rsp)
  321. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  322. }
  323. // QueryUserFavoriteGoodsesReq 获取用户商品收藏信息请求参数
  324. type QueryUserFavoriteGoodsesReq struct {
  325. UserID int `form:"userID" binding:"required"`
  326. }
  327. // QueryUserFavoriteGoodses 获取用户商品收藏信息
  328. // @Summary 获取用户商品收藏信息
  329. // @Produce json
  330. // @Security ApiKeyAuth
  331. // @Param userID query int true "用户ID"
  332. // @Success 200 {object} models.Userfavoritegoods
  333. // @Failure 500 {object} app.Response
  334. // @Router /User/QueryUserFavoriteGoodses [get]
  335. // @Tags 用户信息
  336. func QueryUserFavoriteGoodses(c *gin.Context) {
  337. appG := app.Gin{C: c}
  338. // 获取请求参数
  339. var req QueryUserFavoriteGoodsesReq
  340. if err := appG.C.ShouldBindQuery(&req); err != nil {
  341. logger.GetLogger().Errorf("QueryUserFavoriteGoodses failed: %s", err.Error())
  342. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  343. return
  344. }
  345. userFavoriteGoodses, err := models.GetUserFavoriteGoodses(req.UserID)
  346. if err != nil {
  347. // 查询失败
  348. logger.GetLogger().Errorf("GetUserAuthStatus failed: %s", err.Error())
  349. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  350. return
  351. }
  352. // 查询成功
  353. logger.GetLogger().Debugln("QueryUserFavoriteGoodses successed: %v", userFavoriteGoodses)
  354. appG.Response(http.StatusOK, e.SUCCESS, userFavoriteGoodses)
  355. }
  356. // UpdateUserFavoriteGoodsReq 更新用户商品收藏信息请求参数
  357. type UpdateUserFavoriteGoodsReq struct {
  358. UserID int `form:"userID" binding:"required"`
  359. GoodsID int `form:"goodsID" binding:"required"`
  360. }
  361. // AddUserFavoriteGoods 添加用户商品收藏信息
  362. // @Summary 添加用户商品收藏信息
  363. // @Produce json
  364. // @Security ApiKeyAuth
  365. // @Param userID query int true "用户ID"
  366. // @Param goodsID query int true "商品ID"
  367. // @Success 200 {object} app.Response
  368. // @Failure 500 {object} app.Response
  369. // @Router /User/AddUserFavoriteGoods [post]
  370. // @Tags 用户信息
  371. func AddUserFavoriteGoods(c *gin.Context) {
  372. appG := app.Gin{C: c}
  373. // 获取请求参数
  374. var req UpdateUserFavoriteGoodsReq
  375. if err := appG.C.ShouldBind(&req); err != nil {
  376. logger.GetLogger().Errorf("AddUserFavoriteGoods failed: %s", err.Error())
  377. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  378. return
  379. }
  380. if err := models.InsertUserFavoriteGoods(req.UserID, req.GoodsID); err != nil {
  381. // 执行失败
  382. logger.GetLogger().Errorf("AddUserFavoriteGoods failed: %s", err.Error())
  383. appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
  384. return
  385. }
  386. // 执行成功
  387. logger.GetLogger().Debugln("AddUserFavoriteGoods successed: %v", "ok")
  388. appG.Response(http.StatusOK, e.SUCCESS, "")
  389. }
  390. // RemoveUserFavoriteGoods 移除用户商品收藏信息
  391. // @Summary 移除用户商品收藏信息
  392. // @Produce json
  393. // @Security ApiKeyAuth
  394. // @Param userID query int true "用户ID"
  395. // @Param goodsID query int true "商品ID"
  396. // @Success 200 {object} app.Response
  397. // @Failure 500 {object} app.Response
  398. // @Router /User/RemoveUserFavoriteGoods [post]
  399. // @Tags 用户信息
  400. func RemoveUserFavoriteGoods(c *gin.Context) {
  401. appG := app.Gin{C: c}
  402. // 获取请求参数
  403. var req UpdateUserFavoriteGoodsReq
  404. if err := appG.C.ShouldBind(&req); err != nil {
  405. logger.GetLogger().Errorf("RemoveUserFavoriteGoods failed: %s", err.Error())
  406. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  407. return
  408. }
  409. if err := models.DelUserFavoriteGoods(req.UserID, req.GoodsID); err != nil {
  410. // 执行失败
  411. logger.GetLogger().Errorf("RemoveUserFavoriteGoods failed: %s", err.Error())
  412. appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
  413. return
  414. }
  415. // 执行成功
  416. logger.GetLogger().Debugln("RemoveUserFavoriteGoods successed: %v", "ok")
  417. appG.Response(http.StatusOK, e.SUCCESS, "")
  418. }
  419. // QueryMessageBoardReq 获取用户留言板信息请求参数
  420. type QueryMessageBoardReq struct {
  421. UserID int `form:"userID" binding:"required"`
  422. }
  423. // QueryMessageBoard 获取用户留言板信息
  424. // @Summary 获取用户留言板信息
  425. // @Produce json
  426. // @Security ApiKeyAuth
  427. // @Param userID query int true "用户ID"
  428. // @Success 200 {object} models.Messageboard
  429. // @Failure 500 {object} app.Response
  430. // @Router /User/QueryMessageBoard [get]
  431. // @Tags 用户信息
  432. func QueryMessageBoard(c *gin.Context) {
  433. appG := app.Gin{C: c}
  434. // 获取请求参数
  435. var req QueryMessageBoardReq
  436. if err := appG.C.ShouldBindQuery(&req); err != nil {
  437. logger.GetLogger().Errorf("QueryMessageBoard failed: %s", err.Error())
  438. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  439. return
  440. }
  441. messageBoards, err := models.GetMessageBoard(req.UserID)
  442. if err != nil {
  443. // 查询失败
  444. logger.GetLogger().Errorf("QueryMessageBoard failed: %s", err.Error())
  445. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  446. return
  447. }
  448. // 查询成功
  449. logger.GetLogger().Debugln("QueryMessageBoard successed: %v", messageBoards)
  450. appG.Response(http.StatusOK, e.SUCCESS, messageBoards)
  451. }
  452. // AddMessageBoardReq 添加用户留言板信息请求参数
  453. type AddMessageBoardReq struct {
  454. UserID int `form:"userID" binding:"required"`
  455. Message string `form:"message" binding:"required"`
  456. ContactNum string `form:"contactNum" binding:"required"`
  457. }
  458. // AddMessageBoard 添加用户留言板信息
  459. // @Summary 添加用户留言板信息
  460. // @Produce json
  461. // @Security ApiKeyAuth
  462. // @Param userID query int true "用户ID"
  463. // @Param message query string true "留言信息"
  464. // @Param contactNum query string true "联系电话"
  465. // @Success 200 {object} app.Response
  466. // @Failure 500 {object} app.Response
  467. // @Router /User/AddMessageBoard [post]
  468. // @Tags 用户信息
  469. func AddMessageBoard(c *gin.Context) {
  470. appG := app.Gin{C: c}
  471. // 获取请求参数
  472. var req AddMessageBoardReq
  473. if err := appG.C.ShouldBind(&req); err != nil {
  474. logger.GetLogger().Errorf("AddMessageBoard failed: %s", err.Error())
  475. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  476. return
  477. }
  478. if errCode := models.InsertMessageBoard(req.UserID, req.Message, req.ContactNum); errCode != 0 {
  479. // 执行失败
  480. logger.GetLogger().Errorf("AddMessageBoard failed: %s", e.GetMsg(errCode))
  481. appG.Response(http.StatusBadRequest, errCode, nil)
  482. return
  483. }
  484. // 执行成功
  485. logger.GetLogger().Debugln("AddMessageBoard successed: %v", "ok")
  486. appG.Response(http.StatusOK, e.SUCCESS, "")
  487. }
  488. // UpdateUserAccountStatusReq 更新用户状态请求参数
  489. type UpdateUserAccountStatusReq struct {
  490. UserID int `form:"userID" binding:"required"`
  491. AccountStatus int `form:"accountStatus" binding:"required"`
  492. }
  493. // UpdateUserAccountStatus 更新用户状态
  494. // @Summary 更新用户状态
  495. // @Produce json
  496. // @Security ApiKeyAuth
  497. // @Param userID query int true "用户ID"
  498. // @Param accountStatus query int true "账户状态 - 4:正常 6:注销(停用)"
  499. // @Success 200 {object} app.Response
  500. // @Failure 500 {object} app.Response
  501. // @Router /User/UpdateUserAccountStatus [post]
  502. // @Tags 用户信息
  503. func UpdateUserAccountStatus(c *gin.Context) {
  504. appG := app.Gin{C: c}
  505. // 获取请求参数
  506. var req UpdateUserAccountStatusReq
  507. if err := appG.C.ShouldBind(&req); err != nil {
  508. logger.GetLogger().Errorf("UpdateUserAccountStatus failed: %s", err.Error())
  509. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  510. return
  511. }
  512. if err := models.UpdateUserAccountStatus(req.UserID, req.AccountStatus); err != nil {
  513. // 执行失败
  514. logger.GetLogger().Errorf("UpdateUserAccountStatus failed: %s", err.Error())
  515. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  516. return
  517. }
  518. // 执行成功
  519. logger.GetLogger().Debugln("UpdateUserAccountStatus successed: %v", "ok")
  520. appG.Response(http.StatusOK, e.SUCCESS, "ok")
  521. }