A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
style: rename backyard auth function name
LinkinStarc59f48e69440
diff --git a/internal/repo/auth/auth.go b/internal/repo/auth/auth.goindex 46202980..61bd00c7 100644--- a/internal/repo/auth/auth.go+++ b/internal/repo/auth/auth.go@@ -17,6 +17,7 @@ type authRepo struct {data *data.Data}+// GetUserCacheInfo get user cache infofunc (ar *authRepo) GetUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error) {userInfoCache, err := ar.data.Cache.GetString(ctx, constant.UserTokenCacheKey+accessToken)if err != nil {@@ -30,6 +31,7 @@ func (ar *authRepo) GetUserCacheInfo(ctx context.Context, accessToken string) (ureturn userInfo, nil}+// GetUserStatus get user statusfunc (ar *authRepo) GetUserStatus(ctx context.Context, userID string) (userInfo *entity.UserCacheInfo, err error) {userInfoCache, err := ar.data.Cache.GetString(ctx, constant.UserStatusChangedCacheKey+userID)if err != nil {@@ -43,6 +45,7 @@ func (ar *authRepo) GetUserStatus(ctx context.Context, userID string) (userInforeturn userInfo, nil}+// RemoveUserStatus remove user statusfunc (ar *authRepo) RemoveUserStatus(ctx context.Context, userID string) (err error) {err = ar.data.Cache.Del(ctx, constant.UserStatusChangedCacheKey+userID)if err != nil {@@ -51,6 +54,7 @@ func (ar *authRepo) RemoveUserStatus(ctx context.Context, userID string) (err erreturn nil}+// SetUserCacheInfo set user cache infofunc (ar *authRepo) SetUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) (err error) {userInfoCache, err := json.Marshal(userInfo)if err != nil {@@ -64,16 +68,17 @@ func (ar *authRepo) SetUserCacheInfo(ctx context.Context, accessToken string, usreturn nil}+// RemoveUserCacheInfo remove user cache infofunc (ar *authRepo) RemoveUserCacheInfo(ctx context.Context, accessToken string) (err error) {err = ar.data.Cache.Del(ctx, constant.UserTokenCacheKey+accessToken)if err != nil {- err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()- return err+ return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}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)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()@@ -87,7 +92,8 @@ func (ar *authRepo) GetCmsUserCacheInfo(ctx context.Context, accessToken string)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)if err != nil {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),constant.AdminTokenCacheTime)if err != nil {- err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()- return err+ return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}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)if err != nil {- err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()- return err+ return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}return nil}// NewAuthRepo new repository-func NewAuthRepo(- data *data.Data,-) auth.AuthRepo {+func NewAuthRepo(data *data.Data) auth.AuthRepo {return &authRepo{data: data,}diff --git a/internal/service/auth/auth.go b/internal/service/auth/auth.goindex c7f4e712..e4fd9182 100644--- a/internal/service/auth/auth.go+++ b/internal/service/auth/auth.go@@ -15,9 +15,9 @@ type AuthRepo interface {RemoveUserCacheInfo(ctx context.Context, accessToken string) (err error)GetUserStatus(ctx context.Context, userID string) (userInfo *entity.UserCacheInfo, err error)RemoveUserStatus(ctx context.Context, userID string) (err error)- GetCmsUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error)- SetCmsUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) error- RemoveCmsUserCacheInfo(ctx context.Context, accessToken string) (err error)+ GetBackyardUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error)+ SetBackyardUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) error+ RemoveBackyardUserCacheInfo(ctx context.Context, accessToken string) (err error)}// AuthService kit service@@ -75,14 +75,14 @@ func (as *AuthService) RemoveUserCacheInfo(ctx context.Context, accessToken stri//cmsfunc (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) {- err = as.authRepo.SetCmsUserCacheInfo(ctx, accessToken, userInfo)+ err = as.authRepo.SetBackyardUserCacheInfo(ctx, accessToken, userInfo)return err}func (as *AuthService) RemoveCmsUserCacheInfo(ctx context.Context, accessToken string) (err error) {- return as.authRepo.RemoveCmsUserCacheInfo(ctx, accessToken)+ return as.authRepo.RemoveBackyardUserCacheInfo(ctx, accessToken)}