Commit 4fdcf7ac by renyizhao

分页参数校验

parent 1b4c2ba4
......@@ -7,17 +7,21 @@ import com.luhu.computility.module.apihub.service.newapi.NewApiClient;
import com.luhu.computility.module.member.dal.dataobject.user.MemberUserDO;
import com.luhu.computility.module.member.service.user.MemberUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/app/ai-log")
@Validated
public class AppAiLogController {
@Resource
......@@ -89,8 +93,8 @@ public class AppAiLogController {
*/
@GetMapping("/self")
public CommonResult<Map<String, Object>> getSelfLog(
@RequestParam(defaultValue = "1") Integer p,
@RequestParam(defaultValue = "10") Integer page_size,
@RequestParam(defaultValue = "1") @Min(value = 1, message = "页码 p 最小值为 1") Integer p,
@RequestParam(defaultValue = "10") @Min(value = 1, message = "每页条数 page_size 最小值为 1") @Max(value = 100, message = "每页条数 page_size 最大值为 100") Integer page_size,
@RequestParam(defaultValue = "0") Integer type,
@RequestParam(required = false) String model_name,
@RequestParam(required = false) Long start_timestamp,
......
......@@ -13,12 +13,15 @@ import com.luhu.computility.module.member.service.user.MemberUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
......@@ -33,6 +36,7 @@ import java.util.Map;
@RestController
@RequestMapping("/app/ai")
@Tag(name = "APP端 - AI模型与定价")
@Validated
public class AppAiModelController {
/**
......@@ -68,8 +72,8 @@ public class AppAiModelController {
*/
@GetMapping("/models")
@Operation(summary = "获取 New API 模型列表(带元数据和图标)")
public CommonResult<List<AppModelVO>> getModels(@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "100") Integer pageSize) {
public CommonResult<List<AppModelVO>> getModels(@RequestParam(defaultValue = "1") @Min(value = 1, message = "页码 page 最小值为 1") Integer page,
@RequestParam(defaultValue = "100") @Min(value = 1, message = "每页条数 pageSize 最小值为 1") @Max(value = 100, message = "每页条数 pageSize 最大值为 100") Integer pageSize) {
NewApiResponse<Map<String, Object>> resp = newApiClient.getModels(page, pageSize);
if (resp.getSuccess() == null || !resp.getSuccess() || resp.getData() == null) {
log.error("[getModels] 调用 New API 失败:{}", resp.getMessage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment