PortalManageController.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package jnpf.base.controller;
  2. import io.swagger.v3.oas.annotations.Operation;
  3. import io.swagger.v3.oas.annotations.tags.Tag;
  4. import jnpf.base.ActionResult;
  5. import jnpf.base.entity.PortalManageEntity;
  6. import jnpf.base.model.portalManage.*;
  7. import jnpf.base.service.PortalManageService;
  8. import jnpf.base.vo.PageListVO;
  9. import jnpf.constant.MsgCode;
  10. import lombok.extern.slf4j.Slf4j;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.*;
  13. import jakarta.validation.Valid;
  14. import java.util.List;
  15. import java.util.stream.Collectors;
  16. /**
  17. * 门户管理
  18. *
  19. * @author JNPF开发平台组 YanYu
  20. * @version v3.4.6
  21. * @copyrignt 引迈信息技术有限公司
  22. * @date 2023-02-16
  23. */
  24. @Slf4j
  25. @RestController
  26. @Tag(name = "门户管理", description = "PortalManage")
  27. @RequestMapping("/api/system/PortalManage")
  28. public class PortalManageController extends SuperController<PortalManageService, PortalManageEntity> {
  29. @Autowired
  30. PortalManageService portalManageService;
  31. // @Autowired
  32. // PortalService portalApi;
  33. // @Autowired
  34. // private AuthorizeService authorizeService;
  35. @Operation(summary = "新增")
  36. @PostMapping
  37. public ActionResult<String> create(@RequestBody @Valid PortalManageCreForm portalManageForm) {
  38. PortalManageEntity entity = portalManageForm.convertEntity();
  39. try {
  40. portalManageService.checkCreUp(entity);
  41. } catch (Exception e) {
  42. return ActionResult.fail(e.getMessage());
  43. }
  44. portalManageService.save(entity);
  45. return ActionResult.success(MsgCode.SU018.get());
  46. }
  47. @Operation(summary = "删除")
  48. @DeleteMapping("/{id}")
  49. public ActionResult<String> delete(@PathVariable String id) {
  50. boolean flag = portalManageService.removeById(id);
  51. if(flag){
  52. // 删除绑定的所有权限
  53. // authorizeService.remove(new AuthorizePortalManagePrimary(null, id).getQuery());
  54. return ActionResult.success(MsgCode.SU003.get());
  55. } else {
  56. return ActionResult.fail(MsgCode.FA003.get());
  57. }
  58. }
  59. @Operation(summary = "编辑")
  60. @PutMapping("/{id}")
  61. public ActionResult<String> update(@PathVariable("id") String id, @RequestBody @Valid PortalManageUpForm portalManageUpForm){
  62. PortalManageEntity update = portalManageUpForm.convertEntity();
  63. try {
  64. portalManageService.checkCreUp(update);
  65. } catch (Exception e) {
  66. return ActionResult.fail(e.getMessage());
  67. }
  68. portalManageService.updateById(update);
  69. return ActionResult.success(MsgCode.SU004.get());
  70. }
  71. @Operation(summary = "查看")
  72. @GetMapping("/{id}")
  73. public ActionResult<PortalManageVO> getOne(@PathVariable("id") String id) {
  74. PortalManageEntity entity = portalManageService.getById(id);
  75. return ActionResult.success(portalManageService.convertVO(entity));
  76. }
  77. @Operation(summary = "列表")
  78. @GetMapping("/list/{systemId}")
  79. public ActionResult<PageListVO<PortalManageVO>> getPage(@PathVariable("systemId") String systemId, PortalManagePage pmPage) {
  80. pmPage.setSystemId(systemId);
  81. return ActionResult.page(
  82. portalManageService.getPage(pmPage).getRecords()
  83. .stream().map(PortalManagePageDO::convert).collect(Collectors.toList()),
  84. pmPage.getPaginationVO());
  85. }
  86. }