004-按照指定功能模块名称分组

按照指定功能模块名称分组

一、说明

1.现在有一个需求:

需要把一个功能模块的几个功能点放在同一个文档目录下,这几个功能点分布在不同的 Controller

2.具体做法

需要把他们单独分组,方便前端对接。在@ApiOperation 里面增加属性 tags 赋值

注意:接口可以在同一个Controller,也可以不在同一个Controller

二、代码案例

java 复制代码
@Api(tags = "测试日期格式化")
@Slf4j
@RequestMapping("/test8Controller")
@RestController
public class Test8Controller {

    @ApiOperation(value = "查询8实体信息",tags = {"查询API"})
    @GetMapping("/test1")
    public TestDateTimeFormat test1(){
        TestDateTimeFormat testDateTimeFormat = new TestDateTimeFormat();
        testDateTimeFormat.setName("xiaogang");
        testDateTimeFormat.setPhoneNumber("111111111111");
        testDateTimeFormat.setAddress("beijing");
        testDateTimeFormat.setBirthday(new Date());
        return testDateTimeFormat;
    }

    @ApiOperation(value = "新增实体信息")
    @PostMapping("/test2")
    public void test2(@RequestBody TestDateTimeFormat testDateTimeFormat){
        log.info("实体类:{}",testDateTimeFormat);
        // 实体类:TestJsonFormat(name=小明, address=北京市, phoneNumber=123456789, birthday=Thu Oct 10 14:42:20 CST 2024)
    }

}
java 复制代码
@Api(tags = "测试TestJsonFormat日期格式化")
@Slf4j
@RequestMapping("/test7Controller")
@RestController
public class Test7Controller {

    @ApiOperation(value = "查询7实体信息",tags = {"查询API"})
    @GetMapping("/test1")
    public TestJsonFormat test1(){
        TestJsonFormat testJsonFiled = new TestJsonFormat();
        testJsonFiled.setName("xiaogang");
        testJsonFiled.setPhoneNumber("111111111111");
        testJsonFiled.setAddress("beijing");
        testJsonFiled.setBirthday(new Date());
        return testJsonFiled;
    }

    @RequestMapping("/test2")
    public void test2(@RequestBody TestJsonFormat testJsonFormat){
        log.info("实体类:{}",testJsonFormat);
        // 实体类:TestJsonFormat(name=小明, address=北京市, phoneNumber=123456789, birthday=Thu Oct 10 14:42:20 CST 2024)
    }

}

三、效果展示

相关推荐
karry_k5 小时前
MyBatis批量insert-select踩坑:useGeneratedKeys=true 可能让PostgreSQL返回大量插入结果
java·后端
karry_k6 小时前
PostgreSQL 在 MyBatis 中执行正常 SQL 失效:一次 DELETE USING 踩坑记录
java·后端
SamDeepThinking9 小时前
从源码到代码:MyBatis-Flex 与 MyBatis-Plus 的逐项对比
java·后端·程序员
她的男孩12 小时前
Spring Boot 接 Flowable 工作流:用 3 个注解搭一个请假审批流程
java·后端·架构
荣码14 小时前
LLM结构化输出:让AI返回JSON而不是废话,我踩了4个坑
java·python
plainGeekDev15 小时前
Gson → kotlinx.serialization
android·java·kotlin
小bo波1 天前
Java Swing 图形用户界面实验 —— 从算术练习到游戏开发的完整实践
java·课程设计·gui·游戏开发·扫雷·swing
咖啡八杯1 天前
GoF设计模式——备忘录模式
java·后端·spring·设计模式