63 lines
2.1 KiB
Java
63 lines
2.1 KiB
Java
|
|
package com.yj.earth.business.controller;
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
|
|
import com.yj.earth.business.domain.Role;
|
||
|
|
import com.yj.earth.business.service.RoleService;
|
||
|
|
import com.yj.earth.common.util.ApiResponse;
|
||
|
|
import com.yj.earth.dto.role.AddRoleDto;
|
||
|
|
import com.yj.earth.dto.role.UpdateRoleDto;
|
||
|
|
import io.swagger.v3.oas.annotations.Operation;
|
||
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
||
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||
|
|
import org.springframework.beans.BeanUtils;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
import javax.annotation.Resource;
|
||
|
|
|
||
|
|
@Tag(name = "角色数据管理")
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/role")
|
||
|
|
public class RoleController {
|
||
|
|
@Resource
|
||
|
|
private RoleService roleService;
|
||
|
|
|
||
|
|
@Operation(summary = "新增角色")
|
||
|
|
@PostMapping("/add")
|
||
|
|
public ApiResponse save(@RequestBody AddRoleDto addRoleDto) {
|
||
|
|
Role role = new Role();
|
||
|
|
BeanUtils.copyProperties(addRoleDto, role);
|
||
|
|
roleService.save(role);
|
||
|
|
return ApiResponse.success(null);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Operation(summary = "删除角色")
|
||
|
|
@PostMapping("/delete")
|
||
|
|
public ApiResponse delete(@Parameter(description = "角色ID") String id) {
|
||
|
|
roleService.removeById(id);
|
||
|
|
return ApiResponse.success(null);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Operation(summary = "更新角色")
|
||
|
|
@PostMapping("/update")
|
||
|
|
public ApiResponse update(@RequestBody UpdateRoleDto updateRoleDto) {
|
||
|
|
Role role = new Role();
|
||
|
|
BeanUtils.copyProperties(updateRoleDto, role);
|
||
|
|
roleService.updateById(role);
|
||
|
|
return ApiResponse.success(null);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Operation(summary = "角色详情")
|
||
|
|
@GetMapping("/getById")
|
||
|
|
public ApiResponse get(@Parameter(description = "角色ID") String id) {
|
||
|
|
Role role = roleService.getById(id);
|
||
|
|
return ApiResponse.success(role);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Operation(summary = "角色列表")
|
||
|
|
@GetMapping("/list")
|
||
|
|
public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum, @Parameter(description = "分页大小") Integer pageSize) {
|
||
|
|
Page<Role> rolePage = roleService.page(new Page<>(pageNum, pageSize));
|
||
|
|
return ApiResponse.success(rolePage);
|
||
|
|
}
|
||
|
|
}
|