SysOrgController.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package com.qmth.distributed.print.api;
  2. import com.qmth.boot.api.constant.ApiConstant;
  3. import com.qmth.distributed.print.business.service.PrintCommonService;
  4. import com.qmth.teachcloud.common.bean.dto.OrgDto;
  5. import com.qmth.teachcloud.common.entity.SysOrg;
  6. import com.qmth.teachcloud.common.service.SysOrgService;
  7. import com.qmth.teachcloud.common.util.Result;
  8. import com.qmth.teachcloud.common.util.ResultUtil;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.validation.BindingResult;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestMethod;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import javax.annotation.Resource;
  18. import javax.validation.Valid;
  19. import java.util.List;
  20. /**
  21. * <p>
  22. * 学校组织架构 前端控制器
  23. * </p>
  24. *
  25. * @author xf
  26. * @since 2021-03-23
  27. */
  28. @Api(tags = "组织架构Controller")
  29. @RestController
  30. @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.sys}/org")
  31. public class SysOrgController {
  32. @Autowired
  33. private SysOrgService sysOrgService;
  34. @Resource
  35. PrintCommonService printCommonService;
  36. /**
  37. * 查询机构树
  38. *
  39. * @return
  40. */
  41. @ApiOperation(value = "查询")
  42. @RequestMapping(value = "/list", method = RequestMethod.POST)
  43. public Result list() {
  44. List<OrgDto> orgDtoList = sysOrgService.listOrgTree();
  45. return ResultUtil.ok(orgDtoList);
  46. }
  47. /**
  48. * 新增/修改
  49. *
  50. * @param org
  51. * @return
  52. */
  53. @ApiOperation(value = "新增/修改")
  54. @RequestMapping(value = "/save", method = RequestMethod.POST)
  55. public Result save(@Valid @RequestBody SysOrg org, BindingResult bindingResult) {
  56. if (bindingResult.hasErrors()) {
  57. return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
  58. }
  59. return ResultUtil.ok(sysOrgService.saveOrg(org));
  60. }
  61. /**
  62. * 启用/禁用
  63. *
  64. * @param org
  65. * @return
  66. */
  67. @ApiOperation(value = "启用/禁用")
  68. @RequestMapping(value = "/enable", method = RequestMethod.POST)
  69. public Result enable(@RequestBody SysOrg org) {
  70. boolean isSuccess = printCommonService.enable(org);
  71. return ResultUtil.ok(isSuccess);
  72. }
  73. /**
  74. * 删除
  75. *
  76. * @param org
  77. * @return
  78. */
  79. @ApiOperation(value = "删除")
  80. @RequestMapping(value = "/remove", method = RequestMethod.POST)
  81. public Result remove(@RequestBody SysOrg org) {
  82. boolean isSuccess = printCommonService.remove(org.getId());
  83. return ResultUtil.ok(isSuccess);
  84. }
  85. }