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.
75 lines
2.1 KiB
75 lines
2.1 KiB
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("/selectAll")
|
|
public Result selectRole() {
|
|
List<RoleVo> list = roleService.selectAllRole();
|
|
return Result.success(list);
|
|
}
|
|
//获取上级角色的下属角色列表
|
|
@PostMapping("/selectSub")
|
|
public List<RoleVo> selectSub(Integer fatherId) {
|
|
|
|
return roleService.selectSubRole(fatherId);
|
|
}
|
|
|
|
//角色明细筛选
|
|
@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) {
|
|
return Result.error("请检查筛选数据的格式");
|
|
}
|
|
|
|
}
|
|
}
|