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

44 regels
1.0 KiB

  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "applet/app/svc"
  7. "applet/app/utils"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func Login(c *gin.Context) {
  11. r := new(md.LoginResponse)
  12. requestBody := new(md.FastLoginRequestBody)
  13. if err := c.ShouldBindJSON(&requestBody); err != nil {
  14. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  15. return
  16. }
  17. user, _ := db.UserFindByMobileAll(svc.MasterDb(c), requestBody.Mobile)
  18. if user == nil {
  19. e.OutErr(c, 400, e.NewErr(400, "账号不存在"))
  20. return
  21. }
  22. if user.Password != utils.Md5(requestBody.Password) {
  23. e.OutErr(c, 400, e.NewErr(400, "密码不正确"))
  24. return
  25. }
  26. userParty, _ := db.UserThirdPartyFindByID(svc.MasterDb(c), user.Uid)
  27. if userParty == nil || userParty.IsAgent == 0 {
  28. e.OutErr(c, 400, e.NewErr(400, "请联系平台成为代理"))
  29. return
  30. }
  31. if err := svc.FastLoginUserExist(c, r, requestBody); err != nil {
  32. if e.ErrorIsAccountBan(err) {
  33. e.OutErr(c, e.ERR_USER_IS_BAN, err)
  34. return
  35. }
  36. e.OutErr(c, 400, err)
  37. return
  38. }
  39. e.OutSuc(c, r, nil)
  40. return
  41. }