4 changed files with 62 additions and 22 deletions
-
37controllers/client/area.go
-
15models/area_store.go
-
11models/customer.go
-
1utils/define/define.go
@ -0,0 +1,37 @@ |
|||
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, |
|||
}) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue