提交 de9d3ecb 作者: 方治民

feat: 示例接口更新

上级 753bfbfd
......@@ -13,7 +13,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -31,7 +30,6 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor
public class HealthController {
final ApplicationContext applicationContext;
final Redis redis;
final Minio minio;
final UserRepository userRepository;
......
......@@ -73,9 +73,13 @@ public class ExampleController {
*/
@Operation(summary = "测试失败")
@GetMapping("fail")
public Result<String> fail() {
public void fail() {
// 1. 直接抛出异常
Status.BAD_REQUEST.expose("Code.1");
// 2. 手动抛出异常
// throw Status.BAD_REQUEST.exception("Code.1");
// throw BusinessException.i18n("Code.1");
throw new RuntimeException("test fail");
// throw new FailStatusException(Status.BAD_REQUEST, "Code.1");
}
@SaCheckLogin
......@@ -83,6 +87,14 @@ public class ExampleController {
@GetMapping("page")
public Result<PageVo<String>> page(@ParameterObject @Validated PageParam param) {
log.debug("PageParam: {}", param);
log.debug("Pageable: {}", PageParam.toPageable(param));
// 常用的分页、条件查询工具类函数
// 1. Specifications.of()
// 2. Specifications.exist()
// 3. PageParam.toPageable()
// 4. PageVo.build()/PageVo.toPageVo()
// 5. RepositoryUtil.find()
String text = i18n.get("example.hello");
List<String> data = Arrays.asList(text.split(" "));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论