mirror of https://gitee.com/answerdev/answer.git
style: rename backyard auth function name
This commit is contained in:
parent
1b206b4260
commit
c59f48e694
|
@ -17,6 +17,7 @@ type authRepo struct {
|
||||||
data *data.Data
|
data *data.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserCacheInfo get user cache info
|
||||||
func (ar *authRepo) GetUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error) {
|
func (ar *authRepo) GetUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error) {
|
||||||
userInfoCache, err := ar.data.Cache.GetString(ctx, constant.UserTokenCacheKey+accessToken)
|
userInfoCache, err := ar.data.Cache.GetString(ctx, constant.UserTokenCacheKey+accessToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -30,6 +31,7 @@ func (ar *authRepo) GetUserCacheInfo(ctx context.Context, accessToken string) (u
|
||||||
return userInfo, nil
|
return userInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserStatus get user status
|
||||||
func (ar *authRepo) GetUserStatus(ctx context.Context, userID string) (userInfo *entity.UserCacheInfo, err error) {
|
func (ar *authRepo) GetUserStatus(ctx context.Context, userID string) (userInfo *entity.UserCacheInfo, err error) {
|
||||||
userInfoCache, err := ar.data.Cache.GetString(ctx, constant.UserStatusChangedCacheKey+userID)
|
userInfoCache, err := ar.data.Cache.GetString(ctx, constant.UserStatusChangedCacheKey+userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -43,6 +45,7 @@ func (ar *authRepo) GetUserStatus(ctx context.Context, userID string) (userInfo
|
||||||
return userInfo, nil
|
return userInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveUserStatus remove user status
|
||||||
func (ar *authRepo) RemoveUserStatus(ctx context.Context, userID string) (err error) {
|
func (ar *authRepo) RemoveUserStatus(ctx context.Context, userID string) (err error) {
|
||||||
err = ar.data.Cache.Del(ctx, constant.UserStatusChangedCacheKey+userID)
|
err = ar.data.Cache.Del(ctx, constant.UserStatusChangedCacheKey+userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -51,6 +54,7 @@ func (ar *authRepo) RemoveUserStatus(ctx context.Context, userID string) (err er
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetUserCacheInfo set user cache info
|
||||||
func (ar *authRepo) SetUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) (err error) {
|
func (ar *authRepo) SetUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) (err error) {
|
||||||
userInfoCache, err := json.Marshal(userInfo)
|
userInfoCache, err := json.Marshal(userInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -64,16 +68,17 @@ func (ar *authRepo) SetUserCacheInfo(ctx context.Context, accessToken string, us
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveUserCacheInfo remove user cache info
|
||||||
func (ar *authRepo) RemoveUserCacheInfo(ctx context.Context, accessToken string) (err error) {
|
func (ar *authRepo) RemoveUserCacheInfo(ctx context.Context, accessToken string) (err error) {
|
||||||
err = ar.data.Cache.Del(ctx, constant.UserTokenCacheKey+accessToken)
|
err = ar.data.Cache.Del(ctx, constant.UserTokenCacheKey+accessToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ar *authRepo) GetCmsUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error) {
|
// GetBackyardUserCacheInfo get backyard user cache info
|
||||||
|
func (ar *authRepo) GetBackyardUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error) {
|
||||||
userInfoCache, err := ar.data.Cache.GetString(ctx, constant.AdminTokenCacheKey+accessToken)
|
userInfoCache, err := ar.data.Cache.GetString(ctx, constant.AdminTokenCacheKey+accessToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
||||||
|
@ -87,7 +92,8 @@ func (ar *authRepo) GetCmsUserCacheInfo(ctx context.Context, accessToken string)
|
||||||
return userInfo, nil
|
return userInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ar *authRepo) SetCmsUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) (err error) {
|
// SetBackyardUserCacheInfo set backyard user cache info
|
||||||
|
func (ar *authRepo) SetBackyardUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) (err error) {
|
||||||
userInfoCache, err := json.Marshal(userInfo)
|
userInfoCache, err := json.Marshal(userInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -96,25 +102,22 @@ func (ar *authRepo) SetCmsUserCacheInfo(ctx context.Context, accessToken string,
|
||||||
err = ar.data.Cache.SetString(ctx, constant.AdminTokenCacheKey+accessToken, string(userInfoCache),
|
err = ar.data.Cache.SetString(ctx, constant.AdminTokenCacheKey+accessToken, string(userInfoCache),
|
||||||
constant.AdminTokenCacheTime)
|
constant.AdminTokenCacheTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ar *authRepo) RemoveCmsUserCacheInfo(ctx context.Context, accessToken string) (err error) {
|
// RemoveBackyardUserCacheInfo remove backyard user cache info
|
||||||
|
func (ar *authRepo) RemoveBackyardUserCacheInfo(ctx context.Context, accessToken string) (err error) {
|
||||||
err = ar.data.Cache.Del(ctx, constant.AdminTokenCacheKey+accessToken)
|
err = ar.data.Cache.Del(ctx, constant.AdminTokenCacheKey+accessToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAuthRepo new repository
|
// NewAuthRepo new repository
|
||||||
func NewAuthRepo(
|
func NewAuthRepo(data *data.Data) auth.AuthRepo {
|
||||||
data *data.Data,
|
|
||||||
) auth.AuthRepo {
|
|
||||||
return &authRepo{
|
return &authRepo{
|
||||||
data: data,
|
data: data,
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,9 @@ type AuthRepo interface {
|
||||||
RemoveUserCacheInfo(ctx context.Context, accessToken string) (err error)
|
RemoveUserCacheInfo(ctx context.Context, accessToken string) (err error)
|
||||||
GetUserStatus(ctx context.Context, userID string) (userInfo *entity.UserCacheInfo, err error)
|
GetUserStatus(ctx context.Context, userID string) (userInfo *entity.UserCacheInfo, err error)
|
||||||
RemoveUserStatus(ctx context.Context, userID string) (err error)
|
RemoveUserStatus(ctx context.Context, userID string) (err error)
|
||||||
GetCmsUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error)
|
GetBackyardUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error)
|
||||||
SetCmsUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) error
|
SetBackyardUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) error
|
||||||
RemoveCmsUserCacheInfo(ctx context.Context, accessToken string) (err error)
|
RemoveBackyardUserCacheInfo(ctx context.Context, accessToken string) (err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthService kit service
|
// AuthService kit service
|
||||||
|
@ -75,14 +75,14 @@ func (as *AuthService) RemoveUserCacheInfo(ctx context.Context, accessToken stri
|
||||||
//cms
|
//cms
|
||||||
|
|
||||||
func (as *AuthService) GetCmsUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error) {
|
func (as *AuthService) GetCmsUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error) {
|
||||||
return as.authRepo.GetCmsUserCacheInfo(ctx, accessToken)
|
return as.authRepo.GetBackyardUserCacheInfo(ctx, accessToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *AuthService) SetCmsUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) (err error) {
|
func (as *AuthService) SetCmsUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) (err error) {
|
||||||
err = as.authRepo.SetCmsUserCacheInfo(ctx, accessToken, userInfo)
|
err = as.authRepo.SetBackyardUserCacheInfo(ctx, accessToken, userInfo)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *AuthService) RemoveCmsUserCacheInfo(ctx context.Context, accessToken string) (err error) {
|
func (as *AuthService) RemoveCmsUserCacheInfo(ctx context.Context, accessToken string) (err error) {
|
||||||
return as.authRepo.RemoveCmsUserCacheInfo(ctx, accessToken)
|
return as.authRepo.RemoveBackyardUserCacheInfo(ctx, accessToken)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue