111 lines
2.8 KiB
Go
111 lines
2.8 KiB
Go
|
package controller
|
||
|
|
||
|
import (
|
||
|
"service/api/errcode"
|
||
|
loginproto "service/api/proto/login/proto"
|
||
|
"service/app/mix/service"
|
||
|
"service/bizcommon/util"
|
||
|
"service/library/logger"
|
||
|
"service/library/mediafiller"
|
||
|
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
func ApiLoginByPswd(ctx *gin.Context) {
|
||
|
req := ctx.MustGet("client_req").(*loginproto.ApiLoginByPswdReq)
|
||
|
isEnabled, token, accountVO, ec := service.DefaultService.ApiLoginByPswd(ctx, req)
|
||
|
if ec != errcode.ErrCodeLoginSrvOk {
|
||
|
logger.Error("ApiLoginByPswd fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||
|
ReplyErrCodeMsg(ctx, ec)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
//填充媒体切片
|
||
|
mediafiller.FillEntity(ctx, accountVO.Avatar)
|
||
|
|
||
|
ReplyOk(ctx, &loginproto.ApiLoginData{
|
||
|
IsEnabled: isEnabled,
|
||
|
Token: token,
|
||
|
AccountVO: accountVO,
|
||
|
})
|
||
|
|
||
|
}
|
||
|
|
||
|
func ApiSetPassword(ctx *gin.Context) {
|
||
|
req := ctx.MustGet("client_req").(*loginproto.ApiSetPswdReq)
|
||
|
ec := service.DefaultService.ApiSetPassword(ctx, req)
|
||
|
if ec != errcode.ErrCodeLoginSrvOk {
|
||
|
logger.Error("ApiSetPassword fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||
|
ReplyErrCodeMsg(ctx, ec)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
ReplyOk(ctx, &loginproto.ApiSetPswdData{
|
||
|
ApiResult: true,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func ApiResetPassword(ctx *gin.Context) {
|
||
|
req := ctx.MustGet("client_req").(*loginproto.ApiResetPswdReq)
|
||
|
ec := service.DefaultService.ApiResetPassword(ctx, req)
|
||
|
if ec != errcode.ErrCodeLoginSrvOk {
|
||
|
logger.Error("ApiLoginByVeriCode fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||
|
ReplyErrCodeMsg(ctx, ec)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
ReplyOk(ctx, &loginproto.ApiResetPswdData{
|
||
|
ApiResult: true,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func ApiUpdatePassword(ctx *gin.Context) {
|
||
|
req := ctx.MustGet("client_req").(*loginproto.ApiUpdatePswdReq)
|
||
|
ec := service.DefaultService.ApiUpdatePassword(ctx, req)
|
||
|
if ec != errcode.ErrCodeLoginSrvOk {
|
||
|
logger.Error("ApiLoginByVeriCode fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||
|
ReplyErrCodeMsg(ctx, ec)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
ReplyOk(ctx, &loginproto.ApiUpdatePswdData{
|
||
|
ApiResult: true,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func ApiLoginByVeriCode(ctx *gin.Context) {
|
||
|
req := ctx.MustGet("client_req").(*loginproto.ApiLoginByVeriCodeReq)
|
||
|
isEnabled, token, accountVO, ec := service.DefaultService.ApiLoginByVeriCode(ctx, req)
|
||
|
if ec != errcode.ErrCodeLoginSrvOk {
|
||
|
logger.Error("ApiLoginByVeriCode fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||
|
ReplyErrCodeMsg(ctx, ec)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
//填充媒体切片
|
||
|
mediafiller.FillEntity(ctx, accountVO.Avatar)
|
||
|
|
||
|
ReplyOk(ctx, &loginproto.ApiLoginData{
|
||
|
IsEnabled: isEnabled,
|
||
|
Token: token,
|
||
|
AccountVO: accountVO,
|
||
|
})
|
||
|
|
||
|
}
|
||
|
|
||
|
func ApiLogout(ctx *gin.Context) {
|
||
|
req := ctx.MustGet("client_req").(*loginproto.ApiLogoutReq)
|
||
|
logoutData, ec := service.DefaultService.ApiLogout(ctx, req)
|
||
|
if ec != errcode.ErrCodeLoginSrvOk {
|
||
|
logger.Error("ApiLogout fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||
|
ReplyErrCodeMsg(ctx, ec)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
ReplyOk(ctx, logoutData)
|
||
|
}
|
||
|
|
||
|
func ApiValidate(ctx *gin.Context) {
|
||
|
ReplyOk(ctx, nil)
|
||
|
}
|