VrRoleController.java
2.53 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.glsx.usedcar.controller;
import com.glsx.usedcar.module.vrsystem.service.VrRoleService;
import com.glsx.usedcar.module.vrsystem.vo.VrRoleAddVO;
import com.glsx.usedcar.module.vrsystem.vo.VrRoleRespVO;
import com.glsx.usedcar.module.vrsystem.vo.VrRoleUpdateVO;
import com.glsx.usedcar.resp.BaseResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* VR角色管理接口
*/
@Slf4j
@RestController
@RequestMapping("/rest/system/role")
@RequiredArgsConstructor
@Tag(name = "角色管理接口", description = "角色(账号类型)的增删改查操作")
public class VrRoleController {
private final VrRoleService vrRoleService;
@GetMapping("/list")
@Operation(summary = "角色列表", description = "查询所有角色列表(按排序字段升序)")
public BaseResp<List<VrRoleRespVO>> listRoles() {
return BaseResp.success(vrRoleService.listRoles());
}
@GetMapping("/detail")
@Operation(summary = "角色详情", description = "根据ID查询角色详情")
public BaseResp<VrRoleRespVO> getRoleDetail(
@Parameter(description = "角色ID", required = true, example = "1") @RequestParam Long id) {
return BaseResp.success(vrRoleService.getRoleById(id));
}
@PostMapping("/add")
@Operation(summary = "新增角色", description = "新增角色,角色编码需唯一")
public BaseResp<Void> addRole(@Valid @RequestBody VrRoleAddVO addVO) {
vrRoleService.addRole(addVO);
return BaseResp.success();
}
@PostMapping("/update/{id}")
@Operation(summary = "修改角色", description = "修改角色信息(不支持修改角色编码)")
public BaseResp<Void> updateRole(
@Parameter(description = "角色ID", required = true, example = "1") @PathVariable Long id,
@RequestBody VrRoleUpdateVO updateVO) {
vrRoleService.updateRole(id, updateVO);
return BaseResp.success();
}
@DeleteMapping("/delete/{id}")
@Operation(summary = "删除角色", description = "逻辑删除角色,角色下有用户时不可删除")
public BaseResp<Void> deleteRole(
@Parameter(description = "角色ID", required = true, example = "1") @PathVariable Long id) {
vrRoleService.deleteRole(id);
return BaseResp.success();
}
}