|
@@ -0,0 +1,135 @@
|
|
|
|
|
+package shop.alien.store.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import io.swagger.annotations.*;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import shop.alien.entity.result.R;
|
|
|
|
|
+import shop.alien.entity.store.LifeSysRole;
|
|
|
|
|
+import shop.alien.store.service.LifeSysRoleService;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 平台角色信息表 前端控制器
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author system
|
|
|
|
|
+ * @since 2025-01-XX
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Api(tags = {"平台角色管理"})
|
|
|
|
|
+@ApiSort(1)
|
|
|
|
|
+@CrossOrigin
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/sys/role")
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+public class LifeSysRoleController {
|
|
|
|
|
+
|
|
|
|
|
+ private final LifeSysRoleService lifeSysRoleService;
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("分页查询角色列表")
|
|
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "page", value = "页码", dataType = "int", paramType = "query", required = true),
|
|
|
|
|
+ @ApiImplicitParam(name = "size", value = "页容", dataType = "int", paramType = "query", required = true),
|
|
|
|
|
+ @ApiImplicitParam(name = "roleName", value = "角色名称(支持模糊查询)", dataType = "String", paramType = "query"),
|
|
|
|
|
+ @ApiImplicitParam(name = "description", value = "角色描述(支持模糊查询)", dataType = "String", paramType = "query"),
|
|
|
|
|
+ @ApiImplicitParam(name = "status", value = "角色状态(0正常 1停用)", dataType = "String", paramType = "query")
|
|
|
|
|
+ })
|
|
|
|
|
+ @GetMapping("/getRolePage")
|
|
|
|
|
+ public R<IPage<LifeSysRole>> getRolePage(
|
|
|
|
|
+ @RequestParam(name = "page", defaultValue = "1") int page,
|
|
|
|
|
+ @RequestParam(name = "size", defaultValue = "10") int size,
|
|
|
|
|
+ @RequestParam(value = "roleName", required = false) String roleName,
|
|
|
|
|
+ @RequestParam(value = "description", required = false) String description,
|
|
|
|
|
+ @RequestParam(value = "status", required = false) String status) {
|
|
|
|
|
+ log.info("LifeSysRoleController.getRolePage?page={}, size={}, roleName={}, roleKey={}, status={}",
|
|
|
|
|
+ page, size, roleName, description, status);
|
|
|
|
|
+ IPage<LifeSysRole> rolePage = lifeSysRoleService.getRolePage(page, size, roleName, description, status);
|
|
|
|
|
+ return R.data(rolePage);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("根据ID查询角色详情")
|
|
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "roleId", value = "角色ID", dataType = "Long", paramType = "path", required = true)
|
|
|
|
|
+ })
|
|
|
|
|
+ @GetMapping("/getRoleById")
|
|
|
|
|
+ public R<LifeSysRole> getRoleById(@RequestParam("roleId") Long roleId) {
|
|
|
|
|
+ log.info("LifeSysRoleController.getRoleById?roleId={}", roleId);
|
|
|
|
|
+ LifeSysRole role = lifeSysRoleService.getRoleById(roleId);
|
|
|
|
|
+ if (role == null) {
|
|
|
|
|
+ return R.fail("未找到该角色信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.data(role);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("新增角色")
|
|
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
|
|
+ @PostMapping("/saveRole")
|
|
|
|
|
+ public R<String> saveRole(@RequestBody LifeSysRole role) {
|
|
|
|
|
+ log.info("LifeSysRoleController.saveRole?role={}", role);
|
|
|
|
|
+ boolean result = lifeSysRoleService.saveRole(role);
|
|
|
|
|
+ if (result) {
|
|
|
|
|
+ return R.success("新增成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.fail("新增失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("修改角色")
|
|
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
|
|
+ @PostMapping("/updateRole")
|
|
|
|
|
+ public R<String> updateRole(@RequestBody LifeSysRole role) {
|
|
|
|
|
+ log.info("LifeSysRoleController.updateRole?role={}", role);
|
|
|
|
|
+ boolean result = lifeSysRoleService.updateRole(role);
|
|
|
|
|
+ if (result) {
|
|
|
|
|
+ return R.success("修改成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.fail("修改失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("删除角色")
|
|
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "roleId", value = "角色ID", dataType = "Long", paramType = "path", required = true)
|
|
|
|
|
+ })
|
|
|
|
|
+ @DeleteMapping("/deleteRole")
|
|
|
|
|
+ public R<String> deleteRole(@RequestParam("roleId") Long roleId) {
|
|
|
|
|
+ log.info("LifeSysRoleController.deleteRole?roleId={}", roleId);
|
|
|
|
|
+ boolean result = lifeSysRoleService.deleteRole(roleId);
|
|
|
|
|
+ if (result) {
|
|
|
|
|
+ return R.success("删除成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.fail("删除失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("修改角色状态")
|
|
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "roleId", value = "角色ID", dataType = "Long", paramType = "path", required = true),
|
|
|
|
|
+ @ApiImplicitParam(name = "status", value = "角色状态(0正常 1停用)", dataType = "String", paramType = "query", required = true)
|
|
|
|
|
+ })
|
|
|
|
|
+ @PutMapping("/updateStatus")
|
|
|
|
|
+ public R<String> updateStatus(
|
|
|
|
|
+ @RequestParam("roleId") Long roleId,
|
|
|
|
|
+ @RequestParam("status") String status) {
|
|
|
|
|
+ log.info("LifeSysRoleController.updateStatus?roleId={}, status={}", roleId, status);
|
|
|
|
|
+ boolean result = lifeSysRoleService.updateStatus(roleId, status);
|
|
|
|
|
+ if (result) {
|
|
|
|
|
+ return R.success("操作成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.fail("操作失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("查询所有正常状态的角色列表")
|
|
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
|
|
+ @GetMapping("/getAllNormalRoles")
|
|
|
|
|
+ public R<List<LifeSysRole>> getAllNormalRoles() {
|
|
|
|
|
+ log.info("LifeSysRoleController.getAllNormalRoles");
|
|
|
|
|
+ List<LifeSysRole> roles = lifeSysRoleService.getAllNormalRoles();
|
|
|
|
|
+ return R.data(roles);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|