SpRoleController.java
3.49 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.bs.web.controller.role;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.role.SpRole;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.enums.OperatorType;
import com.bs.web.service.role.ISpRoleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/sp/role")
@Tag(name = "服务商角色")
public class SpRoleController extends BaseController {
@Resource
private ISpRoleService spRoleService;
@PostMapping("/list")
@Operation(summary = "列表")
public AjaxResult<List<SpRole>> list(SpRole query) {
List<SpRole> list = spRoleService.list(query);
return AjaxResult.success(list);
}
@RequestMapping(value = "/page", method = {RequestMethod.GET, RequestMethod.POST})
@Operation(summary = "分页列表")
public TableDataInfo page(@RequestBody(required = false) SpRole query) {
com.bs.common.core.page.PageDomain pageDomain = com.bs.common.core.page.TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (pageNum == null && query != null && query.getParams() != null && query.getParams().get("pageNum") != null) {
pageNum = Integer.parseInt(query.getParams().get("pageNum").toString());
}
if (pageSize == null && query != null && query.getParams() != null && query.getParams().get("pageSize") != null) {
pageSize = Integer.parseInt(query.getParams().get("pageSize").toString());
}
if (pageNum == null) pageNum = 1;
if (pageSize == null) pageSize = 10;
com.baomidou.mybatisplus.core.metadata.IPage<SpRole> pageResult = spRoleService.page(query, pageNum, pageSize);
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(com.bs.common.constant.HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(pageResult.getRecords());
rspData.setTotal(pageResult.getTotal());
return rspData;
}
@PostMapping("/{id}")
@Operation(summary = "详情")
public AjaxResult<SpRole> get(@PathVariable("id") Long id) {
return AjaxResult.success(spRoleService.get(id));
}
@Log(title = "服务商角色新增", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE)
@PostMapping("/add")
@Operation(summary = "新增")
public AjaxResult add(@RequestBody SpRole info) {
spRoleService.add(info);
return AjaxResult.success();
}
@Log(title = "服务商角色编辑", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE)
@PostMapping("/edit")
@Operation(summary = "编辑")
public AjaxResult edit(@RequestBody SpRole info) {
spRoleService.edit(info);
return AjaxResult.success();
}
@Log(title = "服务商角色删除", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE)
@PostMapping("/delete/{id}")
@Operation(summary = "删除")
public AjaxResult remove(@PathVariable("id") Long id) {
spRoleService.remove(id);
return AjaxResult.success();
}
}