ReplacementInstrumentCooperationController.java 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package com.ym.mec.web.controller;
  2. import com.ym.mec.auth.api.client.SysUserFeignService;
  3. import com.ym.mec.auth.api.entity.SysUser;
  4. import com.ym.mec.biz.dal.dao.EmployeeDao;
  5. import com.ym.mec.biz.dal.entity.Employee;
  6. import com.ym.mec.biz.dal.entity.ReplacementInstrumentCooperation;
  7. import com.ym.mec.biz.dal.page.ReplacementInstrumentCooperationQueryInfo;
  8. import com.ym.mec.biz.service.ReplacementInstrumentCooperationService;
  9. import com.ym.mec.common.controller.BaseController;
  10. import com.ym.mec.common.entity.HttpResponseResult;
  11. import com.ym.mec.common.page.PageInfo;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import org.apache.commons.lang3.StringUtils;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.security.access.prepost.PreAuthorize;
  17. import org.springframework.web.bind.annotation.GetMapping;
  18. import org.springframework.web.bind.annotation.PostMapping;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RestController;
  21. import java.util.Arrays;
  22. import java.util.Date;
  23. import java.util.List;
  24. @RequestMapping("replacementInstrumentCooperation")
  25. @Api(tags = "乐器置换-生成链接管理服务")
  26. @RestController
  27. public class ReplacementInstrumentCooperationController extends BaseController {
  28. @Autowired
  29. private ReplacementInstrumentCooperationService replacementInstrumentCooperationService;
  30. @Autowired
  31. private SysUserFeignService sysUserFeignService;
  32. @Autowired
  33. private EmployeeDao employeeDao;
  34. @ApiOperation(value = "分页查询列表")
  35. @GetMapping("/queryPage")
  36. @PreAuthorize("@pcs.hasPermissions('replacementInstrumentCooperation/queryPage')")
  37. public HttpResponseResult<PageInfo<ReplacementInstrumentCooperation>> queryPage(ReplacementInstrumentCooperationQueryInfo queryInfo) {
  38. SysUser sysUser = sysUserFeignService.queryUserInfo();
  39. if (sysUser == null) {
  40. return failed("用户信息获取失败");
  41. }
  42. Employee employee = employeeDao.get(sysUser.getId());
  43. if (StringUtils.isEmpty(queryInfo.getOrganId())) {
  44. queryInfo.setOrganId(employee.getOrganIdList());
  45. } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
  46. return failed("用户所在分部异常");
  47. } else {
  48. List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
  49. if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
  50. return failed("非法请求");
  51. }
  52. }
  53. return succeed(replacementInstrumentCooperationService.getPageList(queryInfo));
  54. }
  55. @ApiOperation(value = "新增合作单位置换活动")
  56. @PostMapping("/add")
  57. @PreAuthorize("@pcs.hasPermissions('replacementInstrumentCooperation/add')")
  58. public HttpResponseResult<ReplacementInstrumentCooperation> add(ReplacementInstrumentCooperation replacementInstrumentCooperation) {
  59. ReplacementInstrumentCooperation hasOld = replacementInstrumentCooperationService.findByCooperationOrganIdAndTopicId(replacementInstrumentCooperation.getCooperationOrganId(),
  60. replacementInstrumentCooperation.getTopicId());
  61. if (hasOld != null) {
  62. return failed("合作单位链接已生成,不能重复生成");
  63. }
  64. Date nowDate = new Date();
  65. replacementInstrumentCooperation.setCreateTime(nowDate);
  66. replacementInstrumentCooperation.setUpdateTime(nowDate);
  67. replacementInstrumentCooperationService.insert(replacementInstrumentCooperation);
  68. return succeed(replacementInstrumentCooperation);
  69. }
  70. @ApiOperation(value = "开启缴费")
  71. @PostMapping("/openPay")
  72. @PreAuthorize("@pcs.hasPermissions('replacementInstrumentCooperation/openPay')")
  73. public HttpResponseResult<ReplacementInstrumentCooperation> openPay(Integer id) {
  74. return succeed(replacementInstrumentCooperationService.openPay(id));
  75. }
  76. }