|
|
@@ -0,0 +1,89 @@
|
|
|
+package com.smart.reader.controller;
|
|
|
+
|
|
|
+import com.smart.reader.common.Page;
|
|
|
+import com.smart.reader.common.R;
|
|
|
+import com.smart.reader.enums.SuccessResultCode;
|
|
|
+import com.smart.reader.exception.CustomException;
|
|
|
+import com.smart.reader.model.bo.SysRoleInfoAddBo;
|
|
|
+import com.smart.reader.model.bo.SysRoleInfoUpdateBo;
|
|
|
+import com.smart.reader.model.vo.SysRoleInfoVo;
|
|
|
+import com.smart.reader.service.SysRoleInfoService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RequestMapping("/api/v1/system/roleInfo")
|
|
|
+@RestController
|
|
|
+@Validated
|
|
|
+@Api(tags = "角色管理", description = "角色管理相关接口")
|
|
|
+public class SysRoleInfoController {
|
|
|
+ @Resource
|
|
|
+ private SysRoleInfoService sysRoleInfoService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增数据
|
|
|
+ *
|
|
|
+ * @param sysRoleInfo 实例对象
|
|
|
+ * @return 实例对象
|
|
|
+ */
|
|
|
+ @ApiOperation("新增数据")
|
|
|
+ @PostMapping("/add")
|
|
|
+ public R add(@RequestBody @Valid SysRoleInfoAddBo sysRoleInfo) throws CustomException {
|
|
|
+ sysRoleInfoService.add(sysRoleInfo);
|
|
|
+ return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("删除数据")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "角色ID", required = true)
|
|
|
+ })
|
|
|
+ @DeleteMapping("/delete/{id}")
|
|
|
+ public R delete(@NotNull(message = "角色ID不能为空") @PathVariable("id") Long id) throws CustomException {
|
|
|
+ sysRoleInfoService.delete(id);
|
|
|
+ return R.fail(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("批量删除数据")
|
|
|
+ @DeleteMapping("/batchDelete")
|
|
|
+ public R batchDelete(@RequestBody List<Long> ids) throws CustomException {
|
|
|
+ sysRoleInfoService.batchDelete(ids);
|
|
|
+ return R.success(SuccessResultCode.SUCCESS.getCode(), "批量删除成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("修改数据")
|
|
|
+ @PutMapping("/edit")
|
|
|
+ public R edit(@RequestBody @Valid SysRoleInfoUpdateBo sysRoleInfo) throws CustomException {
|
|
|
+ System.out.println(sysRoleInfo);
|
|
|
+ sysRoleInfoService.edit(sysRoleInfo);
|
|
|
+ return R.fail(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("queryInfo")
|
|
|
+ @ApiOperation("获取角色列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, dataType = "int", defaultValue = "1"),
|
|
|
+ @ApiImplicitParam(name = "pageSize", value = "页大小", required = true, dataType = "int", defaultValue = "10"),
|
|
|
+ })
|
|
|
+ public R<Page<SysRoleInfoVo>> queryInfo(int pageNum, int pageSize) {
|
|
|
+ Page<SysRoleInfoVo> result = sysRoleInfoService.queryInfo(pageNum, pageSize);
|
|
|
+ return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg(), result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("根据角色ID查询角色详情")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "角色ID", required = true)
|
|
|
+ })
|
|
|
+ @GetMapping("/detail/{id}")
|
|
|
+ public R detail(@NotNull(message = "角色ID不能为空") @PathVariable("id") Long id) {
|
|
|
+ SysRoleInfoVo sysRoleInfoVo = sysRoleInfoService.detail(id);
|
|
|
+ return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg(), sysRoleInfoVo);
|
|
|
+ }
|
|
|
+}
|