SysRoleController.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package edu.travel.tenant.web;
  2. import edu.travel.interfaces.InsertGroups;
  3. import edu.travel.resp.BaseResponse;
  4. import edu.travel.tenant.entity.EduTenant;
  5. import edu.travel.tenant.entity.SysRole;
  6. import edu.travel.tenant.service.ISysRoleService;
  7. import edu.travel.web.BaseController;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.security.access.prepost.PreAuthorize;
  10. import org.springframework.security.core.context.SecurityContextHolder;
  11. import org.springframework.transaction.annotation.Transactional;
  12. import org.springframework.validation.annotation.Validated;
  13. import org.springframework.web.bind.annotation.PostMapping;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RestController;
  17. /**
  18. * SysRoleController 类。
  19. * <p>
  20. * 描述:
  21. *
  22. * @author huangwenwen
  23. * @date 2025/2/6
  24. */
  25. @RestController
  26. @RequestMapping("/sysRole")
  27. public class SysRoleController extends BaseController<SysRole> {
  28. @Autowired
  29. private ISysRoleService sysRoleService;
  30. /**
  31. * 新增管理角色
  32. */
  33. @PostMapping("/add")
  34. @Transactional
  35. // @PreAuthorize("hasAuthority = '超级管理员'")
  36. public BaseResponse<Boolean> add(@Validated(InsertGroups.class) @RequestBody SysRole sysRole) {
  37. EduTenant principal = (EduTenant) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
  38. sysRoleService.add(sysRole,principal);
  39. return new BaseResponse<>(200,"success",true) ;
  40. }
  41. /**
  42. * 删除角色
  43. */
  44. @PostMapping("/delete")
  45. public BaseResponse<Boolean> delete(@RequestBody String ids) {
  46. // sysRoleService.deleteByIds(ids);
  47. return new BaseResponse<>(200,"success",true) ;
  48. }
  49. }