RtkInfoController.java 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. /**
  21. * 经销商申请管理
  22. * @author
  23. * @since 2022-09-21
  24. */
  25. @RestController
  26. @RequestMapping("/service/manage/rtkInfo")
  27. public class RtkInfoController {
  28. @Autowired
  29. IRtkInfoService rtkInfoService;
  30. @Autowired
  31. ICameraService cameraService;
  32. @PostMapping("/list")
  33. public ResultData list(@RequestBody RtkInfoParam param){
  34. return ResultData.ok(rtkInfoService.pageList(param));
  35. }
  36. @PostMapping("/saveOrEdit")
  37. public ResultData saveOrEdit(@RequestBody RtkInfo rtkInfo){
  38. if(rtkInfo.getId() == null){
  39. rtkInfo.setCreateUserId(Long.valueOf((String)StpUtil.getLoginId()));
  40. }else {
  41. rtkInfo.setUpdateUserId(Long.valueOf((String)StpUtil.getLoginId()));
  42. }
  43. if(rtkInfo.getRtkType() == null || StringUtils.isBlank(rtkInfo.getCameraSnCode())){
  44. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  45. }
  46. if(rtkInfo.getRtkType() == 0){
  47. rtkInfo.setIpAddr(null);
  48. rtkInfo.setMountPoint(null);
  49. rtkInfo.setPort(null);
  50. rtkInfo.setUserName(null);
  51. rtkInfo.setPassword(null);
  52. rtkInfo.setOperator(null);
  53. }
  54. Camera camera = cameraService.getBySnCode(rtkInfo.getCameraSnCode());
  55. if(camera == null){
  56. throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
  57. }
  58. rtkInfoService.saveOrEdit(rtkInfo);
  59. return ResultData.ok();
  60. }
  61. @PostMapping("/del")
  62. public ResultData del(@RequestBody RtkInfo rtkInfo){
  63. rtkInfoService.del(rtkInfo);
  64. return ResultData.ok();
  65. }
  66. }