This commit is contained in:
2026-01-12 16:43:08 +08:00
parent dc747139c9
commit 3c6e2683f5
110 changed files with 9630 additions and 481 deletions

View File

@@ -0,0 +1,57 @@
package agent
import (
"context"
"ycc-server/common/xerr"
"github.com/pkg/errors"
"ycc-server/app/main/api/internal/svc"
"ycc-server/app/main/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetWhitelistFeaturesLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetWhitelistFeaturesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWhitelistFeaturesLogic {
return &GetWhitelistFeaturesLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetWhitelistFeaturesLogic) GetWhitelistFeatures(req *types.GetWhitelistFeaturesReq) (resp *types.GetWhitelistFeaturesResp, err error) {
// 使用SelectBuilder查询所有feature然后筛选whitelist_price > 0的
// 注意系统会自动处理del_state不需要手动添加
builder := l.svcCtx.FeatureModel.SelectBuilder().
Where("whitelist_price > 0").
OrderBy("name ASC")
features, err := l.svcCtx.FeatureModel.FindAll(l.ctx, builder, "")
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询feature列表失败, %v", err)
}
// 组装响应直接使用feature的WhitelistPrice字段
list := make([]types.WhitelistFeatureItem, 0, len(features))
for _, f := range features {
if f.WhitelistPrice > 0 {
list = append(list, types.WhitelistFeatureItem{
FeatureId: f.Id,
FeatureApiId: f.ApiId,
FeatureName: f.Name,
WhitelistPrice: f.WhitelistPrice,
})
}
}
return &types.GetWhitelistFeaturesResp{
List: list,
}, nil
}