Commit cdcd5499745ff2c29f0f646b1673950e2fdcacf7
1 parent
79e0eacc
fix: 新增app版本监察和更新
Showing
14 changed files
with
728 additions
and
12 deletions
ruoyi-admin/src/main/java/com/ruoyi/controller/ApplicationUpdateController.java
0 → 100644
| 1 | +package com.ruoyi.controller; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 4 | +import com.ruoyi.service.AppService; | ||
| 5 | +import io.swagger.annotations.Api; | ||
| 6 | +import io.swagger.annotations.ApiOperation; | ||
| 7 | +import org.springframework.web.bind.annotation.*; | ||
| 8 | +import org.springframework.web.multipart.MultipartFile; | ||
| 9 | + | ||
| 10 | +import javax.annotation.Resource; | ||
| 11 | +import javax.servlet.http.HttpServletResponse; | ||
| 12 | +import java.io.IOException; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 管理应用更新 | ||
| 16 | + */ | ||
| 17 | +@RestController | ||
| 18 | +@Api(tags = "管理应用更新") | ||
| 19 | +@RequestMapping("/app") | ||
| 20 | +public class ApplicationUpdateController { | ||
| 21 | + | ||
| 22 | + @Resource | ||
| 23 | + private AppService appService; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 校验版本号 | ||
| 27 | + */ | ||
| 28 | + @GetMapping("/version/check/{currentVersion}") | ||
| 29 | + @ApiOperation("校验版本号") | ||
| 30 | + public AjaxResult checkVersionNum(@PathVariable("currentVersion") String currentVersion) { | ||
| 31 | + return AjaxResult.success(appService.checkVersionNum(currentVersion)); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 下载最新apk | ||
| 36 | + */ | ||
| 37 | + @PostMapping("/download") | ||
| 38 | + @ApiOperation("下载最新apk") | ||
| 39 | + public void downloadApk(String apkUrl, HttpServletResponse response) { | ||
| 40 | + try { | ||
| 41 | + appService.downloadApk(apkUrl, response); | ||
| 42 | + } catch (IOException e) { | ||
| 43 | + throw new RuntimeException("下载失败,请联系管理员处理,失败原因 :" + e.getMessage()); | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @PostMapping("/uploadApk") | ||
| 48 | + @ApiOperation("上传apk文件") | ||
| 49 | + public AjaxResult uploadApk(MultipartFile file) { | ||
| 50 | + try { | ||
| 51 | + return appService.uploadApk(file); | ||
| 52 | + } catch (Exception e) { | ||
| 53 | + return AjaxResult.error("上传失败,请重试,再次失败请联系管理员,失败原因:" + e.getMessage()); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | +} |
ruoyi-admin/src/main/java/com/ruoyi/driver/controller/DriverController.java
| @@ -51,7 +51,6 @@ public class DriverController extends BaseController { | @@ -51,7 +51,6 @@ public class DriverController extends BaseController { | ||
| 51 | return driverService.getDriverSchedulingAll(); | 51 | return driverService.getDriverSchedulingAll(); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | - | ||
| 55 | /** | 54 | /** |
| 56 | * 查询驾驶员信息列表 | 55 | * 查询驾驶员信息列表 |
| 57 | */ | 56 | */ |
| @@ -66,6 +65,7 @@ public class DriverController extends BaseController { | @@ -66,6 +65,7 @@ public class DriverController extends BaseController { | ||
| 66 | 65 | ||
| 67 | /** | 66 | /** |
| 68 | * 获取驾驶员信息列表 | 67 | * 获取驾驶员信息列表 |
| 68 | + * | ||
| 69 | * @param driver | 69 | * @param driver |
| 70 | * @return | 70 | * @return |
| 71 | */ | 71 | */ |
| @@ -75,7 +75,6 @@ public class DriverController extends BaseController { | @@ -75,7 +75,6 @@ public class DriverController extends BaseController { | ||
| 75 | return AjaxResult.success(driverService.getDrivers(driver)); | 75 | return AjaxResult.success(driverService.getDrivers(driver)); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | - | ||
| 79 | /** | 78 | /** |
| 80 | * 导出驾驶员信息列表 | 79 | * 导出驾驶员信息列表 |
| 81 | */ | 80 | */ |
| @@ -105,12 +104,23 @@ public class DriverController extends BaseController { | @@ -105,12 +104,23 @@ public class DriverController extends BaseController { | ||
| 105 | // @PreAuthorize("@ss.hasPermi('driver:driver:add')") | 104 | // @PreAuthorize("@ss.hasPermi('driver:driver:add')") |
| 106 | @Log(title = "驾驶员信息", businessType = BusinessType.INSERT) | 105 | @Log(title = "驾驶员信息", businessType = BusinessType.INSERT) |
| 107 | @PostMapping | 106 | @PostMapping |
| 108 | - @ApiOperation("新增驾驶员信息") | ||
| 109 | - public AjaxResult add(@ApiParam("driver") @RequestBody Driver driver) { | 107 | + @ApiOperation("新增驾驶员信息(后台)") |
| 108 | + public AjaxResult add(@ApiParam @RequestBody Driver driver) { | ||
| 110 | return toAjax(driverService.insertDriver(driver)); | 109 | return toAjax(driverService.insertDriver(driver)); |
| 111 | } | 110 | } |
| 112 | 111 | ||
| 113 | /** | 112 | /** |
| 113 | + * 人脸注册 | ||
| 114 | + * @param driver | ||
| 115 | + * @return | ||
| 116 | + */ | ||
| 117 | + @PostMapping("/addDriver") | ||
| 118 | + @ApiOperation("新增驾驶员信息(酒精一体机)") | ||
| 119 | + public AjaxResult addDriver(@ApiParam @RequestBody Driver driver) { | ||
| 120 | + return toAjax(driverService.addDriver(driver)); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 114 | * 修改驾驶员信息 | 124 | * 修改驾驶员信息 |
| 115 | */ | 125 | */ |
| 116 | // @PreAuthorize("@ss.hasPermi('driver:driver:edit')") | 126 | // @PreAuthorize("@ss.hasPermi('driver:driver:edit')") |
| @@ -147,22 +157,20 @@ public class DriverController extends BaseController { | @@ -147,22 +157,20 @@ public class DriverController extends BaseController { | ||
| 147 | 157 | ||
| 148 | @PostMapping("/upload") | 158 | @PostMapping("/upload") |
| 149 | public AjaxResult uploadImage(MultipartFile file) { | 159 | public AjaxResult uploadImage(MultipartFile file) { |
| 150 | - try | ||
| 151 | - { | 160 | + try { |
| 152 | return driverService.uploadImage(file); | 161 | return driverService.uploadImage(file); |
| 153 | - } | ||
| 154 | - catch (Exception e) | ||
| 155 | - { | 162 | + } catch (Exception e) { |
| 156 | return AjaxResult.error(e.getMessage()); | 163 | return AjaxResult.error(e.getMessage()); |
| 157 | } | 164 | } |
| 158 | } | 165 | } |
| 166 | + | ||
| 159 | /** | 167 | /** |
| 160 | * 头像下载 根据 工号 | 168 | * 头像下载 根据 工号 |
| 161 | */ | 169 | */ |
| 162 | @ApiModelProperty("头像下载") | 170 | @ApiModelProperty("头像下载") |
| 163 | @GetMapping("/download/{jobCode}") | 171 | @GetMapping("/download/{jobCode}") |
| 164 | - public void downLoadHeadImage(@PathVariable("jobCode")String jobCode,HttpServletResponse response){ | ||
| 165 | - driverService.downloadHeadImage(jobCode,response); | 172 | + public void downLoadHeadImage(@PathVariable("jobCode") String jobCode, HttpServletResponse response) { |
| 173 | + driverService.downloadHeadImage(jobCode, response); | ||
| 166 | } | 174 | } |
| 167 | 175 | ||
| 168 | } | 176 | } |
ruoyi-admin/src/main/java/com/ruoyi/driver/service/IDriverService.java
| @@ -86,4 +86,6 @@ public interface IDriverService | @@ -86,4 +86,6 @@ public interface IDriverService | ||
| 86 | void downloadHeadImage(String jobCode, HttpServletResponse response); | 86 | void downloadHeadImage(String jobCode, HttpServletResponse response); |
| 87 | 87 | ||
| 88 | List<Driver> getDrivers(Driver driver); | 88 | List<Driver> getDrivers(Driver driver); |
| 89 | + | ||
| 90 | + int addDriver(Driver driver); | ||
| 89 | } | 91 | } |
ruoyi-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
| @@ -235,6 +235,12 @@ public class DriverServiceImpl implements IDriverService { | @@ -235,6 +235,12 @@ public class DriverServiceImpl implements IDriverService { | ||
| 235 | return drivers; | 235 | return drivers; |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | + @Override | ||
| 239 | + public int addDriver(Driver driver) { | ||
| 240 | + // TODO 人脸注册 | ||
| 241 | + return 0; | ||
| 242 | + } | ||
| 243 | + | ||
| 238 | private File getLocationFile(String jobCode) { | 244 | private File getLocationFile(String jobCode) { |
| 239 | String image = driverMapper.getDriverInfoByJobCode(jobCode); | 245 | String image = driverMapper.getDriverInfoByJobCode(jobCode); |
| 240 | 246 |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ApplicationResponseVo.java
0 → 100644
| 1 | +package com.ruoyi.pojo.response; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @author 20412 | ||
| 9 | + */ | ||
| 10 | +@ApiModel("应用更新实体类") | ||
| 11 | +@Data | ||
| 12 | +public class ApplicationResponseVo { | ||
| 13 | + @ApiModelProperty("是否更新") | ||
| 14 | + Boolean updateFlag; | ||
| 15 | + @ApiModelProperty("是否强制更新") | ||
| 16 | + Boolean forceUpdate; | ||
| 17 | + @ApiModelProperty("更新版本号") | ||
| 18 | + String versionNum; | ||
| 19 | + @ApiModelProperty("更新apk的url") | ||
| 20 | + String apkUrl; | ||
| 21 | + private ApplicationResponseVo(){ } | ||
| 22 | + public ApplicationResponseVo appNoUpdate(String versionNum){ | ||
| 23 | + this.updateFlag = false; | ||
| 24 | + this.forceUpdate = false; | ||
| 25 | + this.versionNum = versionNum; | ||
| 26 | + this.apkUrl = ""; | ||
| 27 | + return this; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 一般更新 | ||
| 32 | + * @param versionNum | ||
| 33 | + * @param apkUrl | ||
| 34 | + * @return | ||
| 35 | + */ | ||
| 36 | + public ApplicationResponseVo appNormalUpdate(String versionNum,String apkUrl){ | ||
| 37 | + this.updateFlag = true; | ||
| 38 | + this.forceUpdate = false; | ||
| 39 | + this.versionNum = versionNum; | ||
| 40 | + this.apkUrl = apkUrl; | ||
| 41 | + return this; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * 强制更新 | ||
| 46 | + * @param versionNum | ||
| 47 | + * @param apkUrl | ||
| 48 | + * @return | ||
| 49 | + */ | ||
| 50 | + public ApplicationResponseVo appForceUpdate(String versionNum,String apkUrl){ | ||
| 51 | + this.updateFlag = true; | ||
| 52 | + this.forceUpdate = true; | ||
| 53 | + this.versionNum = versionNum; | ||
| 54 | + this.apkUrl = apkUrl; | ||
| 55 | + return this; | ||
| 56 | + } | ||
| 57 | + public static ApplicationResponseVo applicationResponseVoBuild(){ | ||
| 58 | + return new ApplicationResponseVo(); | ||
| 59 | + } | ||
| 60 | +} |
ruoyi-admin/src/main/java/com/ruoyi/service/AppService.java
0 → 100644
| 1 | +package com.ruoyi.service; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.config.RuoYiConfig; | ||
| 4 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 5 | +import com.ruoyi.common.utils.StringUtils; | ||
| 6 | +import com.ruoyi.common.utils.file.FileUploadUtils; | ||
| 7 | +import com.ruoyi.common.utils.file.FileUtils; | ||
| 8 | +import com.ruoyi.framework.config.ServerConfig; | ||
| 9 | +import com.ruoyi.pojo.response.ApplicationResponseVo; | ||
| 10 | +import com.ruoyi.upgrade.domain.VersionUpgrade; | ||
| 11 | +import com.ruoyi.upgrade.mapper.VersionUpgradeMapper; | ||
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | +import org.springframework.beans.factory.annotation.Value; | ||
| 14 | +import org.springframework.http.MediaType; | ||
| 15 | +import org.springframework.stereotype.Service; | ||
| 16 | +import org.springframework.web.multipart.MultipartFile; | ||
| 17 | + | ||
| 18 | +import javax.servlet.ServletOutputStream; | ||
| 19 | +import javax.servlet.http.HttpServletResponse; | ||
| 20 | +import java.io.*; | ||
| 21 | +import java.nio.file.Paths; | ||
| 22 | +import java.util.Objects; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * 应用service | ||
| 26 | + */ | ||
| 27 | +@Service | ||
| 28 | +public class AppService { | ||
| 29 | + | ||
| 30 | + @Value("${api.apk.path}") | ||
| 31 | + String apkPath; | ||
| 32 | + | ||
| 33 | + @Autowired | ||
| 34 | + private ServerConfig serverConfig; | ||
| 35 | + @Autowired | ||
| 36 | + private VersionUpgradeMapper versionUpgradeMapper; | ||
| 37 | + | ||
| 38 | + public ApplicationResponseVo checkVersionNum(String versionNum) { | ||
| 39 | + // 比对版本 需要更新 判断是否需要强制更新 | ||
| 40 | + VersionUpgrade vu = versionUpgradeMapper.queryLatestVersionNum(); | ||
| 41 | + // 无需更新 | ||
| 42 | + if (!Objects.isNull(vu) && vu.getVersionCode().equals(versionNum)){ | ||
| 43 | + return ApplicationResponseVo.applicationResponseVoBuild().appNoUpdate(versionNum); | ||
| 44 | + } | ||
| 45 | + // 更新判断 | ||
| 46 | + return ApplicationResponseVo.applicationResponseVoBuild().appForceUpdate(versionNum,vu.getApkUrl()); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void downloadApk(String url, HttpServletResponse response) throws IOException { | ||
| 50 | + // 把文件写入响应体 | ||
| 51 | + String realFileName = url.substring(url.indexOf("_") + 1); | ||
| 52 | + response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); | ||
| 53 | + FileUtils.setAttachmentResponseHeader(response, realFileName); | ||
| 54 | + FileUtils.writeBytes(RuoYiConfig.getUploadPath() + url, response.getOutputStream()); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public AjaxResult uploadApk(MultipartFile file) throws IOException { | ||
| 58 | + // 校验文件 | ||
| 59 | +// checkFile(file); | ||
| 60 | + // 上传文件路径 | ||
| 61 | + String filePath = RuoYiConfig.getUploadPath(); | ||
| 62 | + // 上传并返回新文件名称 | ||
| 63 | + String fileName = apkPath + System.currentTimeMillis() + "_" + file.getOriginalFilename(); | ||
| 64 | + // 获取相对路径 | ||
| 65 | + String absPath = FileUploadUtils.getAbsoluteFile(filePath, fileName).getAbsolutePath(); | ||
| 66 | + // 上传文件 | ||
| 67 | + file.transferTo(Paths.get(absPath)); | ||
| 68 | + // 返回url | ||
| 69 | + String url = serverConfig.getUrl() + fileName; | ||
| 70 | + AjaxResult ajax = AjaxResult.success(); | ||
| 71 | + ajax.put("url", url); | ||
| 72 | + ajax.put("fileName", fileName); | ||
| 73 | + ajax.put("newFileName", FileUtils.getName(fileName)); | ||
| 74 | + ajax.put("originalFilename", file.getOriginalFilename()); | ||
| 75 | + return ajax; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + private void checkFile(MultipartFile file) { | ||
| 79 | + | ||
| 80 | + if (StringUtils.isEmpty(file.getOriginalFilename()) ){ | ||
| 81 | + throw new RuntimeException("不是apk文件请重新上传"); | ||
| 82 | + } | ||
| 83 | + if (!file.getOriginalFilename().endsWith(".apk")) { | ||
| 84 | + throw new RuntimeException("不是apk文件请重新上传"); | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | +} |
ruoyi-admin/src/main/java/com/ruoyi/upgrade/controller/VersionUpgradeController.java
0 → 100644
| 1 | +package com.ruoyi.upgrade.controller; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import javax.servlet.http.HttpServletResponse; | ||
| 5 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 8 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 9 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 10 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 11 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 12 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 13 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 14 | +import org.springframework.web.bind.annotation.RestController; | ||
| 15 | +import com.ruoyi.common.annotation.Log; | ||
| 16 | +import com.ruoyi.common.core.controller.BaseController; | ||
| 17 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 18 | +import com.ruoyi.common.enums.BusinessType; | ||
| 19 | +import com.ruoyi.upgrade.domain.VersionUpgrade; | ||
| 20 | +import com.ruoyi.upgrade.service.IVersionUpgradeService; | ||
| 21 | +import com.ruoyi.common.utils.poi.ExcelUtil; | ||
| 22 | +import com.ruoyi.common.core.page.TableDataInfo; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * upgradeController | ||
| 26 | + * | ||
| 27 | + * @author ruoyi | ||
| 28 | + * @date 2023-07-18 | ||
| 29 | + */ | ||
| 30 | +@RestController | ||
| 31 | +@RequestMapping("/upgrade/upgrade") | ||
| 32 | +public class VersionUpgradeController extends BaseController | ||
| 33 | +{ | ||
| 34 | + @Autowired | ||
| 35 | + private IVersionUpgradeService versionUpgradeService; | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * 查询upgrade列表 | ||
| 39 | + */ | ||
| 40 | + @PreAuthorize("@ss.hasPermi('upgrade:upgrade:list')") | ||
| 41 | + @GetMapping("/list") | ||
| 42 | + public TableDataInfo list(VersionUpgrade versionUpgrade) | ||
| 43 | + { | ||
| 44 | + startPage(); | ||
| 45 | + List<VersionUpgrade> list = versionUpgradeService.selectVersionUpgradeList(versionUpgrade); | ||
| 46 | + return getDataTable(list); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * 导出upgrade列表 | ||
| 51 | + */ | ||
| 52 | + @PreAuthorize("@ss.hasPermi('upgrade:upgrade:export')") | ||
| 53 | + @Log(title = "upgrade", businessType = BusinessType.EXPORT) | ||
| 54 | + @PostMapping("/export") | ||
| 55 | + public void export(HttpServletResponse response, VersionUpgrade versionUpgrade) | ||
| 56 | + { | ||
| 57 | + List<VersionUpgrade> list = versionUpgradeService.selectVersionUpgradeList(versionUpgrade); | ||
| 58 | + ExcelUtil<VersionUpgrade> util = new ExcelUtil<VersionUpgrade>(VersionUpgrade.class); | ||
| 59 | + util.exportExcel(response, list, "upgrade数据"); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 获取upgrade详细信息 | ||
| 64 | + */ | ||
| 65 | + @PreAuthorize("@ss.hasPermi('upgrade:upgrade:query')") | ||
| 66 | + @GetMapping(value = "/{id}") | ||
| 67 | + public AjaxResult getInfo(@PathVariable("id") String id) | ||
| 68 | + { | ||
| 69 | + return success(versionUpgradeService.selectVersionUpgradeById(id)); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 新增upgrade | ||
| 74 | + */ | ||
| 75 | + @PreAuthorize("@ss.hasPermi('upgrade:upgrade:add')") | ||
| 76 | + @Log(title = "upgrade", businessType = BusinessType.INSERT) | ||
| 77 | + @PostMapping | ||
| 78 | + public AjaxResult add(@RequestBody VersionUpgrade versionUpgrade) | ||
| 79 | + { | ||
| 80 | + return toAjax(versionUpgradeService.insertVersionUpgrade(versionUpgrade)); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * 修改upgrade | ||
| 85 | + */ | ||
| 86 | + @PreAuthorize("@ss.hasPermi('upgrade:upgrade:edit')") | ||
| 87 | + @Log(title = "upgrade", businessType = BusinessType.UPDATE) | ||
| 88 | + @PutMapping | ||
| 89 | + public AjaxResult edit(@RequestBody VersionUpgrade versionUpgrade) | ||
| 90 | + { | ||
| 91 | + return toAjax(versionUpgradeService.updateVersionUpgrade(versionUpgrade)); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * 删除upgrade | ||
| 96 | + */ | ||
| 97 | + @PreAuthorize("@ss.hasPermi('upgrade:upgrade:remove')") | ||
| 98 | + @Log(title = "upgrade", businessType = BusinessType.DELETE) | ||
| 99 | + @DeleteMapping("/{ids}") | ||
| 100 | + public AjaxResult remove(@PathVariable String[] ids) | ||
| 101 | + { | ||
| 102 | + return toAjax(versionUpgradeService.deleteVersionUpgradeByIds(ids)); | ||
| 103 | + } | ||
| 104 | +} |
ruoyi-admin/src/main/java/com/ruoyi/upgrade/domain/VersionUpgrade.java
0 → 100644
| 1 | +package com.ruoyi.upgrade.domain; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import org.apache.commons.lang3.builder.ToStringBuilder; | ||
| 7 | +import org.apache.commons.lang3.builder.ToStringStyle; | ||
| 8 | +import com.ruoyi.common.annotation.Excel; | ||
| 9 | +import com.ruoyi.common.core.domain.BaseEntity; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * upgrade对象 version_upgrade | ||
| 13 | + * | ||
| 14 | + * @author ruoyi | ||
| 15 | + * @date 2023-07-18 | ||
| 16 | + */ | ||
| 17 | +@Data | ||
| 18 | +@ApiModel("版本对象") | ||
| 19 | +public class VersionUpgrade extends BaseEntity | ||
| 20 | +{ | ||
| 21 | + private static final long serialVersionUID = 1L; | ||
| 22 | + | ||
| 23 | + /** 组件 */ | ||
| 24 | + private String id; | ||
| 25 | + | ||
| 26 | + /** 客户端设备id 1安卓pad */ | ||
| 27 | + @Excel(name = "客户端设备id 1安卓pad") | ||
| 28 | + @ApiModelProperty("设备类型") | ||
| 29 | + private Integer appId; | ||
| 30 | + | ||
| 31 | + /** 大版本号id */ | ||
| 32 | + @Excel(name = "大版本号id") | ||
| 33 | + @ApiModelProperty("大版本号") | ||
| 34 | + private Integer versionId; | ||
| 35 | + | ||
| 36 | + /** 小版本号 */ | ||
| 37 | + @Excel(name = "小版本号") | ||
| 38 | + @ApiModelProperty("小版本号") | ||
| 39 | + private Integer versionMini; | ||
| 40 | + | ||
| 41 | + /** 版本标识 */ | ||
| 42 | + @Excel(name = "版本标识") | ||
| 43 | + @ApiModelProperty("版本标识") | ||
| 44 | + private String versionCode; | ||
| 45 | + | ||
| 46 | + /** 是否升级 */ | ||
| 47 | + @Excel(name = "是否升级") | ||
| 48 | + @ApiModelProperty("升级类型 ") | ||
| 49 | + private String type; | ||
| 50 | + | ||
| 51 | + /** ApkUrl */ | ||
| 52 | + @Excel(name = "ApkUrl") | ||
| 53 | + @ApiModelProperty("apk路径") | ||
| 54 | + private String apkUrl; | ||
| 55 | + | ||
| 56 | + /** 升级提示 */ | ||
| 57 | + @Excel(name = "升级提示") | ||
| 58 | + @ApiModelProperty("升级提示") | ||
| 59 | + private String upgradePoint; | ||
| 60 | + | ||
| 61 | + /** 状态 */ | ||
| 62 | + @Excel(name = "状态") | ||
| 63 | + @ApiModelProperty("状态") | ||
| 64 | + private Integer status; | ||
| 65 | +} |
ruoyi-admin/src/main/java/com/ruoyi/upgrade/mapper/VersionUpgradeMapper.java
0 → 100644
| 1 | +package com.ruoyi.upgrade.mapper; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import com.ruoyi.upgrade.domain.VersionUpgrade; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * upgradeMapper接口 | ||
| 8 | + * | ||
| 9 | + * @author ruoyi | ||
| 10 | + * @date 2023-07-18 | ||
| 11 | + */ | ||
| 12 | +public interface VersionUpgradeMapper | ||
| 13 | +{ | ||
| 14 | + /** | ||
| 15 | + * 查询upgrade | ||
| 16 | + * | ||
| 17 | + * @param id upgrade主键 | ||
| 18 | + * @return upgrade | ||
| 19 | + */ | ||
| 20 | + public VersionUpgrade selectVersionUpgradeById(String id); | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 查询upgrade列表 | ||
| 24 | + * | ||
| 25 | + * @param versionUpgrade upgrade | ||
| 26 | + * @return upgrade集合 | ||
| 27 | + */ | ||
| 28 | + public List<VersionUpgrade> selectVersionUpgradeList(VersionUpgrade versionUpgrade); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 新增upgrade | ||
| 32 | + * | ||
| 33 | + * @param versionUpgrade upgrade | ||
| 34 | + * @return 结果 | ||
| 35 | + */ | ||
| 36 | + public int insertVersionUpgrade(VersionUpgrade versionUpgrade); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 修改upgrade | ||
| 40 | + * | ||
| 41 | + * @param versionUpgrade upgrade | ||
| 42 | + * @return 结果 | ||
| 43 | + */ | ||
| 44 | + public int updateVersionUpgrade(VersionUpgrade versionUpgrade); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 删除upgrade | ||
| 48 | + * | ||
| 49 | + * @param id upgrade主键 | ||
| 50 | + * @return 结果 | ||
| 51 | + */ | ||
| 52 | + public int deleteVersionUpgradeById(String id); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 批量删除upgrade | ||
| 56 | + * | ||
| 57 | + * @param ids 需要删除的数据主键集合 | ||
| 58 | + * @return 结果 | ||
| 59 | + */ | ||
| 60 | + public int deleteVersionUpgradeByIds(String[] ids); | ||
| 61 | + | ||
| 62 | + VersionUpgrade queryLatestVersionNum(); | ||
| 63 | +} |
ruoyi-admin/src/main/java/com/ruoyi/upgrade/service/IVersionUpgradeService.java
0 → 100644
| 1 | +package com.ruoyi.upgrade.service; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import com.ruoyi.upgrade.domain.VersionUpgrade; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * upgradeService接口 | ||
| 8 | + * | ||
| 9 | + * @author ruoyi | ||
| 10 | + * @date 2023-07-18 | ||
| 11 | + */ | ||
| 12 | +public interface IVersionUpgradeService | ||
| 13 | +{ | ||
| 14 | + /** | ||
| 15 | + * 查询upgrade | ||
| 16 | + * | ||
| 17 | + * @param id upgrade主键 | ||
| 18 | + * @return upgrade | ||
| 19 | + */ | ||
| 20 | + public VersionUpgrade selectVersionUpgradeById(String id); | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 查询upgrade列表 | ||
| 24 | + * | ||
| 25 | + * @param versionUpgrade upgrade | ||
| 26 | + * @return upgrade集合 | ||
| 27 | + */ | ||
| 28 | + public List<VersionUpgrade> selectVersionUpgradeList(VersionUpgrade versionUpgrade); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 新增upgrade | ||
| 32 | + * | ||
| 33 | + * @param versionUpgrade upgrade | ||
| 34 | + * @return 结果 | ||
| 35 | + */ | ||
| 36 | + public int insertVersionUpgrade(VersionUpgrade versionUpgrade); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 修改upgrade | ||
| 40 | + * | ||
| 41 | + * @param versionUpgrade upgrade | ||
| 42 | + * @return 结果 | ||
| 43 | + */ | ||
| 44 | + public int updateVersionUpgrade(VersionUpgrade versionUpgrade); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 批量删除upgrade | ||
| 48 | + * | ||
| 49 | + * @param ids 需要删除的upgrade主键集合 | ||
| 50 | + * @return 结果 | ||
| 51 | + */ | ||
| 52 | + public int deleteVersionUpgradeByIds(String[] ids); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 删除upgrade信息 | ||
| 56 | + * | ||
| 57 | + * @param id upgrade主键 | ||
| 58 | + * @return 结果 | ||
| 59 | + */ | ||
| 60 | + public int deleteVersionUpgradeById(String id); | ||
| 61 | +} |
ruoyi-admin/src/main/java/com/ruoyi/upgrade/service/impl/VersionUpgradeServiceImpl.java
0 → 100644
| 1 | +package com.ruoyi.upgrade.service.impl; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import com.ruoyi.common.utils.DateUtils; | ||
| 5 | +import com.ruoyi.common.utils.SecurityUtils; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.stereotype.Service; | ||
| 8 | +import com.ruoyi.upgrade.mapper.VersionUpgradeMapper; | ||
| 9 | +import com.ruoyi.upgrade.domain.VersionUpgrade; | ||
| 10 | +import com.ruoyi.upgrade.service.IVersionUpgradeService; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * upgradeService业务层处理 | ||
| 14 | + * | ||
| 15 | + * @author ruoyi | ||
| 16 | + * @date 2023-07-18 | ||
| 17 | + */ | ||
| 18 | +@Service | ||
| 19 | +public class VersionUpgradeServiceImpl implements IVersionUpgradeService | ||
| 20 | +{ | ||
| 21 | + @Autowired | ||
| 22 | + private VersionUpgradeMapper versionUpgradeMapper; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 查询upgrade | ||
| 26 | + * | ||
| 27 | + * @param id upgrade主键 | ||
| 28 | + * @return upgrade | ||
| 29 | + */ | ||
| 30 | + @Override | ||
| 31 | + public VersionUpgrade selectVersionUpgradeById(String id) | ||
| 32 | + { | ||
| 33 | + return versionUpgradeMapper.selectVersionUpgradeById(id); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 查询upgrade列表 | ||
| 38 | + * | ||
| 39 | + * @param versionUpgrade upgrade | ||
| 40 | + * @return upgrade | ||
| 41 | + */ | ||
| 42 | + @Override | ||
| 43 | + public List<VersionUpgrade> selectVersionUpgradeList(VersionUpgrade versionUpgrade) | ||
| 44 | + { | ||
| 45 | + return versionUpgradeMapper.selectVersionUpgradeList(versionUpgrade); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 新增upgrade | ||
| 50 | + * | ||
| 51 | + * @param versionUpgrade upgrade | ||
| 52 | + * @return 结果 | ||
| 53 | + */ | ||
| 54 | + @Override | ||
| 55 | + public int insertVersionUpgrade(VersionUpgrade versionUpgrade) | ||
| 56 | + { | ||
| 57 | + versionUpgrade.setCreateTime(DateUtils.getNowDate()); | ||
| 58 | + return versionUpgradeMapper.insertVersionUpgrade(versionUpgrade); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 修改upgrade | ||
| 63 | + * | ||
| 64 | + * @param versionUpgrade upgrade | ||
| 65 | + * @return 结果 | ||
| 66 | + */ | ||
| 67 | + @Override | ||
| 68 | + public int updateVersionUpgrade(VersionUpgrade versionUpgrade) | ||
| 69 | + { | ||
| 70 | + versionUpgrade.setUpdateTime(DateUtils.getNowDate()); | ||
| 71 | + return versionUpgradeMapper.updateVersionUpgrade(versionUpgrade); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * 批量删除upgrade | ||
| 76 | + * | ||
| 77 | + * @param ids 需要删除的upgrade主键 | ||
| 78 | + * @return 结果 | ||
| 79 | + */ | ||
| 80 | + @Override | ||
| 81 | + public int deleteVersionUpgradeByIds(String[] ids) | ||
| 82 | + { | ||
| 83 | + return versionUpgradeMapper.deleteVersionUpgradeByIds(ids); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * 删除upgrade信息 | ||
| 88 | + * | ||
| 89 | + * @param id upgrade主键 | ||
| 90 | + * @return 结果 | ||
| 91 | + */ | ||
| 92 | + @Override | ||
| 93 | + public int deleteVersionUpgradeById(String id) | ||
| 94 | + { | ||
| 95 | + return versionUpgradeMapper.deleteVersionUpgradeById(id); | ||
| 96 | + } | ||
| 97 | +} |
ruoyi-admin/src/main/resources/application-druid-dev.yml
ruoyi-admin/src/main/resources/mapper/upgrade/VersionUpgradeMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
| 2 | +<!DOCTYPE mapper | ||
| 3 | +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 4 | +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 5 | +<mapper namespace="com.ruoyi.upgrade.mapper.VersionUpgradeMapper"> | ||
| 6 | + | ||
| 7 | + <resultMap type="VersionUpgrade" id="VersionUpgradeResult"> | ||
| 8 | + <result property="id" column="id" /> | ||
| 9 | + <result property="appId" column="app_id" /> | ||
| 10 | + <result property="versionId" column="version_id" /> | ||
| 11 | + <result property="versionMini" column="version_mini" /> | ||
| 12 | + <result property="versionCode" column="version_code" /> | ||
| 13 | + <result property="type" column="type" /> | ||
| 14 | + <result property="apkUrl" column="apk_url" /> | ||
| 15 | + <result property="upgradePoint" column="upgrade_point" /> | ||
| 16 | + <result property="status" column="status" /> | ||
| 17 | + <result property="createTime" column="create_time" /> | ||
| 18 | + <result property="updateTime" column="update_time" /> | ||
| 19 | + </resultMap> | ||
| 20 | + | ||
| 21 | + <sql id="selectVersionUpgradeVo"> | ||
| 22 | + select id, app_id, version_id, version_mini, version_code, type, apk_url, upgrade_point, status, create_time, update_time from version_upgrade | ||
| 23 | + </sql> | ||
| 24 | + | ||
| 25 | + <select id="selectVersionUpgradeList" parameterType="VersionUpgrade" resultMap="VersionUpgradeResult"> | ||
| 26 | + <include refid="selectVersionUpgradeVo"/> | ||
| 27 | + <where> | ||
| 28 | + <if test="appId != null and appId != ''"> and app_id = #{appId}</if> | ||
| 29 | + <if test="versionId != null and versionId != ''"> and version_id = #{versionId}</if> | ||
| 30 | + <if test="versionMini != null and versionMini != ''"> and version_mini = #{versionMini}</if> | ||
| 31 | + <if test="versionCode != null and versionCode != ''"> and version_code = #{versionCode}</if> | ||
| 32 | + <if test="type != null and type != ''"> and type = #{type}</if> | ||
| 33 | + <if test="apkUrl != null and apkUrl != ''"> and apk_url = #{apkUrl}</if> | ||
| 34 | + <if test="upgradePoint != null and upgradePoint != ''"> and upgrade_point = #{upgradePoint}</if> | ||
| 35 | + <if test="status != null "> and status = #{status}</if> | ||
| 36 | + </where> | ||
| 37 | + </select> | ||
| 38 | + | ||
| 39 | + <select id="selectVersionUpgradeById" parameterType="String" resultMap="VersionUpgradeResult"> | ||
| 40 | + <include refid="selectVersionUpgradeVo"/> | ||
| 41 | + where id = #{id} | ||
| 42 | + </select> | ||
| 43 | + <select id="queryLatestVersionNum" resultType="com.ruoyi.upgrade.domain.VersionUpgrade"> | ||
| 44 | + <include refid="selectVersionUpgradeVo"></include> | ||
| 45 | + order by create_time desc | ||
| 46 | + limit 1 | ||
| 47 | + </select> | ||
| 48 | + | ||
| 49 | + <insert id="insertVersionUpgrade" parameterType="VersionUpgrade" useGeneratedKeys="true" keyProperty="id"> | ||
| 50 | + insert into version_upgrade | ||
| 51 | + <trim prefix="(" suffix=")" suffixOverrides=","> | ||
| 52 | + <if test="appId != null and appId != ''">app_id,</if> | ||
| 53 | + <if test="versionId != null">version_id,</if> | ||
| 54 | + <if test="versionMini != null">version_mini,</if> | ||
| 55 | + <if test="versionCode != null">version_code,</if> | ||
| 56 | + <if test="type != null">type,</if> | ||
| 57 | + <if test="apkUrl != null">apk_url,</if> | ||
| 58 | + <if test="upgradePoint != null">upgrade_point,</if> | ||
| 59 | + <if test="status != null">status,</if> | ||
| 60 | + <if test="createTime != null">create_time,</if> | ||
| 61 | + <if test="updateTime != null">update_time,</if> | ||
| 62 | + </trim> | ||
| 63 | + <trim prefix="values (" suffix=")" suffixOverrides=","> | ||
| 64 | + <if test="appId != null and appId != ''">#{appId},</if> | ||
| 65 | + <if test="versionId != null">#{versionId},</if> | ||
| 66 | + <if test="versionMini != null">#{versionMini},</if> | ||
| 67 | + <if test="versionCode != null">#{versionCode},</if> | ||
| 68 | + <if test="type != null">#{type},</if> | ||
| 69 | + <if test="apkUrl != null">#{apkUrl},</if> | ||
| 70 | + <if test="upgradePoint != null">#{upgradePoint},</if> | ||
| 71 | + <if test="status != null">#{status},</if> | ||
| 72 | + <if test="createTime != null">#{createTime},</if> | ||
| 73 | + <if test="updateTime != null">#{updateTime},</if> | ||
| 74 | + </trim> | ||
| 75 | + </insert> | ||
| 76 | + | ||
| 77 | + <update id="updateVersionUpgrade" parameterType="VersionUpgrade"> | ||
| 78 | + update version_upgrade | ||
| 79 | + <trim prefix="SET" suffixOverrides=","> | ||
| 80 | + <if test="appId != null and appId != ''">app_id = #{appId},</if> | ||
| 81 | + <if test="versionId != null">version_id = #{versionId},</if> | ||
| 82 | + <if test="versionMini != null">version_mini = #{versionMini},</if> | ||
| 83 | + <if test="versionCode != null">version_code = #{versionCode},</if> | ||
| 84 | + <if test="type != null">type = #{type},</if> | ||
| 85 | + <if test="apkUrl != null">apk_url = #{apkUrl},</if> | ||
| 86 | + <if test="upgradePoint != null">upgrade_point = #{upgradePoint},</if> | ||
| 87 | + <if test="status != null">status = #{status},</if> | ||
| 88 | + <if test="createTime != null">create_time = #{createTime},</if> | ||
| 89 | + <if test="updateTime != null">update_time = #{updateTime},</if> | ||
| 90 | + </trim> | ||
| 91 | + where id = #{id} | ||
| 92 | + </update> | ||
| 93 | + | ||
| 94 | + <delete id="deleteVersionUpgradeById" parameterType="String"> | ||
| 95 | + delete from version_upgrade where id = #{id} | ||
| 96 | + </delete> | ||
| 97 | + | ||
| 98 | + <delete id="deleteVersionUpgradeByIds" parameterType="String"> | ||
| 99 | + delete from version_upgrade where id in | ||
| 100 | + <foreach item="id" collection="array" open="(" separator="," close=")"> | ||
| 101 | + #{id} | ||
| 102 | + </foreach> | ||
| 103 | + </delete> | ||
| 104 | +</mapper> | ||
| 0 | \ No newline at end of file | 105 | \ No newline at end of file |
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java
| @@ -43,7 +43,7 @@ public class FileUtils | @@ -43,7 +43,7 @@ public class FileUtils | ||
| 43 | File file = new File(filePath); | 43 | File file = new File(filePath); |
| 44 | if (!file.exists()) | 44 | if (!file.exists()) |
| 45 | { | 45 | { |
| 46 | - throw new FileNotFoundException(filePath); | 46 | + throw new FileNotFoundException("路径不存在"+filePath); |
| 47 | } | 47 | } |
| 48 | fis = new FileInputStream(file); | 48 | fis = new FileInputStream(file); |
| 49 | byte[] b = new byte[1024]; | 49 | byte[] b = new byte[1024]; |