From 45c5a2b45a9763c58402fbe2a642fa751ece02c0 Mon Sep 17 00:00:00 2001
From: jjLv <1981429112@qq.com>
Date: Mon, 12 May 2025 09:26:47 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0apk=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controller/DoubleScreenMachineController.java | 3 +--
.../device/service/IDoubleScreenMachineService.java | 3 ++-
.../service/impl/DoubleScreenMachineServiceImpl.java | 11 +++++++++--
.../mapper/device/DoubleScreenMachineMapper.xml | 12 +++++++++++-
4 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/controller/DoubleScreenMachineController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/controller/DoubleScreenMachineController.java
index 168f6e2..5d0af60 100644
--- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/controller/DoubleScreenMachineController.java
+++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/controller/DoubleScreenMachineController.java
@@ -122,8 +122,7 @@ public class DoubleScreenMachineController extends BaseController {
@ApiOperation(value = "上传APK")
@PostMapping({"/uploadApk"})
public AjaxResult uploadApk(@RequestBody @Valid ApkDTO dto) {
- this.screenMachineService.uploadApk(dto);
- return AjaxResult.success();
+ return this.screenMachineService.uploadApk(dto);
}
}
diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/IDoubleScreenMachineService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/IDoubleScreenMachineService.java
index 05d1c81..044f64e 100644
--- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/IDoubleScreenMachineService.java
+++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/IDoubleScreenMachineService.java
@@ -7,6 +7,7 @@ import com.bonus.canteen.core.device.dto.ApkDTO;
import com.bonus.canteen.core.device.dto.DeviceDTO;
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
+import com.bonus.common.core.web.domain.AjaxResult;
import javax.validation.Valid;
@@ -51,5 +52,5 @@ public interface IDoubleScreenMachineService {
*/
void updateTimeBySn(String sn);
- void uploadApk(@Valid ApkDTO dto);
+ AjaxResult uploadApk(@Valid ApkDTO dto);
}
diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DoubleScreenMachineServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DoubleScreenMachineServiceImpl.java
index be2e549..90214cc 100644
--- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DoubleScreenMachineServiceImpl.java
+++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DoubleScreenMachineServiceImpl.java
@@ -11,6 +11,7 @@ import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO;
import com.bonus.common.core.exception.ServiceException;
+import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.houqin.constant.GlobalConstants;
import com.bonus.common.houqin.mq.constant.LeMqConstant;
import com.bonus.common.houqin.utils.id.Id;
@@ -171,16 +172,22 @@ public class DoubleScreenMachineServiceImpl implements IDoubleScreenMachineServi
}
@Override
- public void uploadApk(ApkDTO dto) {
+ public AjaxResult uploadApk(ApkDTO dto) {
try {
ApkDTO apkDTO = mapper.getApkByType(dto.getType(), dto.getVersion());
if (apkDTO != null) {
+ //检查最新的一条版本是否相同
+ ApkDTO lastBean = mapper.getApkByType(dto.getType(), null);
+ if (lastBean != null && !lastBean.getVersion().equals(dto.getVersion())){
+ return AjaxResult.error("该版本已存在");
+ }
mapper.updateApk(dto);
} else {
mapper.insertApk(dto);
}
} catch (Exception e) {
- throw new ServiceException("操作失败");
+ return AjaxResult.error("操作失败");
}
+ return AjaxResult.success();
}
}
diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/DoubleScreenMachineMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/DoubleScreenMachineMapper.xml
index 3d45243..f0e97b1 100644
--- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/DoubleScreenMachineMapper.xml
+++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/DoubleScreenMachineMapper.xml
@@ -181,7 +181,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"