Commit cd35d7ec18911b0aae2427056f0d38713b667981
1 parent
ad773669
apk更新接口
Showing
1 changed file
with
40 additions
and
7 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/controller/MobileController.java
1 | package org.jeecg.modules.wms.api.mobile.controller; | 1 | package org.jeecg.modules.wms.api.mobile.controller; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONException; | ||
3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 4 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 5 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
5 | import io.swagger.annotations.Api; | 6 | import io.swagger.annotations.Api; |
7 | +import io.swagger.annotations.ApiOperation; | ||
6 | import org.jeecg.common.api.vo.Result; | 8 | import org.jeecg.common.api.vo.Result; |
7 | import org.jeecg.modules.system.entity.SysDictItem; | 9 | import org.jeecg.modules.system.entity.SysDictItem; |
8 | import org.jeecg.modules.system.service.impl.SysDictItemServiceImpl; | 10 | import org.jeecg.modules.system.service.impl.SysDictItemServiceImpl; |
9 | import org.jeecg.modules.wms.api.mobile.entity.TvTaskVo; | 11 | import org.jeecg.modules.wms.api.mobile.entity.TvTaskVo; |
12 | +import org.jeecg.modules.wms.monitor.apkinfo.entity.ApkInfo; | ||
13 | +import org.jeecg.modules.wms.monitor.apkinfo.service.IApkInfoService; | ||
10 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; | 14 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; |
11 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; | 15 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; |
12 | import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskDetailServiceImpl; | 16 | import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskDetailServiceImpl; |
13 | import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskHeaderServiceImpl; | 17 | import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskHeaderServiceImpl; |
14 | import org.jeecg.utils.StringUtils; | 18 | import org.jeecg.utils.StringUtils; |
15 | import org.jeecg.utils.constant.QuantityConstant; | 19 | import org.jeecg.utils.constant.QuantityConstant; |
16 | -import org.springframework.web.bind.annotation.GetMapping; | ||
17 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
18 | -import org.springframework.web.bind.annotation.RestController; | 20 | +import org.springframework.beans.factory.annotation.Value; |
21 | +import org.springframework.web.bind.annotation.*; | ||
19 | 22 | ||
20 | import javax.annotation.Resource; | 23 | import javax.annotation.Resource; |
21 | -import java.util.ArrayList; | ||
22 | -import java.util.Arrays; | ||
23 | -import java.util.HashMap; | ||
24 | -import java.util.List; | 24 | +import java.util.*; |
25 | 25 | ||
26 | /** | 26 | /** |
27 | */ | 27 | */ |
@@ -30,6 +30,12 @@ import java.util.List; | @@ -30,6 +30,12 @@ import java.util.List; | ||
30 | @RequestMapping("/api/mobile") | 30 | @RequestMapping("/api/mobile") |
31 | public class MobileController { | 31 | public class MobileController { |
32 | 32 | ||
33 | + @Value(value = "${server.servlet.context-path}") | ||
34 | + private String ctx; | ||
35 | + | ||
36 | + @Resource | ||
37 | + private IApkInfoService apkInfoService; | ||
38 | + | ||
33 | @Resource | 39 | @Resource |
34 | private TaskHeaderServiceImpl taskHeaderService; | 40 | private TaskHeaderServiceImpl taskHeaderService; |
35 | 41 | ||
@@ -87,4 +93,31 @@ public class MobileController { | @@ -87,4 +93,31 @@ public class MobileController { | ||
87 | } | 93 | } |
88 | return Result.OK("", list); | 94 | return Result.OK("", list); |
89 | } | 95 | } |
96 | + | ||
97 | + @PostMapping("/getUpdateApkInfo") | ||
98 | + @ApiOperation("获取apk更新信息") | ||
99 | + public Result getUpdateApkInfo(@RequestBody Map<String, String> param) { | ||
100 | + System.out.println("getUpdateApkInfo pkgName:" + param.get("pkgName")); | ||
101 | + String pkgName = param.get("pkgName"); | ||
102 | + String versionCode = param.get("versionCode"); | ||
103 | + if (StringUtils.isEmpty(pkgName)) { | ||
104 | + throw new JSONException("pkgName不能为空"); | ||
105 | + } | ||
106 | + if (StringUtils.isEmpty(versionCode)) { | ||
107 | + throw new JSONException("versionCode不能为空"); | ||
108 | + } | ||
109 | + | ||
110 | + LambdaQueryWrapper<ApkInfo> query = Wrappers.lambdaQuery(); | ||
111 | + query.eq(ApkInfo::getPkgname, pkgName) | ||
112 | + .orderByDesc(ApkInfo::getVersioncode) | ||
113 | + .last(" limit 1"); | ||
114 | + ApkInfo apkInfo = apkInfoService.getOne(query); | ||
115 | + if (apkInfo == null ){ | ||
116 | + return Result.error("服务器上找不到安装包:" + pkgName); | ||
117 | + }else if(apkInfo.getVersioncode() <= Integer.parseInt(versionCode)){ | ||
118 | + return Result.ok("当前已经是最新版本"); | ||
119 | + } | ||
120 | + apkInfo.setUrl(ctx + apkInfo.getUrl()); | ||
121 | + return Result.ok(apkInfo); | ||
122 | + } | ||
90 | } | 123 | } |