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)
    }

}

三、效果展示

相关推荐
寻星探路2 小时前
【深度长文】万字攻克网络原理:从 HTTP 报文解构到 HTTPS 终极加密逻辑
java·开发语言·网络·python·http·ai·https
曹牧4 小时前
Spring Boot:如何测试Java Controller中的POST请求?
java·开发语言
爬山算法5 小时前
Hibernate(90)如何在故障注入测试中使用Hibernate?
java·后端·hibernate
kfyty7255 小时前
集成 spring-ai 2.x 实践中遇到的一些问题及解决方案
java·人工智能·spring-ai
猫头虎5 小时前
如何排查并解决项目启动时报错Error encountered while processing: java.io.IOException: closed 的问题
java·开发语言·jvm·spring boot·python·开源·maven
李少兄5 小时前
在 IntelliJ IDEA 中修改 Git 远程仓库地址
java·git·intellij-idea
忆~遂愿6 小时前
ops-cv 算子库深度解析:面向视觉任务的硬件优化与数据布局(NCHW/NHWC)策略
java·大数据·linux·人工智能
小韩学长yyds6 小时前
Java序列化避坑指南:明确这4种场景,再也不盲目实现Serializable
java·序列化
仟濹6 小时前
【Java基础】多态 | 打卡day2
java·开发语言