|
|
@@ -50,8 +50,7 @@ public class CameraVersionServiceImpl extends ServiceImpl<ICameraVersionMapper,
|
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
|
|
|
|
@Override
|
|
|
- public void addAndUpload(MultipartFile file, String version, String description, String minVersion, String type) throws IOException {
|
|
|
- String cameraType = StringUtils.isNotBlank(type) ? type : "1";
|
|
|
+ public void addAndUpload(MultipartFile file, String version, String description, String minVersion, Integer type) throws IOException {
|
|
|
log.info("run upload");
|
|
|
if (!file.isEmpty()&& file.getSize() <= 0) {
|
|
|
throw new BusinessException(ErrorCode.FILE_NOT_EXIST);
|
|
|
@@ -87,7 +86,7 @@ public class CameraVersionServiceImpl extends ServiceImpl<ICameraVersionMapper,
|
|
|
versionEntity.setFileUrl(url);
|
|
|
versionEntity.setVersion(version);
|
|
|
versionEntity.setDescription(description);
|
|
|
- versionEntity.setType(Integer.parseInt(cameraType));
|
|
|
+ versionEntity.setType(type);
|
|
|
versionEntity.setMinVersion(minVersion);
|
|
|
versionEntity.setStatus("I");
|
|
|
versionEntity.setFileMd5(FileMd5Util.getFileMD5(new File(filePath)));
|
|
|
@@ -120,7 +119,7 @@ public class CameraVersionServiceImpl extends ServiceImpl<ICameraVersionMapper,
|
|
|
if(cameraVersion == null){
|
|
|
throw new BusinessException(ErrorCode.NOT_RECORD);
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(param.getStatus())){
|
|
|
+ if(StringUtils.isNotBlank(param.getStatus()) && !param.getStatus().equals(cameraVersion.getStatus())){
|
|
|
if(StringUtils.isBlank(param.getStatus()) || param.getType() == null){
|
|
|
throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
|
@@ -129,14 +128,15 @@ public class CameraVersionServiceImpl extends ServiceImpl<ICameraVersionMapper,
|
|
|
}
|
|
|
// 仅有有一台相机是活动状态
|
|
|
// 查找所以活动状态相机
|
|
|
- LambdaUpdateWrapper<CameraVersion> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.set(CameraVersion::getStatus,"I")
|
|
|
- .eq(CameraVersion::getStatus,"A")
|
|
|
- .eq(CameraVersion::getType,param.getType());
|
|
|
- this.update(updateWrapper);
|
|
|
-
|
|
|
+ if(param.getStatus().equals("A")){
|
|
|
+ LambdaUpdateWrapper<CameraVersion> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(CameraVersion::getStatus,"I")
|
|
|
+ .eq(CameraVersion::getStatus,"A")
|
|
|
+ .eq(CameraVersion::getType,param.getType());
|
|
|
+ this.update(updateWrapper);
|
|
|
+ }
|
|
|
cameraVersion.setStatus(param.getStatus());
|
|
|
- this.updateById(cameraVersion);
|
|
|
+ this.updateById(param);
|
|
|
return;
|
|
|
}
|
|
|
this.saveOrUpdate(param);
|