|
|
@@ -25,14 +25,22 @@ public class AitagTagCategoryController {
|
|
|
@Autowired
|
|
|
private FastApiService fastApiService;
|
|
|
|
|
|
+ // 定义一个系统默认页大小,防止前端不传时查询数据量过大
|
|
|
+ private static final int DEFAULT_PAGE_SIZE = 10;
|
|
|
+ private static final int MAX_PAGE_SIZE = 100;
|
|
|
+
|
|
|
@ApiOperationType("标签体系列表")
|
|
|
@GetMapping("/list")
|
|
|
public Result<List<AitagTagCategoryVo>> listCategories(
|
|
|
@RequestParam(required = false) String categoryNm,
|
|
|
@RequestParam(defaultValue = "1") int page,
|
|
|
- @RequestParam(defaultValue = "5") int size) {
|
|
|
+ @RequestParam(value = "pageSize", required = false) Integer size) {
|
|
|
+
|
|
|
+ // 处理 pageSize:如果前端没传,使用默认值;如果传了,可以使用前端值
|
|
|
+ int actualSize = (size == null || size <= 0) ? DEFAULT_PAGE_SIZE : Math.min(size, MAX_PAGE_SIZE);
|
|
|
+
|
|
|
try {
|
|
|
- Page<AitagTagCategoryVo> pageResult = aiTagCategoryService.listCategories(categoryNm, page, size);
|
|
|
+ Page<AitagTagCategoryVo> pageResult = aiTagCategoryService.listCategories(categoryNm, page, actualSize);
|
|
|
return Result.pageSuccess(pageResult.getRecords(), pageResult.getTotal());
|
|
|
} catch (Exception e) {
|
|
|
return Result.error("500", "分页查询失败:" + e.getMessage());
|
|
|
@@ -51,7 +59,6 @@ public class AitagTagCategoryController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@ApiOperationType("编辑标签体系")
|
|
|
@PostMapping("/update")
|
|
|
public Result<AitagTagCategory> updateCategory(@Validated @RequestBody AitagTagCategoryUpdateDto dto) {
|
|
|
@@ -103,17 +110,18 @@ public class AitagTagCategoryController {
|
|
|
@GetMapping("/enablelist")
|
|
|
public Result<List<AitagTagCategoryVo>> listEnabledCategories(
|
|
|
@RequestParam(defaultValue = "1") int page,
|
|
|
- @RequestParam(defaultValue = "5") int size) {
|
|
|
+ @RequestParam(value = "pageSize", required = false) Integer size) { // 修改点:改为 Integer,移除 defaultValue
|
|
|
+
|
|
|
+ int actualSize = (size == null || size <= 0) ? DEFAULT_PAGE_SIZE : Math.min(size, MAX_PAGE_SIZE);
|
|
|
+
|
|
|
try {
|
|
|
- Page<AitagTagCategoryVo> pageResult = aiTagCategoryService.listEnabledCategories(page, size);
|
|
|
+ Page<AitagTagCategoryVo> pageResult = aiTagCategoryService.listEnabledCategories(page, actualSize);
|
|
|
return Result.pageSuccess(pageResult.getRecords(), pageResult.getTotal());
|
|
|
} catch (Exception e) {
|
|
|
return Result.error("500", "分页查询失败:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@ApiOperationType("标签体系详情")
|
|
|
@GetMapping("/detail/{id}")
|
|
|
public Result<AitagTagCategoryVo> getCategoryDetail(@PathVariable String id) {
|
|
|
@@ -125,22 +133,19 @@ public class AitagTagCategoryController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 外部页面获取已启用的标签体系列表,无需token
|
|
|
- *
|
|
|
- * @return ResultDto
|
|
|
- */
|
|
|
@ApiOperationType("外部标签体系")
|
|
|
@GetMapping("/enablelistnoauth")
|
|
|
public Result<List<AitagTagCategoryVo>> listEnabledCategoriesNoAuth(
|
|
|
@RequestParam(defaultValue = "1") int page,
|
|
|
- @RequestParam(defaultValue = "5") int size) {
|
|
|
+ @RequestParam(value = "pageSize", required = false) Integer size) { // 修改点:改为 Integer,移除 defaultValue
|
|
|
+
|
|
|
+ int actualSize = (size == null || size <= 0) ? DEFAULT_PAGE_SIZE : Math.min(size, MAX_PAGE_SIZE);
|
|
|
+
|
|
|
try {
|
|
|
- Page<AitagTagCategoryVo> pageResult = aiTagCategoryService.listEnabledCategories(page, size);
|
|
|
+ Page<AitagTagCategoryVo> pageResult = aiTagCategoryService.listEnabledCategories(page, actualSize);
|
|
|
return Result.pageSuccess(pageResult.getRecords(), pageResult.getTotal());
|
|
|
} catch (Exception e) {
|
|
|
return Result.error("500", "分页查询失败:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|