feat:添加APP版本管理相关代码
This commit is contained in:
@@ -13,6 +13,13 @@
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<!-- 其他依赖版本 -->
|
||||
<lombok.version>1.18.30</lombok.version>
|
||||
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
|
||||
<junrar.version>7.5.5</junrar.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
@@ -48,9 +55,11 @@
|
||||
<artifactId>blade-mk-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 其他依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${org.mapstruct.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -80,6 +89,34 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven.plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${org.mapstruct.version}</version>
|
||||
</path>
|
||||
<!-- other annotation processors -->
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* 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.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.AppVersion;
|
||||
import org.springblade.system.service.AppVersionService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("appVersion")
|
||||
@Tag(name = "APP版本管理", description = "APP版本管理")
|
||||
public class AppVersionController extends BladeController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(AppVersionController.class);
|
||||
|
||||
private final AppVersionService appVersionService;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "分页")
|
||||
public R<IPage<AppVersion>> page(AppVersion modelVo, Query query) {
|
||||
try {
|
||||
return R.data(appVersionService.page(modelVo,query));
|
||||
} catch (Exception e) {
|
||||
logger.error("appVersion/page:" + e.getMessage());
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail/{id}")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "详情")
|
||||
public R<AppVersion> detail(@PathVariable Long id) {
|
||||
try {
|
||||
return R.data(appVersionService.detail(id));
|
||||
} catch (Exception e) {
|
||||
logger.error("appVersion/detail:" + e.getMessage());
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布版本/编辑
|
||||
*/
|
||||
@PostMapping("/publishOrEdit")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "发布版本/编辑")
|
||||
public R<AppVersion> publishOrEdit(@Valid @RequestBody AppVersion modelVo) {
|
||||
try {
|
||||
return R.data(appVersionService.publishOrEdit(modelVo));
|
||||
} catch (Exception e) {
|
||||
logger.error("appVersion/publishOrEdit:" + e.getMessage());
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "删除")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
try {
|
||||
return R.status(appVersionService.removeByIds(Func.toLongList(ids)));
|
||||
} catch (Exception e) {
|
||||
logger.error("appVersion/remove:" + e.getMessage());
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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.system.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.AppVersion;
|
||||
|
||||
|
||||
public interface AppVersionMapper extends BaseMapper<AppVersion> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.springblade.system.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.log.utils.AssertUtils;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.system.mapper.AppVersionMapper;
|
||||
import org.springblade.system.pojo.entity.AppVersion;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class AppVersionService extends ServiceImpl<AppVersionMapper, AppVersion> {
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public IPage<AppVersion> page(AppVersion modelVo, Query query){
|
||||
query.setDescs("create_time");
|
||||
IPage<AppVersion> page = this.page(Condition.getPage(query), Condition.getQueryWrapper(modelVo));
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public AppVersion detail(Long id){
|
||||
AssertUtils.isTrue(ObjectUtil.isNotEmpty(id),"id不能为空");
|
||||
AppVersion model = this.getById(id);
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布版本/编辑
|
||||
*/
|
||||
public AppVersion publishOrEdit(AppVersion modelVo) {
|
||||
//版本号没有重复校验
|
||||
AppVersion appVersion=this.getOne(new LambdaQueryWrapper<AppVersion>().eq(AppVersion::getUpdateType, modelVo.getUpdateType())
|
||||
.eq(AppVersion::getVersion, modelVo.getVersion())
|
||||
.eq(AppVersion::getSubVersion, modelVo.getSubVersion())
|
||||
);
|
||||
if(ObjectUtil.isNotEmpty(appVersion)){
|
||||
if(ObjectUtil.isEmpty(modelVo.getId())||(ObjectUtil.isNotEmpty(modelVo.getId())&&!modelVo.getId().equals(appVersion.getId()))){
|
||||
throw new RuntimeException("该更新类型的版本号重复");
|
||||
}
|
||||
}
|
||||
this.saveOrUpdate(modelVo);
|
||||
return modelVo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user