新增版本管理
parent
2086b90ce7
commit
1b31218d57
@ -0,0 +1,31 @@
|
||||
package com.ruoyi.web.controller.pc;
|
||||
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.system.domain.AppVersionsInfo;
|
||||
import com.ruoyi.system.service.IAppVersionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 版本管理
|
||||
*
|
||||
* @author gongzhenkun
|
||||
* @date 2022/10/8 14:27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/version")
|
||||
public class AppVersionController {
|
||||
@Autowired
|
||||
private IAppVersionService appVersionService;
|
||||
|
||||
@GetMapping("/queryAll")
|
||||
public AjaxResult queryAllVersions() {
|
||||
AppVersionsInfo allVersions = appVersionService.selectAllVersions(RuoYiConfig.getAppVersionPath());
|
||||
return AjaxResult.success(allVersions);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* app版本信息实体
|
||||
*
|
||||
* @author gongzhenkun
|
||||
* @date 2022/10/8 15:45
|
||||
*/
|
||||
public class AppVersionsInfo {
|
||||
private String baseURL;
|
||||
|
||||
private List<String> versions;
|
||||
|
||||
public String getBaseURL() {
|
||||
return baseURL;
|
||||
}
|
||||
|
||||
public void setBaseURL(String baseURL) {
|
||||
this.baseURL = baseURL;
|
||||
}
|
||||
|
||||
public List<String> getVersions() {
|
||||
return versions;
|
||||
}
|
||||
|
||||
public void setVersions(List<String> versions) {
|
||||
this.versions = versions;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.system.domain.AppVersionsInfo;
|
||||
import com.ruoyi.system.domain.SysConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* app版服务
|
||||
*
|
||||
* @author gongzhenkun
|
||||
* @date 2022/10/08
|
||||
*/
|
||||
public interface IAppVersionService {
|
||||
|
||||
/**
|
||||
* 查询app所有版本
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
* @return {@code List<String>}
|
||||
*/
|
||||
public AppVersionsInfo selectAllVersions(String folderPath);
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.system.domain.AppVersionsInfo;
|
||||
import com.ruoyi.system.service.IAppVersionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* app版本服务impl
|
||||
*
|
||||
* @author gongzhenkun
|
||||
* @date 2022/10/08
|
||||
*/
|
||||
@Service
|
||||
public class AppVersionServiceImpl implements IAppVersionService {
|
||||
/**
|
||||
* 查询所有版本
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
* @return {@code List<String>}
|
||||
*/
|
||||
@Override
|
||||
public AppVersionsInfo selectAllVersions(String folderPath) {
|
||||
AppVersionsInfo appVersionsInfo = new AppVersionsInfo();
|
||||
List<String> files = FileUtils.scanFilesWithPath(folderPath);
|
||||
files = files.stream()
|
||||
.filter(s -> s.contains(".apk"))
|
||||
.map(s -> s.replaceAll("\\\\", "/"))
|
||||
.map(s -> s.replace(RuoYiConfig.getProfile(), "/profile/"))
|
||||
.collect(Collectors.toList());
|
||||
String relativePath = files.get(0);
|
||||
String baseURL = relativePath.substring(0, relativePath.lastIndexOf("/") + 1);
|
||||
appVersionsInfo.setBaseURL(baseURL);
|
||||
appVersionsInfo.setVersions(files.stream().map(s -> s.replace(baseURL, "")).collect(Collectors.toList()));
|
||||
return appVersionsInfo;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue