123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package com.fdkankan.manage.controller;
- import cn.dev33.satoken.stp.StpUtil;
- import com.fdkankan.manage.common.ResultCode;
- import com.fdkankan.manage.common.ResultData;
- import com.fdkankan.manage.entity.AgentAudit;
- import com.fdkankan.manage.entity.Camera;
- import com.fdkankan.manage.entity.RtkInfo;
- import com.fdkankan.manage.exception.BusinessException;
- import com.fdkankan.manage.service.IAgentAuditService;
- import com.fdkankan.manage.service.ICameraService;
- import com.fdkankan.manage.service.IRtkInfoService;
- import com.fdkankan.manage.vo.request.AgentAuditListParam;
- import com.fdkankan.manage.vo.request.RtkInfoParam;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.Objects;
- /**
- * 经销商申请管理
- * @author
- * @since 2022-09-21
- */
- @RestController
- @RequestMapping("/service/manage/rtkInfo")
- public class RtkInfoController {
- @Autowired
- IRtkInfoService rtkInfoService;
- @Autowired
- ICameraService cameraService;
- @PostMapping("/list")
- public ResultData list(@RequestBody RtkInfoParam param){
- return ResultData.ok(rtkInfoService.pageList(param));
- }
- @PostMapping("/saveOrEdit")
- public ResultData saveOrEdit(@RequestBody RtkInfo rtkInfo){
- if(rtkInfo.getRtkType() == null || StringUtils.isBlank(rtkInfo.getCameraSnCode()) || StringUtils.isBlank(rtkInfo.getRtkSnCode())){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- RtkInfo dbRtkInfo = rtkInfoService.getByRtkSnCode(rtkInfo.getRtkSnCode());
- RtkInfo dbRtkInfo2 = rtkInfoService.getByCameraSnCode(rtkInfo.getCameraSnCode());
- if(rtkInfo.getId() == null){
- rtkInfo.setCreateUserId(Long.valueOf((String)StpUtil.getLoginId()));
- if(dbRtkInfo != null){
- throw new BusinessException(ResultCode.RTK_SN_EXIST);
- }
- if(dbRtkInfo2 != null){
- throw new BusinessException(ResultCode.CAMERA_SN_EXIST);
- }
- }else {
- rtkInfo.setUpdateUserId(Long.valueOf((String)StpUtil.getLoginId()));
- if( dbRtkInfo != null && !Objects.equals(dbRtkInfo.getId(), rtkInfo.getId()) ){
- throw new BusinessException(ResultCode.RTK_SN_EXIST);
- }
- if( dbRtkInfo2 != null && !Objects.equals(dbRtkInfo2.getId(), rtkInfo.getId()) ){
- throw new BusinessException(ResultCode.CAMERA_SN_EXIST);
- }
- }
- if(rtkInfo.getRtkType() == 0){
- rtkInfo.setIpAddr(null);
- rtkInfo.setMountPoint(null);
- rtkInfo.setPort(null);
- rtkInfo.setUserName(null);
- rtkInfo.setPassword(null);
- rtkInfo.setOperator(null);
- }
- Camera camera = cameraService.getBySnCode(rtkInfo.getCameraSnCode());
- if(camera == null){
- throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
- }
- rtkInfoService.saveOrEdit(rtkInfo);
- return ResultData.ok();
- }
- @PostMapping("/del")
- public ResultData del(@RequestBody RtkInfo rtkInfo){
- rtkInfoService.del(rtkInfo);
- return ResultData.ok();
- }
- }
|