作者 tangxvhui

手机端获取用户信息

package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 员工绩效 手机端登录,来源于能力展示app
func (service *AuthService) MobileLogin(param *command.MobileLoginCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if errStart := transactionContext.StartTransaction(); errStart != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 统一用户中心登录
authCodeReply, err := factory.UCenterApi().AppAuthCode(param.Credentials, param.Cuid, param.Cid)
if err != nil || !authCodeReply.IsOk() {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统一用户中心认证失败")
}
// 用户权限校验
// 登录平台ID,28-绩效管理后台 29-员工绩效
userAuthReply, err := factory.BusinessAdminApi().GetUserAuth(int64(param.Muid), constant.PLATFORM_FONT_ID)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户鉴权失败")
}
if !userAuthReply.IsOk() {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, userAuthReply.Message())
}
//获取公司数据
companyRepository := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
company, err := companyRepository.FindOne(map[string]interface{}{
"id": param.Cid,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据失败")
}
userRepository := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
user, err := userRepository.FindOne(map[string]interface{}{
"id": param.Muid,
"companyId": company.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户数据失败")
}
if user.Status != domain.UserStatusEnable {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户被禁用")
}
userAuth := &domain.UserAuth{
UserId: user.Id,
CompanyId: user.CompanyId,
CompanyName: company.Name,
Phone: user.Account,
PlatformId: constant.PLATFORM_FONT_ID,
Name: user.Name,
AdminType: user.AdminType,
}
accessToken, err := userAuth.CreateAccessToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
result := map[string]interface{}{
"access": map[string]interface{}{
"accessToken": accessToken,
"expiresIn": domain.JWTExpiresSecond,
},
}
return result, nil
}
// Authorize 移动端授权登录
func (srv *AuthService) Authorize(param *command.AuthorizeCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if errStart := transactionContext.StartTransaction(); errStart != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 统一用户中心登录
authCodeReply, err := factory.UCenterApi().AppAuthCode(param.Credentials, param.Cuid, param.Cid)
if err != nil || !authCodeReply.IsOk() {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统一用户中心认证失败")
}
// 用户权限校验
// 登录平台ID, 29-员工绩效
userAuthReply, err := factory.BusinessAdminApi().GetUserAuth(int64(param.Muid), constant.PLATFORM_FONT_ID)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户鉴权失败")
}
if !userAuthReply.IsOk() {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, userAuthReply.Message())
}
//获取公司数据
companyRepository := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
company, err := companyRepository.FindOne(map[string]interface{}{
"id": param.Cid,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据失败")
}
userRepository := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
user, err := userRepository.FindOne(map[string]interface{}{
"id": param.Muid,
"companyId": company.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户数据失败")
}
if user.Status != domain.UserStatusEnable {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户被禁用")
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
userAuth := &domain.UserAuth{
UserId: user.Id,
CompanyId: user.CompanyId,
CompanyName: company.Name,
Phone: user.Account,
PlatformId: constant.PLATFORM_FONT_ID,
Name: user.Name,
AdminType: user.AdminType,
}
accessToken, err := userAuth.CreateAccessToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
respData := map[string]interface{}{
"authCode": accessToken,
}
return respData, nil
}
func (srv *AuthService) AccessToken(param *command.AccessTokenCommand) (map[string]interface{}, error) {
userAuth := domain.UserAuth{}
_, err := userAuth.ParseAccessToken(param.AuthCode)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "authcode 失效")
}
accessToken, err := userAuth.CreateAccessToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成 accessToken 失败")
}
refreshToken, err := userAuth.CreateRefreshToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成 refreshToken 解析失败")
}
respData := map[string]interface{}{
"refreshToken": refreshToken,
"accessToken": accessToken,
"expiresIn": domain.JWTExpiresSecond,
}
return respData, nil
}
// 刷新token
func (srv *AuthService) RefreshToken(param *command.RefreshTokenCommand) (map[string]interface{}, error) {
userAuth := domain.UserAuth{}
_, err := userAuth.ParseAccessToken(param.RefreshToken)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "refresh_token 失效")
}
accessToken, err := userAuth.CreateAccessToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成 accessToken 失败")
}
refreshToken, err := userAuth.CreateRefreshToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成 refreshToken 解析失败")
}
respData := map[string]interface{}{
"refreshToken": refreshToken,
"accessToken": accessToken,
"expiresIn": domain.JWTExpiresSecond,
}
return respData, nil
}
func (srv *AuthService) UserInfo(param *command.GetMeInfo) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if errStart := transactionContext.StartTransaction(); errStart != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
companyRepository := factory.CreateCompanyRepository(map[string]interface{}{"transactionContext": transactionContext})
depRepository := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext})
userData, err := userRepository.FindOne(map[string]interface{}{
"id": param.UserId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工数据"+err.Error())
}
companyData, err := companyRepository.FindOne(map[string]interface{}{
"id": param.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据"+err.Error())
}
var departmentList []*domain.Department
if len(userData.DepartmentId) > 0 {
_, departmentList, err = depRepository.Find(map[string]interface{}{"ids": userData.DepartmentId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门数据"+err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
respData := map[string]interface{}{
"user": map[string]interface{}{
"uid": userData.Id,
"muid": userData.Id,
"uname": userData.Name,
"phone": userData.Account,
"image": map[string]interface{}{
"path": userData.AvatarUrl,
"w": 0,
"h": 0,
},
"company": map[string]interface{}{
"id": companyData.Id,
"name": companyData.Name,
},
"dep": map[string]interface{}{
"id": 0,
"name": "",
},
},
}
if len(departmentList) > 0 {
respData["dep"] = map[string]interface{}{
"id": departmentList[0].Id,
"name": departmentList[0].Name,
}
}
return respData, nil
}
... ...
... ... @@ -6,7 +6,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
... ... @@ -85,80 +84,6 @@ func (service *AuthService) Login(loginCommand *command.LoginCommand) (interface
}, nil
}
// 员工绩效 手机端登录,来源于能力展示app
func (service *AuthService) MobileLogin(param *command.MobileLoginCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if errStart := transactionContext.StartTransaction(); errStart != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 统一用户中心登录
authCodeReply, err := factory.UCenterApi().AppAuthCode(param.Credentials, param.Cuid, param.Cid)
if err != nil || !authCodeReply.IsOk() {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统一用户中心认证失败")
}
// 用户权限校验
// 登录平台ID,28-绩效管理后台 29-员工绩效
userAuthReply, err := factory.BusinessAdminApi().GetUserAuth(int64(param.Muid), constant.PLATFORM_FONT_ID)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户鉴权失败")
}
if !userAuthReply.IsOk() {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, userAuthReply.Message())
}
//获取公司数据
companyRepository := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
company, err := companyRepository.FindOne(map[string]interface{}{
"id": param.Cid,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据失败")
}
userRepository := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
user, err := userRepository.FindOne(map[string]interface{}{
"id": param.Muid,
"companyId": company.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户数据失败")
}
if user.Status != domain.UserStatusEnable {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户被禁用")
}
userAuth := &domain.UserAuth{
UserId: user.Id,
CompanyId: user.CompanyId,
CompanyName: company.Name,
Phone: user.Account,
PlatformId: constant.PLATFORM_FONT_ID,
Name: user.Name,
AdminType: user.AdminType,
}
accessToken, err := userAuth.CreateAccessToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
result := map[string]interface{}{
"access": map[string]interface{}{
"accessToken": accessToken,
"expiresIn": domain.JWTExpiresSecond,
},
}
return result, nil
}
// 获取我的
func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interface{}, error) {
... ... @@ -229,119 +154,3 @@ func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interfa
"user": info,
}, nil
}
// Authorize 移动端授权登录
func (srv *AuthService) Authorize(param *command.AuthorizeCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if errStart := transactionContext.StartTransaction(); errStart != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 统一用户中心登录
authCodeReply, err := factory.UCenterApi().AppAuthCode(param.Credentials, param.Cuid, param.Cid)
if err != nil || !authCodeReply.IsOk() {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统一用户中心认证失败")
}
// 用户权限校验
// 登录平台ID, 29-员工绩效
userAuthReply, err := factory.BusinessAdminApi().GetUserAuth(int64(param.Muid), constant.PLATFORM_FONT_ID)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户鉴权失败")
}
if !userAuthReply.IsOk() {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, userAuthReply.Message())
}
//获取公司数据
companyRepository := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
company, err := companyRepository.FindOne(map[string]interface{}{
"id": param.Cid,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据失败")
}
userRepository := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
user, err := userRepository.FindOne(map[string]interface{}{
"id": param.Muid,
"companyId": company.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户数据失败")
}
if user.Status != domain.UserStatusEnable {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户被禁用")
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
userAuth := &domain.UserAuth{
UserId: user.Id,
CompanyId: user.CompanyId,
CompanyName: company.Name,
Phone: user.Account,
PlatformId: constant.PLATFORM_FONT_ID,
Name: user.Name,
AdminType: user.AdminType,
}
accessToken, err := userAuth.CreateAccessToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
respData := map[string]interface{}{
"authCode": accessToken,
}
return respData, nil
}
func (srv *AuthService) AccessToken(param *command.AccessTokenCommand) (map[string]interface{}, error) {
userAuth := domain.UserAuth{}
_, err := userAuth.ParseAccessToken(param.AuthCode)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "authcode 失效")
}
accessToken, err := userAuth.CreateAccessToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成 accessToken 失败")
}
refreshToken, err := userAuth.CreateRefreshToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成 refreshToken 解析失败")
}
respData := map[string]interface{}{
"refreshToken": refreshToken,
"accessToken": accessToken,
"expiresIn": domain.JWTExpiresSecond,
}
return respData, nil
}
func (srv *AuthService) RefreshToken(param *command.RefreshTokenCommand) (map[string]interface{}, error) {
userAuth := domain.UserAuth{}
_, err := userAuth.ParseAccessToken(param.RefreshToken)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "refresh_token 失效")
}
accessToken, err := userAuth.CreateAccessToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成 accessToken 失败")
}
refreshToken, err := userAuth.CreateRefreshToken()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成 refreshToken 解析失败")
}
respData := map[string]interface{}{
"refreshToken": refreshToken,
"accessToken": accessToken,
"expiresIn": domain.JWTExpiresSecond,
}
return respData, nil
}
... ...
package controllers
import (
"errors"
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/service"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
... ... @@ -50,7 +53,7 @@ func (controller *AuthController) Authorize() {
controller.Response(resp, err)
}
// Login 获取token
// AccessToken 手机端 获取token
func (controller *AuthController) AccessToken() {
authService := &service.AuthService{}
loginCommand := &command.AccessTokenCommand{}
... ... @@ -67,3 +70,28 @@ func (controller *AuthController) RefreshToken() {
resp, err := authService.RefreshToken(loginCommand)
controller.Response(resp, err)
}
// 手机端 获取个人信息
func (controller *AuthController) UserInfos() {
tokenStr := controller.Ctx.Input.Header("x-mmm-accesstoken")
if tokenStr == "" { //没有带token
controller.Response(nil, errors.New("token 错误"))
return
}
userAuth, err := (&domain.UserAuth{}).ParseAccessToken(tokenStr)
if err != nil || userAuth.UserId <= 0 {
controller.Response(nil, errors.New("token 错误"))
return
}
if userAuth.PlatformId != constant.PLATFORM_FONT_ID {
controller.Response(nil, errors.New("token 错误"))
return
}
authService := &service.AuthService{}
param := &command.GetMeInfo{
UserId: userAuth.UserId,
CompanyId: userAuth.CompanyId,
}
resp, err := authService.UserInfo(param)
controller.Response(resp, err)
}
... ...
package middlewares
// func setUserId(userId int64, ctx *context.Context) {
// ctx.Input.SetData("_UserId", userId)
// }
//
//import (
// "github.com/beego/beego/v2/server/web/context"
//)
//
//func setUserId(userId int64, ctx *context.Context) {
// ctx.Input.SetData("_UserId", userId)
//}
//
//func GetUserId(ctx *context.Context) int64 {
// userId := ctx.Input.GetData("_UserId")
// return userId.(int64)
//}
//
//func setCompanyId(companyId int64, ctx *context.Context) {
// ctx.Input.SetData("_CompanyId", companyId)
//}
//
//func GetCompanyId(ctx *context.Context) int64 {
// companyId := ctx.Input.GetData("_CompanyId")
// return companyId.(int64)
//}
//
//func setCompanyType(companyId int, ctx *context.Context) {
// ctx.Input.SetData("_CompanyType", companyId)
//}
// func GetUserId(ctx *context.Context) int64 {
// userId := ctx.Input.GetData("_UserId")
// return userId.(int64)
// }
//
//func GetCompanyType(ctx *context.Context) int {
// companyId := ctx.Input.GetData("_CompanyType")
// return companyId.(int)
//}
// func setCompanyId(companyId int64, ctx *context.Context) {
// ctx.Input.SetData("_CompanyId", companyId)
// }
//
//func invalidOrExpired(ctx *context.Context) {
// resp := map[string]interface{}{
// "code": 902,
// "msg": "Authorization过期或无效,需要进行重新获取令牌",
// func GetCompanyId(ctx *context.Context) int64 {
// companyId := ctx.Input.GetData("_CompanyId")
// return companyId.(int64)
// }
// _ = ctx.Output.JSON(resp, false, false)
//}
//
//func CheckToken() func(ctx *context.Context) {
// return func(ctx *context.Context) {
// tokenStr := ctx.Input.Header("x-mmm-accesstoken")
// if tokenStr == "" { //没有带token
// invalidOrExpired(ctx)
// return
// }
// func setCompanyType(companyId int, ctx *context.Context) {
// ctx.Input.SetData("_CompanyType", companyId)
// }
//
// //userServe := service.UserService{}
// //userTk, err := userServe.ValidLoginToken(tokenStr)
// //if err != nil {
// // invalidOrExpired(ctx)
// // return
// //}
// //setUserId(userTk.UserId, ctx)
// //setCompanyId(userTk.CompanyId, ctx)
// //setCompanyType(userTk.CompanyType, ctx)
// func GetCompanyType(ctx *context.Context) int {
// companyId := ctx.Input.GetData("_CompanyType")
// return companyId.(int)
// }
//}
// func invalidOrExpired(ctx *context.Context) {
// resp := map[string]interface{}{
// "code": 902,
// "msg": "Authorization过期或无效,需要进行重新获取令牌",
// }
// _ = ctx.Output.JSON(resp, false, false)
// }
// // 适配手机端的token 处理
// func CheckTokenForApp() func(ctx *context.Context) {
// return func(ctx *context.Context) {
// tokenStr := ctx.Input.Header("x-mmm-accesstoken")
// if tokenStr == "" { //没有带token
// invalidOrExpired(ctx)
// return
// }
// userAuth, err := (&domain.UserAuth{}).ParseAccessToken(tokenStr)
// if err != nil || userAuth.UserId <= 0 {
// forbidden(ctx)
// return
// }
// if userAuth.PlatformId != constant.PLATFORM_FONT_ID {
// forbidden(ctx)
// return
// }
// ctx.Input.SetData(domain.UserAuth{}, userAuth)
// }
// }
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"
)
func init() {
//手机模块登录-旧
web.Router("/login/mobile", &controllers.AuthController{}, "Post:MobileLogin")
{
//手机模块登录-新
web.CtrlPost("/v1/auth/authorize", (*controllers.AuthController).Authorize)
web.CtrlPost("/v1/auth/accessToken", (*controllers.AuthController).AccessToken)
web.CtrlPost("/v1/auth/refreshToken", (*controllers.AuthController).RefreshToken)
}
// 手机端登录后获取用户信息
web.CtrlPost("/v2/user/userInfo", (*controllers.AuthController).UserInfos)
}
... ...
... ... @@ -8,8 +8,6 @@ import (
func init() {
web.Router("/login", &controllers.AuthController{}, "Post:Login")
//手机模块登录-旧
web.Router("/login/mobile", &controllers.AuthController{}, "Post:MobileLogin")
web.InsertFilter("/auth/admin/*", web.BeforeExec, middlewares.CheckAdminToken())
web.Router("/auth/admin/user", &controllers.AuthController{}, "Get:User")
... ... @@ -17,11 +15,4 @@ func init() {
web.InsertFilter("/auth/font/*", web.BeforeExec, middlewares.CheckFontToken())
web.Router("/auth/font/user", &controllers.AuthController{}, "Get:User")
{
//手机模块登录-新
web.CtrlPost("/v1/auth/authorize", (*controllers.AuthController).Authorize)
web.CtrlPost("/v1/auth/accessToken", (*controllers.AuthController).AccessToken)
web.CtrlPost("/v1/auth/refreshToken", (*controllers.AuthController).RefreshToken)
}
}
... ...
... ... @@ -16,4 +16,5 @@ func init() {
web.NSRouter("/import-parent", &controllers.UserController{}, "Post:ImportParentUser"), // 直接上级导入
)
web.AddNamespace(ns)
}
... ...