寻找 swagger的依赖

1
2
3
4
5
6
<!-- https://mvnrepository.com/artifact/com.github.xiaoymin/knife4j-spring-boot-starter -->
<dependency>
    <groupId>com.github.xiaoymin</groupId>
    <artifactId>knife4j-spring-boot-starter</artifactId>
    <version>3.0.3</version>
</dependency>

这里 我使用 knife4j 其实是一样的。

官方文档

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package io.github.lyr2000.dissertation.controller.api;


import io.github.lyr2000.common.dto.R;
import io.github.lyr2000.common.dto.Result;
import io.github.lyr2000.dissertation.pojo.po.Role;
import io.github.lyr2000.dissertation.service.RolePermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;

@Api(tags = "权限管理")
@RestController
@RequestMapping("/api/admin/")
public class ApiAdminController {
    @Resource
    private RolePermissionService rolePermissionService;


    @GetMapping("/role")
    @ApiOperation("获取角色列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", dataType = "integer", paramType = "query", value = "分页页数",example = "1"),
            @ApiImplicitParam(name = "size", dataType = "integer", paramType = "query", value = "返回数量",example = "10"),
            @ApiImplicitParam(name = "name",paramType = "query",value = "角色名字"),
    })
    public Result<?> getRoles(@ApiIgnore @PageableDefault(size = 10,page = 1) Pageable page, @RequestParam(defaultValue = "") String name) {

        return rolePermissionService.queryRoles(page,name);
    }
    @PostMapping("/role")
    public Result addRole(@RequestBody Role role) {
        rolePermissionService.addRole(role);
        return R.ok();
    }
    @PatchMapping("/role")
    public Result updateRole(@RequestBody Role role) {
        rolePermissionService.updateRole(role);
        return R.ok();
    }



}