diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/controller/MobileController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/controller/MobileController.java index 96a1a66..6fce763 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/controller/MobileController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/controller/MobileController.java @@ -1,27 +1,27 @@ package org.jeecg.modules.wms.api.mobile.controller; +import com.alibaba.fastjson.JSONException; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.system.entity.SysDictItem; import org.jeecg.modules.system.service.impl.SysDictItemServiceImpl; import org.jeecg.modules.wms.api.mobile.entity.TvTaskVo; +import org.jeecg.modules.wms.monitor.apkinfo.entity.ApkInfo; +import org.jeecg.modules.wms.monitor.apkinfo.service.IApkInfoService; import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskDetailServiceImpl; import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskHeaderServiceImpl; import org.jeecg.utils.StringUtils; import org.jeecg.utils.constant.QuantityConstant; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; +import java.util.*; /** */ @@ -30,6 +30,12 @@ import java.util.List; @RequestMapping("/api/mobile") public class MobileController { + @Value(value = "${server.servlet.context-path}") + private String ctx; + + @Resource + private IApkInfoService apkInfoService; + @Resource private TaskHeaderServiceImpl taskHeaderService; @@ -87,4 +93,31 @@ public class MobileController { } return Result.OK("", list); } + + @PostMapping("/getUpdateApkInfo") + @ApiOperation("获取apk更新信息") + public Result getUpdateApkInfo(@RequestBody Map<String, String> param) { + System.out.println("getUpdateApkInfo pkgName:" + param.get("pkgName")); + String pkgName = param.get("pkgName"); + String versionCode = param.get("versionCode"); + if (StringUtils.isEmpty(pkgName)) { + throw new JSONException("pkgName不能为空"); + } + if (StringUtils.isEmpty(versionCode)) { + throw new JSONException("versionCode不能为空"); + } + + LambdaQueryWrapper<ApkInfo> query = Wrappers.lambdaQuery(); + query.eq(ApkInfo::getPkgname, pkgName) + .orderByDesc(ApkInfo::getVersioncode) + .last(" limit 1"); + ApkInfo apkInfo = apkInfoService.getOne(query); + if (apkInfo == null ){ + return Result.error("服务器上找不到安装包:" + pkgName); + }else if(apkInfo.getVersioncode() <= Integer.parseInt(versionCode)){ + return Result.ok("当前已经是最新版本"); + } + apkInfo.setUrl(ctx + apkInfo.getUrl()); + return Result.ok(apkInfo); + } }