This commit is contained in:
shaoyongjun 2024-05-15 17:29:08 +08:00
parent 1de6800707
commit 699877a969
3 changed files with 8 additions and 1 deletions
common/config
infrastructure/repository
service

@ -15,7 +15,7 @@ rpc:
# mysql
mysql:
logSql: true
dsn: uc:zELLqwk2hBp8QyJgEtH5YGc6WKMS3dXP@tcp(43.133.218.116:10119)/user_center?charset=utf8mb4&parseTime=True&loc=Local
dsn: uc:zELLqwk2hBp8QyJgEtH5YGc6WKMS3dXP@tcp(123.207.198.132:10119)/user_center?charset=utf8mb4&parseTime=True&loc=Local
maxIdleConn: 4
maxOpenConn: 4
connMaxLifetime: 3000

@ -33,6 +33,11 @@ type gUserRepositoryImpl struct {
// FindByAccount 根据 account 和 pwd 查询用户
func (gUserRepositoryImpl) FindByAccount(ctx context.Context, account string) *AccountDO {
//验证参数
if account == "" {
}
db, ok := ctx.Value("db").(*gorm.DB)
if !ok {
db = Db

@ -49,6 +49,7 @@ func (l login) Register(ctx context.Context, req dto.ThirdRegisterReq) error {
}
func (l login) Login(ctx context.Context, req dto.ThirdLoginReq) (string, error) {
//1. 验证账号密码
h := sha256.Sum256([]byte(req.Password))
passHash := hex.EncodeToString(h[:])
@ -79,6 +80,7 @@ func (l login) Login(ctx context.Context, req dto.ThirdLoginReq) (string, error)
gUserToken.AccessToken = thirdUserToken.AccessToken
gUserToken.ExpireTime = thirdUserToken.ExpireTime
repository.GUserToken.UpdateUserLoginToken(ctx, gUserToken)
return l.GenAccessToken(gUserToken), nil
}