You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package com.example.demo.controller;
import com.example.demo.domain.entity.Role; import com.example.demo.domain.vo.Page; import com.example.demo.domain.vo.Result; import com.example.demo.domain.vo.RoleVo; import com.example.demo.service.RefundService; import com.example.demo.service.RoleService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** * @program: gold-java * @ClassName RoleController * @description: * @author: Double * @create: 2025−07-15 11:23 * @Version 1.0 **/
@RestController @RequestMapping("/role") @RequiredArgsConstructor @Slf4j @CrossOrigin public class RoleController {
@Autowired private RoleService roleService;
//新增角色
@PostMapping("/add") public Result addRole(@RequestBody RoleVo roleVo) {
return roleService.addRole(roleVo); } //删除角色
@PostMapping("/delete") public Result deleteRole(@RequestBody RoleVo roleVo) {
return roleService.deleteRole(roleVo); }
//查找全部角色
@PostMapping("/selectAll") public Result selectRole() { List<RoleVo> list = roleService.selectAllRole(); return Result.success(list); } //获取上级角色的下属角色列表
@PostMapping("/selectSub") public Result selectSub(@RequestBody RoleVo roleVo) { Integer id = roleVo.getId(); List<RoleVo> list=roleService.selectSubRole(id); return Result.success(list); } //获取当前角色的上级角色
@PostMapping("/selectFather") public Result selectFather(@RequestBody RoleVo roleVo) { Integer id = roleVo.getId(); RoleVo role = roleService.selectFather(id); return Result.success(role); }
//角色明细筛选
@PostMapping("/selectBy") public Result selectBy(@RequestBody Page page) { try { //页码校验
if (ObjectUtils.isEmpty(page.getPageNum())) { return Result.error("页码数为空!"); } //页面大小校验
if (ObjectUtils.isEmpty(page.getPageSize())) { return Result.error("页大小为空!"); } else { return Result.success(roleService.selectBy(page.getPageNum(), page.getPageSize(), page.getRoleVo())); } } catch (Exception e) { e.printStackTrace(); return Result.error("请检查筛选数据的格式"); }
} }
|