互动
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.

37 lines
945 B

  1. package client
  2. import (
  3. "hudongzhuanjia/controllers"
  4. "hudongzhuanjia/libs/jwt"
  5. "hudongzhuanjia/models"
  6. "hudongzhuanjia/utils/code"
  7. "hudongzhuanjia/utils/define"
  8. )
  9. type AreaCtl struct {
  10. controllers.BaseCtl
  11. }
  12. // 登陆
  13. func (t *AreaCtl) Login() {
  14. activityId := t.MustGetInt("activity_id")
  15. username := t.MustGet("username")
  16. password := t.MustGet("password")
  17. activity := &models.Activity{}
  18. exist, err := models.Get(activity, activityId)
  19. t.CheckErr(err)
  20. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  21. area := &models.AreaStore{}
  22. exist, err = area.Login(activityId, username, password)
  23. t.CheckErr(err)
  24. t.Assert(exist, code.MSG_ERR_Authority, "用户信息异常")
  25. token, err := jwt.GenJwtToken(define.TYPE_AREAADMIN, area.Id, area.CustomerId, area.CustomerId, area.Id, area.ActivityId)
  26. t.CheckErr(err)
  27. t.SetSession(define.TOKEN, token)
  28. t.JSON(map[string]interface{}{
  29. "token": token,
  30. "area": area,
  31. })
  32. }