完成游戏人生账号绑定、解绑、绑定信息的接口开发
This commit is contained in:
@ -11,7 +11,7 @@ import (
|
||||
"server/internal/model/entity"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
utility "server/utility/encrypt"
|
||||
"server/utility/encrypt"
|
||||
"server/utility/jwt"
|
||||
)
|
||||
|
||||
@ -54,7 +54,7 @@ func checkAdmin() {
|
||||
return err
|
||||
}
|
||||
if !exist {
|
||||
password, err := utility.EncryptPassword("Aa123456")
|
||||
password, err := encrypt.EncryptPassword("Aa123456")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -91,7 +91,7 @@ func (s *sAdmin) Login(ctx context.Context, in *model.AdminLoginIn) (out *model.
|
||||
if err := dao.Admins.Ctx(ctx).Where(do.Admins{Username: in.Username}).Scan(&admin); err != nil {
|
||||
return nil, ecode.Fail.Sub("查询管理员失败")
|
||||
}
|
||||
if !utility.ComparePassword(admin.PasswordHash, in.Password) {
|
||||
if !encrypt.ComparePassword(admin.PasswordHash, in.Password) {
|
||||
return nil, ecode.Auth
|
||||
}
|
||||
value, err := dao.Roles.Ctx(ctx).WherePri(admin.RoleId).Fields(dao.Roles.Columns().Code).Value()
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
"server/internal/model/entity"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
utility "server/utility/encrypt"
|
||||
"server/utility/encrypt"
|
||||
"server/utility/jwt"
|
||||
"server/utility/snowid"
|
||||
)
|
||||
@ -65,7 +65,7 @@ func (s *sMerchantAdmin) Login(ctx context.Context, in *model.MerchantLoginIn) (
|
||||
if mAdmin[dao.MerchantAdmins.Columns().Status].Int() == consts.MerchantAdministratorDisable {
|
||||
return nil, ecode.Params.Sub("该用户已被禁用")
|
||||
}
|
||||
if !utility.ComparePassword(mAdmin[dao.MerchantAdmins.Columns().PasswordHash].String(), in.Password) {
|
||||
if !encrypt.ComparePassword(mAdmin[dao.MerchantAdmins.Columns().PasswordHash].String(), in.Password) {
|
||||
return nil, ecode.Params.Sub("密码错误")
|
||||
}
|
||||
value, err := dao.Roles.Ctx(ctx).WherePri(mAdmin[dao.MerchantAdmins.Columns().RoleId].Int()).Fields(dao.Roles.Columns().Code).Value()
|
||||
@ -145,7 +145,7 @@ func (s *sMerchantAdmin) Register(ctx context.Context, in *model.MerchantAdminRe
|
||||
if code.String() != in.Code {
|
||||
return nil, ecode.Fail.Sub("验证码错误")
|
||||
}
|
||||
hashPass, err := utility.EncryptPassword(in.Password)
|
||||
hashPass, err := encrypt.EncryptPassword(in.Password)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("密码加密失败")
|
||||
}
|
||||
|
||||
@ -8,8 +8,9 @@ import (
|
||||
"server/internal/model/do"
|
||||
"server/internal/model/entity"
|
||||
"server/internal/service"
|
||||
"server/utility/encrypt"
|
||||
|
||||
"server/utility/ecode"
|
||||
utility "server/utility/encrypt"
|
||||
"server/utility/jwt"
|
||||
)
|
||||
|
||||
@ -56,7 +57,7 @@ func (s *sStoreAdmin) Login(ctx context.Context, in *model.StoreAdminLoginIn) (o
|
||||
if one[dao.StoreAdmins.Columns().Status].Int() == consts.StoreAdminDisable {
|
||||
return nil, ecode.Params.Sub("该用户已被禁用")
|
||||
}
|
||||
if !utility.ComparePassword(one[dao.StoreAdmins.Columns().PasswordHash].String(), in.Password) {
|
||||
if !encrypt.ComparePassword(one[dao.StoreAdmins.Columns().PasswordHash].String(), in.Password) {
|
||||
return nil, ecode.Params.Sub("密码错误")
|
||||
}
|
||||
value, err := dao.Roles.Ctx(ctx).WherePri(one[dao.StoreAdmins.Columns().RoleId].Int()).Fields(dao.Roles.Columns().Code).Value()
|
||||
|
||||
@ -3,6 +3,7 @@ package internal
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/consts"
|
||||
"server/internal/dao"
|
||||
@ -11,6 +12,7 @@ import (
|
||||
"server/internal/model/entity"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
"server/utility/gamelife"
|
||||
"server/utility/jwt"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
@ -200,3 +202,41 @@ func (s *sUser) List(ctx context.Context, in *model.UserListIn) (out *model.User
|
||||
// 用于系统管理员、商户、门店查看用户列表, 展示用户最近的相关信息
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sUser) BoundUrl(ctx context.Context, in *model.UserBoundUrlIn) (out *model.UserBoundUrlOut, err error) {
|
||||
url, err := gamelife.GetGamelifeClient(ctx).GetUrl(ctx, in.PopenId, in.AppName, "", in.BindType, in.IsBound)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("获取绑定链接失败")
|
||||
}
|
||||
return &model.UserBoundUrlOut{
|
||||
Url: url,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sUser) UnBoundUrl(ctx context.Context, in *model.UserBoundUrlIn) (out *model.UserUnBoundUrlOut, err error) {
|
||||
url, err := gamelife.GetGamelifeClient(ctx).GetUrl(ctx, in.PopenId, in.AppName, in.Nickname, in.BindType, in.IsBound)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("获取绑定链接失败")
|
||||
}
|
||||
return &model.UserUnBoundUrlOut{
|
||||
Url: url,
|
||||
}, nil
|
||||
}
|
||||
func (s *sUser) BoundInfo(ctx context.Context, in *model.UserBoundInfoIn) (out *model.UserBoundInfoOut, err error) {
|
||||
url, err := gamelife.GetGamelifeClient(ctx).GetBound(ctx, in.PopenId)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("获取绑定信息失败")
|
||||
}
|
||||
var result model.UserBoundResult
|
||||
resp, err := resty.New().R().SetResult(&result).Post(url)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("获取绑定信息失败")
|
||||
}
|
||||
if resp.StatusCode() != 200 {
|
||||
return nil, ecode.Fail.Sub("获取绑定信息失败")
|
||||
}
|
||||
|
||||
return &model.UserBoundInfoOut{
|
||||
IsBound: result.Result,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user