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

96 lines
2.0 KiB

  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/e"
  6. "applet/app/store/svc"
  7. "github.com/gin-gonic/gin"
  8. )
  9. // Login 登陆
  10. // @Summary 登陆
  11. // @Tags 登陆
  12. // @Description 登入
  13. // @Accept json
  14. // @Produce json
  15. // @Param req body md.FastLoginRequestBody true "请求参数"
  16. // @Success 200 {object} md.LoginResponse ""
  17. // @Failure 400 {object} md.Response "具体错误"
  18. // @Router /api/v1/communityTeam/store/login [post]
  19. func Login(c *gin.Context) {
  20. svc.Login(c)
  21. }
  22. func LoginSendSms(c *gin.Context) {
  23. svc.LoginSendSms(c)
  24. }
  25. func Sms(c *gin.Context) {
  26. svc.Sms(c)
  27. }
  28. func LoginFastIn(c *gin.Context) {
  29. svc.LoginFastIn(c)
  30. }
  31. type resultItem struct {
  32. Id string `json:"id" example:"440100000000"`
  33. Name string `json:"name" example:"city"`
  34. }
  35. func GetRegionChildNode(c *gin.Context) {
  36. parent, has := c.GetQuery("parent")
  37. if !has {
  38. e.OutErr(c, e.ERR_INVALID_ARGS)
  39. return
  40. }
  41. id, has := c.GetQuery("id")
  42. if parent != "root" && !has {
  43. e.OutErr(c, e.ERR_INVALID_ARGS)
  44. return
  45. }
  46. var nodeList []interface{}
  47. var err error
  48. switch parent {
  49. case "root":
  50. var provinceList []*model.Province
  51. err = db.Db.Find(&provinceList)
  52. for _, item := range provinceList {
  53. nodeList = append(nodeList, resultItem{
  54. Id: item.Id,
  55. Name: item.Name,
  56. })
  57. }
  58. case "province":
  59. var cityList []*model.City
  60. err = db.Db.Where("province_id=?", id).Find(&cityList)
  61. for _, item := range cityList {
  62. nodeList = append(nodeList, resultItem{
  63. Id: item.Id,
  64. Name: item.Name,
  65. })
  66. }
  67. case "city":
  68. var countyList []*model.County
  69. err = db.Db.Where("city_id=?", id).Find(&countyList)
  70. for _, item := range countyList {
  71. nodeList = append(nodeList, resultItem{
  72. Id: item.Id,
  73. Name: item.Name,
  74. })
  75. }
  76. default:
  77. e.OutErr(c, e.ERR_INVALID_ARGS)
  78. return
  79. }
  80. if err != nil {
  81. e.OutErr(c, e.ERR_DB_ORM, err)
  82. return
  83. }
  84. if len(nodeList) == 0 {
  85. e.OutSuc(c, []interface{}{}, nil)
  86. return
  87. }
  88. e.OutSuc(c, nodeList, nil)
  89. }