update: 更新模型列表查询接口以支持私有化过滤

This commit is contained in:
2026-05-12 14:08:29 +08:00
parent 37d3461983
commit adf1d0ae6e
4 changed files with 16 additions and 8 deletions

View File

@@ -89,7 +89,7 @@ func (s *modelService) Get(ctx context.Context, id int64) (*entity.AsynchModel,
return model, nil
}
func (s *modelService) List(ctx context.Context, pageNum, pageSize int, modelNameLike string, modelType int) (list []*entity.AsynchModel, total int64, err error) {
func (s *modelService) List(ctx context.Context, pageNum, pageSize int, req *dto.ListModelReq) (list []*entity.AsynchModel, total int64, err error) {
isSuperAdmin, err := IsSuperAdmin(ctx)
if err != nil {
return nil, 0, err
@@ -103,9 +103,9 @@ func (s *modelService) List(ctx context.Context, pageNum, pageSize int, modelNam
var count int64
if isSuperAdmin {
models, count, err = dao.Model.List(ctx, pageNum, pageSize, modelNameLike, modelType)
models, count, err = dao.Model.List(ctx, pageNum, pageSize, req.ModelName, req.ModelType, req.IsPrivate)
} else {
models, count, err = s.getModelsWithDedup(ctx, user.UserName, pageNum, pageSize, modelNameLike, modelType)
models, count, err = s.getModelsWithDedup(ctx, user.UserName, pageNum, pageSize, req.ModelName, req.ModelType, req.IsPrivate)
}
if err != nil {
return nil, 0, err
@@ -122,9 +122,9 @@ func (s *modelService) List(ctx context.Context, pageNum, pageSize int, modelNam
}
// getModelsWithDedup 获取普通用户的模型列表并去重
func (s *modelService) getModelsWithDedup(ctx context.Context, creator string, pageNum, pageSize int, modelNameLike string, modelType int) (list []*entity.AsynchModel, total int64, err error) {
func (s *modelService) getModelsWithDedup(ctx context.Context, creator string, pageNum, pageSize int, modelNameLike string, modelType int, isPrivate int) (list []*entity.AsynchModel, total int64, err error) {
// 1. 查全量数据(不分页,便于去重)
allModels, err := dao.Model.GetByCreatorAndPlatform(ctx, creator, modelNameLike, modelType)
allModels, err := dao.Model.GetByCreatorAndPlatform(ctx, creator, modelNameLike, modelType, isPrivate)
if err != nil {
return nil, 0, err
}