版本管理 和 版本文件上传

This commit is contained in:
2024-08-28 15:45:46 +08:00
parent 09c6cd178a
commit 17fc234975
15 changed files with 129 additions and 27 deletions

View File

@@ -40,6 +40,14 @@ public class TbVersionController {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@PutMapping("upSel")
@ApiOperation("修改当前选中")
public ResponseEntity<Object> updateSel(@Validated @RequestBody TbVersion resources){
tbVersionService.updateSel(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@ApiOperation("删除版本")
public ResponseEntity<Object> deleteTbVersion(@RequestBody Integer[] ids) {

View File

@@ -14,7 +14,7 @@ public class TbVersionDto implements Serializable {
private Integer id;
/** LDBL_APP;WX; */
/** PC;APP; */
private String source;
/** ios;android; */
@@ -22,9 +22,12 @@ public class TbVersionDto implements Serializable {
/** 版本号 */
private String version;
/** 下载地址 */
private String url;
/** 0不更新1更新 */
/** 是否强制更新 0否 1 */
private Integer isUp;
private Integer sel;
/** 更新提示内容 */
private String message;

View File

@@ -12,7 +12,7 @@ import lombok.Data;
public class TbVersionQueryCriteria{
@Query
/** LDBL-APP;WX; */
/** PCAPP; */
private String source;
@Query
/** ios;android; */
@@ -21,7 +21,7 @@ public class TbVersionQueryCriteria{
/** 版本号 */
private String version;
@Query
/** 0不更新1更新 */
/** 是否强制更新 0否 1*/
private Integer isUp;
private Integer pageSize;

View File

@@ -19,7 +19,7 @@ public class TbVersion implements Serializable {
private Integer id;
@Column(name = "`source`")
@ApiModelProperty(value = "LDBL-APP;WX;")
@ApiModelProperty(value = "PCAPP;")
private String source;
@Column(name = "`type`")
@@ -30,10 +30,17 @@ public class TbVersion implements Serializable {
@ApiModelProperty(value = "版本号")
private String version;
@Column(name = "`url`")
@ApiModelProperty(value = "下载地址")
private String url;
@Column(name = "`is_up`")
@ApiModelProperty(value = "0不更新1更新")
@ApiModelProperty(value = "是否强制更新 0否 1")
private Integer isUp;
@ApiModelProperty(value = "选中 0否 1")
private Integer sel;
@Column(name = "`message`")
@ApiModelProperty(value = "更新提示内容")
private String message;

View File

@@ -4,6 +4,7 @@ import cn.ysk.cashier.pojo.TbVersion;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
/**
@@ -15,4 +16,15 @@ public interface TbVersionRepository extends JpaRepository<TbVersion, Integer>,
@Query("SELECT count(1) FROM TbVersion WHERE source = :source AND type =:type AND version =:version")
int isExist(@Param("source") String source, @Param("type") String type, @Param("version") String version);
@Query("SELECT count(1) FROM TbVersion WHERE source = :source AND version =:version")
int isExist(@Param("source") String source, @Param("version") String version);
@Modifying
@Query("update TbVersion version set version.sel=CASE" +
" WHEN version.source=:source AND version.id=:id THEN 1 " +
" WHEN version.source=:source AND version.id!=:id THEN 0 " +
" ELSE version.sel END " +
" WHERE version.source = :source")
int updateSelBySource(@Param("source") String source, @Param("id") Integer id);
}

View File

@@ -52,6 +52,8 @@ public interface TbVersionService {
*/
void update(TbVersion resources);
void updateSel(TbVersion resources);
/**
* 多选删除
* @param ids /

View File

@@ -7,10 +7,7 @@ import cn.ysk.cashier.mapper.TbVersionMapper;
import cn.ysk.cashier.pojo.TbVersion;
import cn.ysk.cashier.repository.TbVersionRepository;
import cn.ysk.cashier.service.TbVersionService;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.RedisUtils;
import cn.ysk.cashier.utils.ValidationUtil;
import cn.ysk.cashier.utils.*;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@@ -61,17 +58,17 @@ public class TbVersionServiceImpl implements TbVersionService {
@Override
@Transactional(rollbackFor = Exception.class)
public TbVersionDto create(TbVersion resources) {
int exist = tbVersionRepository.isExist(resources.getSource(), resources.getType(), resources.getVersion());
int exist = tbVersionRepository.isExist(resources.getSource(), resources.getVersion());
if (exist > 0) {
throw new BadRequestException("该版本已存在。");
}
resources.setCreatedAt(Instant.now().toEpochMilli());
TbVersionDto dto = tbVersionMapper.toDto(tbVersionRepository.save(resources));
if (dto.getIsUp() == 1) {
//产品标识:型号:版本
//LDBL_APP_VERSION:ios:version 存在即需要强制更新
redisUtils.set(dto.getSource() + "_VERSION:" + dto.getType() + ":" + dto.getVersion(), dto.getMessage());
}
// if (dto.getIsUp() == 1) {
// //产品标识:型号:版本
// //VERSION:PC::version 存在即需要强制更新
// redisUtils.set(CacheKey.VERSION + dto.getSource() + ":" + dto.getVersion(), dto);
// }
return dto;
}
@@ -80,17 +77,23 @@ public class TbVersionServiceImpl implements TbVersionService {
public void update(TbVersion resources) {
TbVersion tbVersion = tbVersionRepository.findById(resources.getId()).orElseGet(TbVersion::new);
ValidationUtil.isNull(tbVersion.getId(), "TbVersion", "id", resources.getId());
redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
// redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
tbVersion.copy(resources);
tbVersion.setUpdatedAt(Instant.now().toEpochMilli());
tbVersionRepository.save(tbVersion);
if (resources.getIsUp() == 1) {
//产品标识:型号:版本
//LDBL_APP_VERSION:ios:version 存在即需要强制更新
redisUtils.set(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion(), tbVersion.getMessage());
} else {
redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
}
// if (resources.getIsUp() == 1) {
// //产品标识:型号:版本
// //LDBL_APP_VERSION:ios:version 存在即需要强制更新
// redisUtils.set(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion(), tbVersion.getMessage());
// } else {
// redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
// }
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateSel(TbVersion resources) {
tbVersionRepository.updateSelBySource(resources.getSource(),resources.getId());
}
@Override
@@ -99,9 +102,9 @@ public class TbVersionServiceImpl implements TbVersionService {
TbVersion tbVersion = tbVersionRepository.findById(id).orElseGet(TbVersion::new);
ValidationUtil.isNull(tbVersion.getId(), "TbVersion", "id", id);
tbVersionRepository.deleteById(id);
if (tbVersion.getIsUp() == 1) {
redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
}
// if (tbVersion.getIsUp() == 1) {
// redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
// }
}
}