蛋蛋星球 后台端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

hdl_user_management.go 7.6 KiB

1 månad sedan
1 månad sedan
1 månad sedan
1 månad sedan
1 månad sedan
1 månad sedan
1 månad sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. package member_center
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. md "applet/app/md/institutional_management/member_center"
  6. svc "applet/app/svc/member_center"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // UserManagementGetUserList
  11. // @Summary 制度中心-会员中心-用户信息管理(获取)
  12. // @Tags 会员中心
  13. // @Description 用户信息管理(获取)
  14. // @Accept json
  15. // @Produce json
  16. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  17. // @Param req body md.UserManagementGetUserListReq true "分页信息必填"
  18. // @Success 200 {object} md.UserManagementGetUserListResp "具体数据"
  19. // @Failure 400 {object} md.Response "具体错误"
  20. // @Router /api/memberCenter/userManagement/getUserList [post]
  21. func UserManagementGetUserList(c *gin.Context) {
  22. var req *md.UserManagementGetUserListReq
  23. if err := c.ShouldBindJSON(&req); err != nil {
  24. e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
  25. return
  26. }
  27. levelDb := implement.NewUserLevelDb(db.Db)
  28. levels, err1 := levelDb.UserLevelAllByAsc()
  29. if err1 != nil {
  30. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  31. return
  32. }
  33. levelsList := make([]map[string]interface{}, 0)
  34. levelsMap := make(map[int]string)
  35. for _, level := range levels {
  36. levelsList = append(levelsList, map[string]interface{}{
  37. "id": level.Id,
  38. "name": level.LevelName,
  39. })
  40. levelsMap[level.Id] = level.LevelName
  41. }
  42. tagDb := implement.NewUserTagDb(db.Db)
  43. tags, err2 := tagDb.UserTagAllByAsc()
  44. if err2 != nil {
  45. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  46. return
  47. }
  48. tagsList := make([]map[string]interface{}, 0)
  49. tagsMap := make(map[int]string)
  50. for _, tag := range tags {
  51. tagsList = append(tagsList, map[string]interface{}{
  52. "id": tag.Id,
  53. "name": tag.TagName,
  54. })
  55. tagsMap[tag.Id] = tag.TagName
  56. }
  57. users, total, err3 := svc.UserManagementGetUsers(db.Db, req)
  58. if err3 != nil {
  59. e.OutErr(c, e.ERR_DB_ORM, err3.Error())
  60. return
  61. }
  62. var levelCounts []md.LevelCount
  63. err4 := db.Db.Table("user").Select("level, Count(*) AS count").GroupBy("level").Find(&levelCounts)
  64. if err4 != nil {
  65. e.OutErr(c, e.ERR_DB_ORM, err4.Error())
  66. return
  67. }
  68. list := make([]md.UserManagementGetUserListNode, len(*users))
  69. for i, user := range *users {
  70. list[i] = md.UserManagementGetUserListNode{
  71. ID: user.Id,
  72. Tag: tagsMap[user.TagID],
  73. Avatar: user.Avatar,
  74. Nickname: user.Nickname,
  75. Phone: user.Phone,
  76. IsRealName: user.IsRealName,
  77. Level: levelsMap[user.Level],
  78. InviteCode: user.SystemInviteCode,
  79. ParentID: user.ParentUid,
  80. ParentInviteCode: user.ParentSystemInviteCode,
  81. ParentPhone: user.Phone,
  82. RegisterTime: user.CreateAt,
  83. Memo: user.Memo,
  84. }
  85. }
  86. resp := md.UserManagementGetUserListResp{
  87. LevelsList: levelsList,
  88. TagsList: tagsList,
  89. List: list,
  90. Paginate: md.Paginate{
  91. Limit: req.Limit,
  92. Page: req.Page,
  93. Total: total,
  94. },
  95. }
  96. e.OutSuc(c, resp, nil)
  97. }
  98. // UserManagementUpdateUserInfo
  99. // @Summary 制度中心-会员中心-用户信息管理(更新)
  100. // @Tags 会员中心
  101. // @Description 用户信息管理(更新)
  102. // @Accept json
  103. // @Produce json
  104. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  105. // @Param req body md.UserManagementUpdateUserInfoReq true "用户ID 必传"
  106. // @Success 200 {int} "修改数据行数"
  107. // @Failure 400 {object} md.Response "具体错误"
  108. // @Router /api/memberCenter/userManagement/updateUserInfo [post]
  109. func UserManagementUpdateUserInfo(c *gin.Context) {
  110. var req *md.UserManagementUpdateUserInfoReq
  111. if err := c.ShouldBindJSON(&req); err != nil {
  112. e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
  113. return
  114. }
  115. _ = implement.NewUserDb(db.Db)
  116. //var affected int64
  117. //var err1 error
  118. //forceColumns := make([]string, 0)
  119. //user := model.User{
  120. // Id: req.UID,
  121. //}
  122. //if req.Memo != "" {
  123. // user.Memo = req.Memo
  124. // forceColumns = append(forceColumns, "memo")
  125. //}
  126. //if req.Disable != false {
  127. // user.State = 2
  128. // forceColumns = append(forceColumns, "state")
  129. //}
  130. //if req.LastLoginIp != "" {
  131. // user.LastLoginIp = req.LastLoginIp
  132. // forceColumns = append(forceColumns, "last_login_ip")
  133. //}
  134. //if req.Avatar != "" {
  135. // user.Avatar = req.Avatar
  136. // forceColumns = append(forceColumns, "avatar")
  137. //}
  138. //if len(forceColumns) > 0 {
  139. // affected, err1 = userDb.UserUpdate(req.UID, &user)
  140. // if err1 != nil {
  141. // e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  142. // return
  143. // }
  144. //}
  145. //
  146. //var err2 error
  147. //if req.Tag != 0 {
  148. // record := model.UserTagRecords{
  149. // TagId: req.Tag,
  150. // }
  151. // recordsDb := implement.NewUserTagRecordsDb(db.Db)
  152. // affected, err2 = recordsDb.UserTagRecordsUpdate(req.UID, &record, "tag_id")
  153. // if err2 != nil {
  154. // e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  155. // return
  156. // }
  157. //
  158. //}
  159. e.OutSuc(c, 0, nil)
  160. }
  161. // UserManagementGetOneBasic
  162. // @Summary 制度中心-会员中心-会员明细概况(获取)
  163. // @Tags 会员中心
  164. // @Description 会员明细概况(更新)
  165. // @Accept json
  166. // @Produce json
  167. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  168. // @Param uid query int true "用户 ID"
  169. // @Success 200 {object} md.UserManagementGetOneBasicResp "会员明细概况具体数据"
  170. // @Failure 400 {object} md.Response "具体错误"
  171. // @Router /api/memberCenter/userManagement/getOneBasicInfo [get]
  172. //func UserManagementGetOneBasic(c *gin.Context) {
  173. // uid := c.Query("uid")
  174. // userDb := implement.NewUserDb(db.Db)
  175. // user, err := userDb.UserGetOneByParams(map[string]interface{}{
  176. // "key": "id",
  177. // "value": uid,
  178. // })
  179. // if err != nil {
  180. // e.OutErr(c, e.ERR_DB_ORM, err.Error())
  181. // return
  182. // }
  183. //
  184. // levelDb := implement.NewUserLevelDb(db.Db)
  185. // levels, err1 := levelDb.UserLevelAllByAsc()
  186. // if err1 != nil {
  187. // e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  188. // return
  189. // }
  190. // levelsList := make([]map[string]interface{}, 0)
  191. // levelsMap := make(map[int]string)
  192. // for _, level := range levels {
  193. // levelsList = append(levelsList, map[string]interface{}{
  194. // "id": level.Id,
  195. // "name": level.LevelName,
  196. // })
  197. // levelsMap[level.Id] = level.LevelName
  198. // }
  199. //
  200. // tagDb := implement.NewUserTagDb(db.Db)
  201. // tags, err2 := tagDb.UserTagAllByAsc()
  202. // if err2 != nil {
  203. // e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  204. // return
  205. // }
  206. // tagsList := make([]map[string]interface{}, 0)
  207. // tagsMap := make(map[int]string)
  208. // for _, tag := range tags {
  209. // tagsList = append(tagsList, map[string]interface{}{
  210. // "id": tag.Id,
  211. // "name": tag.TagName,
  212. // })
  213. // tagsMap[tag.Id] = tag.TagName
  214. // }
  215. //
  216. // coinDb := implement.NewVirtualCoinDb(db.Db)
  217. // coins, err3 := coinDb.VirtualCoinFindAll()
  218. // if err3 != nil {
  219. // e.OutErr(c, e.ERR_DB_ORM, err3.Error())
  220. // return
  221. // }
  222. // coinsList := make([]map[string]interface{}, 0)
  223. // coinsMap := make(map[int]string)
  224. // for _, coin := range coins {
  225. // coinsList = append(coinsList, map[string]interface{}{
  226. // "id": coin.Id,
  227. // "name": coin.Name,
  228. // })
  229. // coinsMap[coin.Id] = coin.Name
  230. // }
  231. //
  232. // parent, err := userDb.UserGetOneByParams(map[string]interface{}{
  233. // "key": "id",
  234. // "value": user.ParentUid,
  235. // })
  236. // if err != nil {
  237. // e.OutErr(c, e.ERR_DB_ORM, err.Error())
  238. // return
  239. // }
  240. //
  241. // recordsDb := implement.NewUserTagRecordsDb(db.Db)
  242. // userTagRecord, err := recordsDb.UserTagRecordsGetOneByParams(map[string]interface{}{
  243. // "key": "uid",
  244. // "value": uid,
  245. // })
  246. // if err != nil {
  247. // return
  248. // }
  249. //
  250. // amountDb := implement.NewUserVirtualAmountDb(db.Db)
  251. // amountDb.GetUserVirtualWalletBySession()
  252. //}