41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_service/internal/logic/rankings"
|
|
|
|
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_service/internal/svc"
|
|
"gitea.youtukeji.com.cn/youtu/youtu_grpc/app/ranking_service/ranking"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type RemoveRankingLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewRemoveRankingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveRankingLogic {
|
|
return &RemoveRankingLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *RemoveRankingLogic) RemoveRanking(in *ranking.RemoveRankingRequest) (*ranking.BaseResult, error) {
|
|
cacheKey := rankings.GetRankingsCacheKey(in.AppId, in.Type)
|
|
err := l.svcCtx.RedisRanking.Remove(l.ctx, cacheKey)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
gs := l.svcCtx.Query.GameScore
|
|
_, err = gs.WithContext(l.ctx).Where(gs.AppAccount.Eq(in.AppId), gs.T.Eq(in.Type)).Delete()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &ranking.BaseResult{}, nil
|
|
}
|