package client import ( "hudongzhuanjia/controllers" "hudongzhuanjia/libs/jwt" "hudongzhuanjia/models" "hudongzhuanjia/utils/code" "hudongzhuanjia/utils/define" ) type AreaCtl struct { controllers.BaseCtl } // 登陆 func (t *AreaCtl) Login() { activityId := t.MustGetInt("activity_id") username := t.MustGet("username") password := t.MustGet("password") activity := &models.Activity{} exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") area := &models.AreaStore{} exist, err = area.Login(activityId, username, password) t.CheckErr(err) t.Assert(exist, code.MSG_ERR_Authority, "用户信息异常") token, err := jwt.GenJwtToken(define.TYPE_AREAADMIN, area.Id, area.CustomerId, area.CustomerId, area.Id, area.ActivityId) t.CheckErr(err) t.SetSession(define.TOKEN, token) t.JSON(map[string]interface{}{ "token": token, "area": area, }) }