package controller import ( "github.com/gin-gonic/gin" "kefu/models" "kefu/types" ) //内部接口生成token func InternalToken(c *gin.Context) { username := c.Query("account") if username == "" { c.JSON(200, gin.H{ "code": types.ApiCode.ACCOUNT_NO_EXIST, "msg": types.ApiCode.GetMessage(types.ApiCode.ACCOUNT_NO_EXIST), }) return } user := &models.User{ Name: username, } result := user.GetOneUser("*") if result.ID == 0 { c.JSON(200, gin.H{ "code": types.ApiCode.ACCOUNT_NO_EXIST, "msg": types.ApiCode.GetMessage(types.ApiCode.ACCOUNT_NO_EXIST), }) return } token := GenUserToken(result) c.JSON(200, gin.H{ "code": types.ApiCode.SUCCESS, "msg": types.ApiCode.GetMessage(types.ApiCode.SUCCESS), "result": gin.H{ "token": token, }, }) }