package com.dy.pmsBase.role; import com.alibaba.fastjson2.JSON; import com.dy.common.aop.SsoPowerAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.aop.Log; import com.dy.pmsGlobal.pojoBa.BaRole; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; /** * 角色管理 */ @Slf4j @RestController @RequestMapping(path="role") @SuppressWarnings("unchecked") public class RoleCtrl { private RoleSv roleSv; @Autowired public RoleCtrl(RoleSv roleSv){ this.roleSv = roleSv; } /** * 保存角色信息 * @param role * @return */ @PostMapping(path="save") @SsoPowerAop(power = "10100003") @Log("保存角色信息") public BaseResponse save(@RequestBody @Valid BaRole role){ int count; role.setDeleted(false); role.setDisabled(false); count = roleSv.save(role); if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { return BaseResponseUtils.buildSuccess(true); } } /** * 更新角色信息 * @param role * @return */ @PostMapping(path="update") @SsoPowerAop(power = "10100003") @Log("更新角色信息") public BaseResponse update(@RequestBody @Valid BaRole role){ int count = roleSv.update(role); if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { return BaseResponseUtils.buildSuccess(true); } } /** * 删除角色信息 * @param id * @return */ @GetMapping(path="delete") @SsoPowerAop(power = "10100003") @Log("删除角色信息") public BaseResponse delete(String id){ int count = roleSv.delete(Long.parseLong(id)); if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { return BaseResponseUtils.buildSuccess(true); } } /** * 禁用角色信息 * @param role * @return */ @PostMapping(path="disabled") @SsoPowerAop(power = "10100003") @Log("禁用或启用角色信息") public BaseResponse disabled(@RequestBody BaRole role){ int count = roleSv.disabled(role.id,role.disabled); if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { return BaseResponseUtils.buildSuccess(true); } } /** * 根据ID查询角色信息 * @return */ @GetMapping(path="one") @SsoPowerAop(power = "10100002") //登录与权限同时验证 @Log("根据ID查询角色信息") public BaseResponse one(String id){ BaRole role=roleSv.selectById(id); return BaseResponseUtils.buildSuccess(JSON.toJSON(role)); } /** * 查询所有角色 * @return */ @GetMapping(path="all") @SsoPowerAop(power = "10100002") //登录与权限同时验证 @Log("查询所有角色") public BaseResponse> all(String id){ List roles=roleSv.selectAll(); return BaseResponseUtils.buildSuccess(roles); } /** * 查询角色信息 * @param vo * @return */ @PostMapping(path="some") @SsoPowerAop(power = "10100002") @Log("查询角色信息") public BaseResponse>> some(@RequestBody QueryVo vo){ QueryResultVo> list = roleSv.selectSome(vo) ; return BaseResponseUtils.buildSuccess(list); } }