update:
1. update check-update api
This commit is contained in:
@@ -11,6 +11,8 @@ import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.modules.common.pojo.dto.CommonReleaseVersionDTO;
|
||||
import org.springblade.modules.common.pojo.vo.CommonReleaseVersionDetailVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.modules.common.pojo.entity.CommonReleaseVersionEntity;
|
||||
@@ -19,6 +21,8 @@ import org.springblade.modules.common.wrapper.CommonReleaseVersionWrapper;
|
||||
import org.springblade.modules.common.service.ICommonReleaseVersionService;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* APP版本发布管理 控制器
|
||||
@@ -39,28 +43,39 @@ public class CommonReleaseVersionController extends BladeController {
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入commonReleaseversion")
|
||||
@Operation(summary = "详情", description = "传入commonReleaseversion")
|
||||
public R<CommonReleaseVersionVO> detail(CommonReleaseVersionEntity commonReleaseVersion) {
|
||||
CommonReleaseVersionEntity detail = commonReleaseVersionService.getOne(Condition.getQueryWrapper(commonReleaseVersion));
|
||||
return R.data(CommonReleaseVersionWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* APP版本发布管理 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入commonReleaseversion")
|
||||
@Operation(summary = "分页", description = "传入commonReleaseversion")
|
||||
public R<IPage<CommonReleaseVersionVO>> list(CommonReleaseVersionEntity commonReleaseVersion, Query query) {
|
||||
IPage<CommonReleaseVersionEntity> pages = commonReleaseVersionService.page(Condition.getPage(query), Condition.getQueryWrapper(commonReleaseVersion).orderByDesc("id"));
|
||||
return R.data(CommonReleaseVersionWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* APP版本发布管理 详情查询
|
||||
*/
|
||||
@GetMapping("/detail-list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "详情查询", description = "传入versionName、appType")
|
||||
public R<List<CommonReleaseVersionDetailVO>> detailList(String versionName, Integer appType) {
|
||||
return R.data(commonReleaseVersionService.selectDetaiList(versionName, appType));
|
||||
}
|
||||
|
||||
/**
|
||||
* APP版本发布管理 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入commonReleaseversion")
|
||||
@Operation(summary = "分页", description = "传入commonReleaseversion")
|
||||
public R<IPage<CommonReleaseVersionVO>> page(CommonReleaseVersionVO commonReleaseVersion, Query query) {
|
||||
IPage<CommonReleaseVersionVO> pages = commonReleaseVersionService.selectCommonReleaseVersionPage(Condition.getPage(query), commonReleaseVersion);
|
||||
return R.data(pages);
|
||||
@@ -72,7 +87,7 @@ public class CommonReleaseVersionController extends BladeController {
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入vo")
|
||||
@Operation(summary = "新增", description = "传入vo")
|
||||
public R save(@Valid @RequestBody CommonReleaseVersionVO vo) {
|
||||
return R.status(commonReleaseVersionService.createVersion(vo));
|
||||
}
|
||||
@@ -82,7 +97,7 @@ public class CommonReleaseVersionController extends BladeController {
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入commonReleaseversion")
|
||||
@Operation(summary = "修改", description = "传入commonReleaseversion")
|
||||
public R update(@Valid @RequestBody CommonReleaseVersionEntity commonReleaseVersion) {
|
||||
return R.status(commonReleaseVersionService.updateById(commonReleaseVersion));
|
||||
}
|
||||
@@ -92,7 +107,7 @@ public class CommonReleaseVersionController extends BladeController {
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入commonReleaseversion")
|
||||
@Operation(summary = "新增或修改", description = "传入commonReleaseversion")
|
||||
public R submit(@Valid @RequestBody CommonReleaseVersionEntity commonReleaseVersion) {
|
||||
return R.status(commonReleaseVersionService.saveOrUpdate(commonReleaseVersion));
|
||||
}
|
||||
@@ -102,16 +117,16 @@ public class CommonReleaseVersionController extends BladeController {
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(commonReleaseVersionService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/applyStatus")
|
||||
@PostMapping("/publish")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "上下架版本信息", description = "releaseVersion.id")
|
||||
public R applyStatus(CommonReleaseVersionEntity releaseVersion) {
|
||||
return R.status(commonReleaseVersionService.applyStatus(releaseVersion.getId()));
|
||||
@Operation(summary = "上架版本")
|
||||
public R publish(@Valid @RequestBody CommonReleaseVersionDTO dto) {
|
||||
return R.status(commonReleaseVersionService.publish(dto.getId(), dto.getDownloadUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum VersionStatus {
|
||||
ENABLED(1, "启用"),
|
||||
ENABLED(1, "已启用"),
|
||||
PUBLISHED(2, "已上架"),
|
||||
EXPIRED(3, "过期");
|
||||
EXPIRED(3, "已过期");
|
||||
|
||||
private final int code;
|
||||
private final String description;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.springblade.modules.common.mapper;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonReleaseVersionEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonReleaseVersionDetailVO;
|
||||
import org.springblade.modules.common.pojo.vo.CommonReleaseVersionVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -25,6 +26,6 @@ public interface CommonReleaseVersionMapper extends BaseMapper<CommonReleaseVers
|
||||
|
||||
List<CommonReleaseVersionVO> selectCustomerCommonReleaseVersionPage(IPage page, CommonReleaseVersionVO commonReleaseVersion);
|
||||
|
||||
|
||||
List<CommonReleaseVersionDetailVO> selectDetaiList(String versionName, Integer appType);
|
||||
|
||||
}
|
||||
|
||||
@@ -43,5 +43,12 @@
|
||||
ORDER BY string_to_array(version_name, '.')::int[] DESC, app_type, id DESC
|
||||
</select>
|
||||
|
||||
<select id="selectDetaiList" resultType="org.springblade.modules.common.pojo.vo.CommonReleaseVersionDetailVO">
|
||||
select id, channel_code, download_url, status
|
||||
from release_version
|
||||
where is_deleted = 0
|
||||
and version_name = #{versionName}
|
||||
and app_type = #{appType}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -25,10 +25,13 @@
|
||||
*/
|
||||
package org.springblade.modules.common.pojo.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springblade.modules.common.pojo.entity.CommonReleaseVersionEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* APP版本发布管理 数据传输对象实体类
|
||||
@@ -37,9 +40,14 @@ import java.io.Serial;
|
||||
* @since 2026-04-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CommonReleaseVersionDTO extends CommonReleaseVersionEntity {
|
||||
public class CommonReleaseVersionDTO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "ID 不能为空")
|
||||
private Long id;
|
||||
|
||||
@NotBlank(message = "上架链接不能为空")
|
||||
private String downloadUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.modules.common.pojo.vo;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* APP版本发布管理 视图实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-01
|
||||
*/
|
||||
@Data
|
||||
public class CommonReleaseVersionDetailVO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String channelCode;
|
||||
|
||||
private String downloadUrl;
|
||||
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
package org.springblade.modules.common.service;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springblade.modules.api.response.CheckVersionResponse;
|
||||
import org.springblade.modules.common.pojo.entity.CommonReleaseVersionEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonReleaseVersionDetailVO;
|
||||
import org.springblade.modules.common.pojo.vo.CommonReleaseVersionVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP版本发布管理 服务类
|
||||
*
|
||||
@@ -28,4 +33,8 @@ public interface ICommonReleaseVersionService extends BaseService<CommonReleaseV
|
||||
CheckVersionResponse checkUpdate(Integer type, String version, String brand);
|
||||
|
||||
boolean createVersion(CommonReleaseVersionVO vo);
|
||||
|
||||
List<CommonReleaseVersionDetailVO> selectDetaiList(String versionName, Integer appType);
|
||||
|
||||
boolean publish(Long id, String downloadUrl);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import jakarta.validation.Valid;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.semver4j.Semver;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.modules.api.response.CheckVersionResponse;
|
||||
import org.springblade.modules.common.convert.CommonReleaseVersionConvert;
|
||||
import org.springblade.modules.common.eums.AppMarketChannelEnum;
|
||||
@@ -13,6 +14,7 @@ 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.pojo.entity.CommonReleaseVersionEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonReleaseVersionDetailVO;
|
||||
import org.springblade.modules.common.pojo.vo.CommonReleaseVersionVO;
|
||||
import org.springblade.modules.common.mapper.CommonReleaseVersionMapper;
|
||||
import org.springblade.modules.common.service.ICommonReleaseVersionService;
|
||||
@@ -136,6 +138,33 @@ public class CommonReleaseVersionServiceImpl extends BaseServiceImpl<CommonRelea
|
||||
return saveBatch(versionList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonReleaseVersionDetailVO> selectDetaiList(String versionName, Integer appType) {
|
||||
return baseMapper.selectDetaiList(versionName, appType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean publish(Long id, String downloadUrl) {
|
||||
if (id == null || StringUtil.isBlank(downloadUrl)) {
|
||||
throw new IllegalArgumentException("ID 和下载链接不能为空");
|
||||
}
|
||||
|
||||
CommonReleaseVersionEntity existing = getById(id);
|
||||
if (existing == null) {
|
||||
throw new ServiceException("版本不存在");
|
||||
}
|
||||
if (VersionStatus.PUBLISHED.getCode() == existing.getStatus()) {
|
||||
throw new ServiceException("版本已上架,不可重复操作");
|
||||
}
|
||||
|
||||
if (StringUtil.isBlank(downloadUrl)) {
|
||||
throw new ServiceException("下载链接不能为空");
|
||||
}
|
||||
existing.setDownloadUrl(downloadUrl);
|
||||
existing.setStatus(VersionStatus.PUBLISHED.getCode());
|
||||
return updateById(existing);
|
||||
}
|
||||
|
||||
private static CommonReleaseVersionEntity getCommonReleaseVersionEntity(CommonReleaseVersionVO vo) {
|
||||
CommonReleaseVersionEntity entity = new CommonReleaseVersionEntity();
|
||||
// 手动设 VO 特有字段(或也可用另一个 MapStruct VO->Entity)
|
||||
|
||||
Reference in New Issue
Block a user