附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_user.go 2.5 KiB

2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/e"
  6. "applet/app/md"
  7. "applet/app/svc"
  8. "applet/app/utils"
  9. "github.com/gin-gonic/gin"
  10. "github.com/jinzhu/copier"
  11. )
  12. // User 用户信息
  13. // @Summary 用户信息
  14. // @Tags 用户信息
  15. // @Description 用户信息
  16. // @Accept json
  17. // @Produce json
  18. // @Success 200 {string} ""
  19. // @Failure 400 {object} md.Response "具体错误"
  20. // @Router /api/v1/communityTeam/ownStore/user [GET]
  21. func User(c *gin.Context) {
  22. user := svc.GetUser(c)
  23. res := map[string]string{
  24. "head_img": user.Profile.AvatarUrl,
  25. "nickname": user.Info.Nickname,
  26. "phone": user.Info.Phone,
  27. "state": "0",
  28. "info": "",
  29. "store_type": "0",
  30. }
  31. storeCheck := db.StoreAuditByUid(svc.MasterDb(c), user.Info.Uid)
  32. if storeCheck != nil {
  33. if storeCheck.State == 1 {
  34. res["state"] = "1"
  35. }
  36. if storeCheck.State == 3 {
  37. res["state"] = "3"
  38. res["info"] = storeCheck.Info
  39. }
  40. }
  41. userParty := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  42. if userParty != nil {
  43. if userParty.State == 1 {
  44. res["state"] = "2"
  45. } else if storeCheck != nil && storeCheck.State == 2 {
  46. res["state"] = "3"
  47. }
  48. res["store_type"] = utils.IntToStr(userParty.StoreType)
  49. }
  50. e.OutSuc(c, res, nil)
  51. return
  52. }
  53. func Base(c *gin.Context) {
  54. user := svc.GetUser(c)
  55. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  56. var res = md.CommunityTeamStore{}
  57. if store != nil {
  58. copier.Copy(&res, &store)
  59. res.DistrictId = utils.IntToStr(store.DistrictId)
  60. res.CityId = utils.IntToStr(store.CityId)
  61. res.WorkState = utils.IntToStr(store.WorkState)
  62. res.ProvinceId = utils.IntToStr(store.ProvinceId)
  63. }
  64. e.OutSuc(c, res, nil)
  65. return
  66. }
  67. func BaseSet(c *gin.Context) {
  68. var arg md.CommunityTeamStore
  69. if err := c.ShouldBindJSON(&arg); err != nil {
  70. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  71. return
  72. }
  73. user := svc.GetUser(c)
  74. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  75. var storeData model.CommunityTeamStore
  76. copier.Copy(&storeData, &arg)
  77. storeData.DistrictId = utils.StrToInt(arg.DistrictId)
  78. storeData.CityId = utils.StrToInt(arg.CityId)
  79. storeData.WorkState = utils.StrToInt(arg.WorkState)
  80. storeData.ProvinceId = utils.StrToInt(arg.ProvinceId)
  81. svc.MasterDb(c).Where("id=?", store.Id).Cols("lat,lng,address,work_state,name,province,city,district,timer,phone,logo,province_id,city_id,district_id").Update(&storeData)
  82. e.OutSuc(c, "success", nil)
  83. return
  84. }