RtkInfoController.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package com.fdkankan.manage.controller;
  2. import cn.dev33.satoken.stp.StpUtil;
  3. import com.fdkankan.manage.common.ResultCode;
  4. import com.fdkankan.manage.common.ResultData;
  5. import com.fdkankan.manage.entity.AgentAudit;
  6. import com.fdkankan.manage.entity.Camera;
  7. import com.fdkankan.manage.entity.RtkInfo;
  8. import com.fdkankan.manage.exception.BusinessException;
  9. import com.fdkankan.manage.service.IAgentAuditService;
  10. import com.fdkankan.manage.service.ICameraService;
  11. import com.fdkankan.manage.service.IRtkInfoService;
  12. import com.fdkankan.manage.vo.request.AgentAuditListParam;
  13. import com.fdkankan.manage.vo.request.RtkInfoParam;
  14. import org.apache.commons.lang3.StringUtils;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.web.bind.annotation.PostMapping;
  17. import org.springframework.web.bind.annotation.RequestBody;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RestController;
  20. import java.util.Objects;
  21. /**
  22. * 经销商申请管理
  23. * @author
  24. * @since 2022-09-21
  25. */
  26. @RestController
  27. @RequestMapping("/service/manage/rtkInfo")
  28. public class RtkInfoController {
  29. @Autowired
  30. IRtkInfoService rtkInfoService;
  31. @Autowired
  32. ICameraService cameraService;
  33. @PostMapping("/list")
  34. public ResultData list(@RequestBody RtkInfoParam param){
  35. return ResultData.ok(rtkInfoService.pageList(param));
  36. }
  37. @PostMapping("/saveOrEdit")
  38. public ResultData saveOrEdit(@RequestBody RtkInfo rtkInfo){
  39. if(rtkInfo.getRtkType() == null || StringUtils.isBlank(rtkInfo.getCameraSnCode()) || StringUtils.isBlank(rtkInfo.getRtkSnCode())){
  40. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  41. }
  42. RtkInfo dbRtkInfo = rtkInfoService.getByRtkSnCode(rtkInfo.getRtkSnCode());
  43. RtkInfo dbRtkInfo2 = rtkInfoService.getByCameraSnCode(rtkInfo.getCameraSnCode());
  44. if(rtkInfo.getId() == null){
  45. rtkInfo.setCreateUserId(Long.valueOf((String)StpUtil.getLoginId()));
  46. if(dbRtkInfo != null){
  47. throw new BusinessException(ResultCode.RTK_SN_EXIST);
  48. }
  49. if(dbRtkInfo2 != null){
  50. throw new BusinessException(ResultCode.CAMERA_SN_EXIST);
  51. }
  52. }else {
  53. rtkInfo.setUpdateUserId(Long.valueOf((String)StpUtil.getLoginId()));
  54. if( dbRtkInfo != null && !Objects.equals(dbRtkInfo.getId(), rtkInfo.getId()) ){
  55. throw new BusinessException(ResultCode.RTK_SN_EXIST);
  56. }
  57. if( dbRtkInfo2 != null && !Objects.equals(dbRtkInfo2.getId(), rtkInfo.getId()) ){
  58. throw new BusinessException(ResultCode.CAMERA_SN_EXIST);
  59. }
  60. }
  61. if(rtkInfo.getRtkType() == 0){
  62. rtkInfo.setIpAddr(null);
  63. rtkInfo.setMountPoint(null);
  64. rtkInfo.setPort(null);
  65. rtkInfo.setUserName(null);
  66. rtkInfo.setPassword(null);
  67. rtkInfo.setOperator(null);
  68. }
  69. Camera camera = cameraService.getBySnCode(rtkInfo.getCameraSnCode());
  70. if(camera == null){
  71. throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
  72. }
  73. rtkInfoService.saveOrEdit(rtkInfo);
  74. return ResultData.ok();
  75. }
  76. @PostMapping("/del")
  77. public ResultData del(@RequestBody RtkInfo rtkInfo){
  78. rtkInfoService.del(rtkInfo);
  79. return ResultData.ok();
  80. }
  81. }