feat:
1. add check-update api
This commit is contained in:
@@ -2,13 +2,13 @@ DROP TABLE IF EXISTS release_version CASCADE;
|
|||||||
CREATE TABLE release_version
|
CREATE TABLE release_version
|
||||||
(
|
(
|
||||||
id int8 NOT NULL PRIMARY KEY, -- 主键ID
|
id int8 NOT NULL PRIMARY KEY, -- 主键ID
|
||||||
version_code varchar(20) NULL, -- 内部版本号 (如: 10023)
|
version_code int8 NULL, -- 内部版本号 (如: 10023)
|
||||||
version_name varchar(50) NOT NULL, -- 版本显示名称 (如: 1.2.3)
|
version_name varchar(50) NOT NULL, -- 版本显示名称 (如: 1.2.3)
|
||||||
app_type int4 NOT NULL, -- 应用类型: 1-app, 2-market
|
app_type int4 NOT NULL, -- 应用类型: 1-app, 2-market
|
||||||
channel_code varchar(20) NOT NULL, -- 渠道标识: xiaomi, huawei, honor, oppo, vivo, apple, qihoo, yingyongbao, pgyer, official
|
channel_code varchar(20) NOT NULL, -- 渠道标识: xiaomi, huawei, honor, oppo, vivo, apple, qihoo, yingyongbao, pgyer, official
|
||||||
package_type int4 NOT NULL, -- 包类型: 1-应用市场包(含跳转链接), 2-OSS直连包(兜底)
|
package_type int4 NOT NULL, -- 包类型: 1-应用市场包(含跳转链接), 2-OSS直连包(兜底)
|
||||||
is_force_update int4 NOT NULL, -- 是否强制更新: 0-否, 1-是
|
is_force_update int4 NOT NULL, -- 是否强制更新: 0-否, 1-是
|
||||||
download_url varchar(255) NULL, -- 下载地址 (市场包通常为 schema 链接, OSS包为 http 链接)
|
download_url varchar(255) NULL, -- 下载地址 (市场包通常为 schema 链接, OSS包为 http 链接)
|
||||||
update_content text NOT NULL, -- 更新日志内容
|
update_content text NOT NULL, -- 更新日志内容
|
||||||
privacy_agreement_url varchar(255) NULL, -- 隐私协议地址
|
privacy_agreement_url varchar(255) NULL, -- 隐私协议地址
|
||||||
user_agreement_url varchar(255) NULL, -- 用户协议地址
|
user_agreement_url varchar(255) NULL, -- 用户协议地址
|
||||||
|
|||||||
@@ -11,5 +11,20 @@ public class CheckVersionResponse implements Serializable {
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Boolean needUpdate = Boolean.FALSE;
|
||||||
|
|
||||||
|
private Boolean isForceUpdate = Boolean.FALSE;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private String qihooUrl;
|
||||||
|
|
||||||
|
private String yingyongbaoUrl;
|
||||||
|
|
||||||
|
private String updateContent;
|
||||||
|
|
||||||
|
private String webDownloadUrl;
|
||||||
|
|
||||||
|
private String fallbackUrl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class CommonReleaseVersionEntity extends BaseEntity {
|
|||||||
* 内部版本号 (如: 10023)
|
* 内部版本号 (如: 10023)
|
||||||
*/
|
*/
|
||||||
@Schema(description = "内部版本号 (如: 10023)")
|
@Schema(description = "内部版本号 (如: 10023)")
|
||||||
private String versionCode;
|
private Integer versionCode;
|
||||||
/**
|
/**
|
||||||
* 版本显示名称 (如: 1.2.3)
|
* 版本显示名称 (如: 1.2.3)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.springblade.modules.api.response.CheckVersionResponse;
|
|||||||
import org.springblade.modules.common.convert.CommonReleaseVersionConvert;
|
import org.springblade.modules.common.convert.CommonReleaseVersionConvert;
|
||||||
import org.springblade.modules.common.eums.AppMarketChannelEnum;
|
import org.springblade.modules.common.eums.AppMarketChannelEnum;
|
||||||
import org.springblade.modules.common.eums.AppType;
|
import org.springblade.modules.common.eums.AppType;
|
||||||
|
import org.springblade.modules.common.eums.PhoneBrand;
|
||||||
import org.springblade.modules.common.eums.VersionStatus;
|
import org.springblade.modules.common.eums.VersionStatus;
|
||||||
import org.springblade.modules.common.pojo.entity.CommonReleaseVersionEntity;
|
import org.springblade.modules.common.pojo.entity.CommonReleaseVersionEntity;
|
||||||
import org.springblade.modules.common.pojo.vo.CommonReleaseVersionVO;
|
import org.springblade.modules.common.pojo.vo.CommonReleaseVersionVO;
|
||||||
@@ -24,6 +25,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APP版本发布管理 服务实现类
|
* APP版本发布管理 服务实现类
|
||||||
@@ -51,7 +53,48 @@ public class CommonReleaseVersionServiceImpl extends BaseServiceImpl<CommonRelea
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CheckVersionResponse checkUpdate(Integer type, String version, String brand) {
|
public CheckVersionResponse checkUpdate(Integer type, String version, String brand) {
|
||||||
return null;
|
CheckVersionResponse response = new CheckVersionResponse();
|
||||||
|
List<CommonReleaseVersionEntity> list = list(Wrappers.lambdaQuery(CommonReleaseVersionEntity.class)
|
||||||
|
.eq(CommonReleaseVersionEntity::getAppType, type)
|
||||||
|
.gt(CommonReleaseVersionEntity::getVersionCode, convertVersionNameToVersionCode(version))
|
||||||
|
.in(CommonReleaseVersionEntity::getChannelCode, List.of(PhoneBrand.fromString(brand).getCode(), AppMarketChannelEnum.PGYER.getCode(), AppMarketChannelEnum.QIHOO.getCode(), AppMarketChannelEnum.OFFICIAL.getCode()))
|
||||||
|
.eq(CommonReleaseVersionEntity::getStatus, VersionStatus.PUBLISHED.getCode())
|
||||||
|
.eq(CommonReleaseVersionEntity::getIsDeleted, 0)
|
||||||
|
.orderByDesc(CommonReleaseVersionEntity::getVersionCode)
|
||||||
|
);
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
response.setNeedUpdate(Boolean.TRUE);
|
||||||
|
boolean f = false;
|
||||||
|
int code = list.get(0).getVersionCode();
|
||||||
|
List<CommonReleaseVersionEntity> newestList = new ArrayList<>();
|
||||||
|
for (CommonReleaseVersionEntity entity : list) {
|
||||||
|
if (!f && Objects.equals(entity.getIsForceUpdate(), 1)) {
|
||||||
|
f = true;
|
||||||
|
}
|
||||||
|
if (entity.getVersionCode() == code) {
|
||||||
|
newestList.add(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (CommonReleaseVersionEntity entity : newestList) {
|
||||||
|
if (PhoneBrand.fromString(brand).getCode().equalsIgnoreCase(entity.getChannelCode())) {
|
||||||
|
response.setUrl(entity.getDownloadUrl());
|
||||||
|
}
|
||||||
|
if (AppMarketChannelEnum.QIHOO.getCode().equalsIgnoreCase(entity.getChannelCode())) {
|
||||||
|
response.setQihooUrl(entity.getDownloadUrl());
|
||||||
|
}
|
||||||
|
if (AppMarketChannelEnum.YINGYONGBAO.getCode().equalsIgnoreCase(entity.getChannelCode())) {
|
||||||
|
response.setQihooUrl(entity.getDownloadUrl());
|
||||||
|
}
|
||||||
|
if (AppMarketChannelEnum.PGYER.getCode().equalsIgnoreCase(entity.getChannelCode())) {
|
||||||
|
response.setWebDownloadUrl(entity.getDownloadUrl());
|
||||||
|
}
|
||||||
|
if (AppMarketChannelEnum.OFFICIAL.getCode().equalsIgnoreCase(entity.getChannelCode())) {
|
||||||
|
response.setFallbackUrl(entity.getDownloadUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.setIsForceUpdate(f);
|
||||||
|
}
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,7 +104,7 @@ public class CommonReleaseVersionServiceImpl extends BaseServiceImpl<CommonRelea
|
|||||||
if (appType == null) {
|
if (appType == null) {
|
||||||
throw new ServiceException("无效类型");
|
throw new ServiceException("无效类型");
|
||||||
}
|
}
|
||||||
Semver semver = parseSemver((vo.getVersionName()));
|
Semver semver = new Semver(vo.getVersionName());
|
||||||
CommonReleaseVersionEntity current = baseMapper.selectOne(
|
CommonReleaseVersionEntity current = baseMapper.selectOne(
|
||||||
Wrappers.lambdaQuery(CommonReleaseVersionEntity.class)
|
Wrappers.lambdaQuery(CommonReleaseVersionEntity.class)
|
||||||
.eq(CommonReleaseVersionEntity::getAppType, vo.getAppType())
|
.eq(CommonReleaseVersionEntity::getAppType, vo.getAppType())
|
||||||
@@ -71,7 +114,7 @@ public class CommonReleaseVersionServiceImpl extends BaseServiceImpl<CommonRelea
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
Semver currentSemver = parseSemver(current.getVersionName());
|
Semver currentSemver = new Semver(current.getVersionName());
|
||||||
if (currentSemver.isGreaterThan(semver)) {
|
if (currentSemver.isGreaterThan(semver)) {
|
||||||
throw new ServiceException("当前版本号过小");
|
throw new ServiceException("当前版本号过小");
|
||||||
}
|
}
|
||||||
@@ -93,6 +136,7 @@ public class CommonReleaseVersionServiceImpl extends BaseServiceImpl<CommonRelea
|
|||||||
private static CommonReleaseVersionEntity getCommonReleaseVersionEntity(CommonReleaseVersionVO vo) {
|
private static CommonReleaseVersionEntity getCommonReleaseVersionEntity(CommonReleaseVersionVO vo) {
|
||||||
CommonReleaseVersionEntity entity = new CommonReleaseVersionEntity();
|
CommonReleaseVersionEntity entity = new CommonReleaseVersionEntity();
|
||||||
// 手动设 VO 特有字段(或也可用另一个 MapStruct VO->Entity)
|
// 手动设 VO 特有字段(或也可用另一个 MapStruct VO->Entity)
|
||||||
|
entity.setVersionCode(convertVersionNameToVersionCode(vo.getVersionName()));
|
||||||
entity.setVersionName(vo.getVersionName());
|
entity.setVersionName(vo.getVersionName());
|
||||||
entity.setAppType(vo.getAppType());
|
entity.setAppType(vo.getAppType());
|
||||||
entity.setPrivacyAgreementUrl(vo.getPrivacyAgreementUrl());
|
entity.setPrivacyAgreementUrl(vo.getPrivacyAgreementUrl());
|
||||||
@@ -110,12 +154,9 @@ public class CommonReleaseVersionServiceImpl extends BaseServiceImpl<CommonRelea
|
|||||||
return CommonReleaseVersionConvert.INSTANCE.copyForChannel(entity, channel);
|
return CommonReleaseVersionConvert.INSTANCE.copyForChannel(entity, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Integer convertVersionNameToVersionCode(String versionName) {
|
||||||
private Semver parseSemver(String versionName) {
|
Semver semver = new Semver(versionName);
|
||||||
Semver semver = Semver.coerce(versionName);
|
return semver.getMajor() * 1000000 + semver.getMinor() * 1000 + semver.getPatch();
|
||||||
if (semver == null) {
|
|
||||||
throw new ServiceException("无效版本号: " + versionName);
|
|
||||||
}
|
|
||||||
return semver;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,6 +257,8 @@ blade:
|
|||||||
- /app-tour/product-list
|
- /app-tour/product-list
|
||||||
- /app-tour/product-top-list
|
- /app-tour/product-top-list
|
||||||
- /blade-pay/callback/**
|
- /blade-pay/callback/**
|
||||||
|
- /app/common/version
|
||||||
|
- /market/common/version
|
||||||
|
|
||||||
#授权认证配置
|
#授权认证配置
|
||||||
auth:
|
auth:
|
||||||
|
|||||||
Reference in New Issue
Block a user