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

}

三、效果展示

相关推荐
潇潇云起几秒前
mapdb
java·开发语言·数据结构·db
MXM_7772 分钟前
laravel 并发控制写法-涉及资金
java·数据库·oracle
这就是佬们吗9 分钟前
告别 Node.js 版本冲突:NVM 安装与使用全攻略
java·linux·前端·windows·node.js·mac·web
何中应9 分钟前
@Autowrited和@Resource注解的区别及使用场景
java·开发语言·spring boot·后端·spring
一条咸鱼_SaltyFish10 分钟前
[Day16] Bug 排查记录:若依框架二次开发中的经验与教训 contract-security-ruoyi
java·开发语言·经验分享·微服务·架构·bug·开源软件
荒诞硬汉12 分钟前
递归的学习
java·学习
孤独天狼13 分钟前
java设计模式
java
一勺菠萝丶13 分钟前
Java 对接 PLC 实战:西门子 PLC 与永宏 PLC 通讯方式全面对比
java·开发语言·python
吴声子夜歌13 分钟前
Java数据结构与算法——数论问题
java·开发语言
这就是佬们吗15 分钟前
Windows 的 CMD 网络环境:解决终端无法联网与更新的终极指南
java·windows·git·python·spring·maven