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

}

三、效果展示

相关推荐
我没想到原来他们都是一堆坏人19 分钟前
(未完待续...)如何编写一个用于构建python web项目镜像的dockerfile文件
java·前端·python
沙二原住民27 分钟前
提升数据库性能的秘密武器:深入解析慢查询、连接池与Druid监控
java·数据库·oracle
Jerry&Grj1 小时前
SpringBoot埋点功能技术实现方案深度解析:架构设计、性能优化与扩展性实践
java·微服务·性能优化·springboot·架构设计·埋点技术
没有bug.的程序员1 小时前
Redis Stream:轻量级消息队列深度解析
java·数据库·chrome·redis·消息队列
用户8160791833331 小时前
告别“魔法”:包你解决 Gradle 的下载慢问题
java
当归10242 小时前
SQL Server死锁排查实战指南
java·服务器·网络
echoyu.2 小时前
消息队列-初识kafka
java·分布式·后端·spring cloud·中间件·架构·kafka
little_xianzhong2 小时前
关于对逾期提醒的定时任务~改进完善
java·数据库·spring boot·spring·mybatis
百锦再2 小时前
脚本语言的大浪淘沙或百花争艳
java·开发语言·人工智能·python·django·virtualenv·pygame
小猪咪piggy2 小时前
【JavaEE】(23) 综合练习--博客系统
java·数据库·java-ee