附近小店
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.4 KiB

3 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. }
  30. storeCheck := db.StoreAuditByUid(svc.MasterDb(c), user.Info.Uid)
  31. if storeCheck != nil {
  32. if storeCheck.State == 1 {
  33. res["state"] = "1"
  34. }
  35. if storeCheck.State == 3 {
  36. res["state"] = "3"
  37. res["info"] = storeCheck.Info
  38. }
  39. }
  40. userParty := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  41. if userParty != nil {
  42. if userParty.State == 1 {
  43. res["state"] = "2"
  44. } else if storeCheck != nil && storeCheck.State == 2 {
  45. res["state"] = "3"
  46. }
  47. }
  48. e.OutSuc(c, res, nil)
  49. return
  50. }
  51. func Base(c *gin.Context) {
  52. user := svc.GetUser(c)
  53. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  54. var res = md.CommunityTeamStore{}
  55. if store != nil {
  56. copier.Copy(&res, &store)
  57. res.DistrictId = utils.IntToStr(store.DistrictId)
  58. res.CityId = utils.IntToStr(store.CityId)
  59. res.WorkState = utils.IntToStr(store.WorkState)
  60. res.ProvinceId = utils.IntToStr(store.ProvinceId)
  61. }
  62. e.OutSuc(c, res, nil)
  63. return
  64. }
  65. func BaseSet(c *gin.Context) {
  66. var arg md.CommunityTeamStore
  67. if err := c.ShouldBindJSON(&arg); err != nil {
  68. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  69. return
  70. }
  71. user := svc.GetUser(c)
  72. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  73. var storeData model.CommunityTeamStore
  74. copier.Copy(&storeData, &arg)
  75. storeData.DistrictId = utils.StrToInt(arg.DistrictId)
  76. storeData.CityId = utils.StrToInt(arg.CityId)
  77. storeData.WorkState = utils.StrToInt(arg.WorkState)
  78. storeData.ProvinceId = utils.StrToInt(arg.ProvinceId)
  79. 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)
  80. e.OutSuc(c, "success", nil)
  81. return
  82. }