172 lines
6.6 KiB
Plaintext
172 lines
6.6 KiB
Plaintext
package com.cmeim.basic.controller;
|
|
|
|
import com.cmeim.basic.po.BaAppVersion;
|
|
import com.cmeim.basic.service.BaAppVersionService;
|
|
import com.cmeim.basic.vo.AppVersionVo;
|
|
import com.cmeim.common.core.exception.ServiceException;
|
|
import com.cmeim.common.core.web.controller.GenericController;
|
|
import com.cmeim.common.core.web.domain.Respond;
|
|
import com.cmeim.common.core.web.domain.RespondEnum;
|
|
import com.cmeim.common.core.web.page.PageVo;
|
|
import com.cmeim.common.log.annotation.Log;
|
|
import com.cmeim.common.log.enums.BusinessType;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@Api(tags = "应用版本")
|
|
@RestController
|
|
@RequestMapping(value = "/app/version")
|
|
public class BaAppVersionController extends GenericController {
|
|
|
|
@Autowired
|
|
private BaAppVersionService service;
|
|
|
|
|
|
/*
|
|
* @Author 谷宬膊
|
|
* @Description //TODO 松哥提的要复制一条数据,方便发布
|
|
* @Date 9:37 2022/5/9
|
|
* @Param
|
|
* @return
|
|
**/
|
|
@ApiOperation(value = "复制一条数据,方便发布")
|
|
@GetMapping(value = "/copyAppVersion")
|
|
public Respond copyAppVersion(){
|
|
service.copyAppVersion(this.getCurrentUser());
|
|
return buildSuccess();
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "列表")
|
|
@GetMapping(value = "/list")
|
|
public Respond list(AppVersionVo query) {
|
|
PageRequest pageRequest = PageRequest.of(query.getPageNo() - 1, query.getPageSize(), Sort.by(sortOrder(query.getOrders())));
|
|
Page page = service.findAll(query, pageRequest);
|
|
|
|
PageVo pv = new PageVo();
|
|
pv.setRecordsTotal(page.getTotalElements());
|
|
pv.setData(page.getContent());
|
|
return buildSuccess(pv);
|
|
}
|
|
|
|
@ApiOperation(value = "详情")
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParam(name = "id", value = "Id", required = true)
|
|
})
|
|
@GetMapping(value = "/get/{id}")
|
|
public Respond get(@PathVariable("id") Long id) {
|
|
if (id == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "Id为空");
|
|
}
|
|
BaAppVersion appVersion = service.findById(id);
|
|
return buildSuccess(appVersion);
|
|
}
|
|
|
|
@Log(title = "应用版本", businessType = BusinessType.INSERT)
|
|
@ApiOperation(value = "创建")
|
|
@PostMapping(value = "/create")
|
|
public Respond create(BaAppVersion appVersion) {
|
|
//校验
|
|
if (appVersion.getAppType() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "应用类型为空");
|
|
}
|
|
if (StringUtils.isBlank(appVersion.getAppVersion())) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "应用版本为空");
|
|
}
|
|
if (appVersion.getBuildVersion() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "构建版本为空");
|
|
}
|
|
if (appVersion.getAppStatus() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "应用状态为空");
|
|
}
|
|
if (appVersion.getUpdateForce() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "是否强制更新为空");
|
|
}
|
|
if (StringUtils.isBlank(appVersion.getDeployDt())) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "发布时间为空");
|
|
}
|
|
if (StringUtils.isBlank(appVersion.getDownloadUrl())) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "下载地址为空");
|
|
}
|
|
//创建
|
|
service.create(appVersion, this.getCurrentUser());
|
|
return buildSuccess();
|
|
}
|
|
|
|
@Log(title = "应用版本", businessType = BusinessType.UPDATE)
|
|
@ApiOperation(value = "修改")
|
|
@PutMapping(value = "/update")
|
|
public Respond update(BaAppVersion appVersion) {
|
|
//校验
|
|
if (appVersion.getId() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR,"Id为空");
|
|
}
|
|
if (appVersion.getAppType() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "应用类型为空");
|
|
}
|
|
if (StringUtils.isBlank(appVersion.getAppVersion())) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "应用版本为空");
|
|
}
|
|
if (appVersion.getBuildVersion() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "构建版本为空");
|
|
}
|
|
if (appVersion.getAppStatus() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "应用状态为空");
|
|
}
|
|
if (appVersion.getUpdateForce() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "是否强制更新为空");
|
|
}
|
|
if (StringUtils.isBlank(appVersion.getDeployDt())) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "发布时间为空");
|
|
}
|
|
if (StringUtils.isBlank(appVersion.getDownloadUrl())) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR, "下载地址为空");
|
|
}
|
|
//持久
|
|
service.update(appVersion, this.getCurrentUser());
|
|
return buildSuccess();
|
|
}
|
|
|
|
@Log(title = "应用版本", businessType = BusinessType.UPDATE)
|
|
@ApiOperation(value = "发布")
|
|
@PutMapping(value = "/deploy")
|
|
public Respond deploy(BaAppVersion appVersion) {
|
|
//校验
|
|
if (appVersion.getId() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR,"Id为空");
|
|
}
|
|
//持久
|
|
service.deploy(appVersion, this.getCurrentUser());
|
|
return buildSuccess();
|
|
}
|
|
|
|
@Log(title = "应用版本", businessType = BusinessType.UPDATE)
|
|
@ApiOperation(value = "停用")
|
|
@PutMapping(value = "/pause")
|
|
public Respond pause(BaAppVersion appVersion) {
|
|
//校验
|
|
if (appVersion.getId() == null) {
|
|
throw new ServiceException(RespondEnum.PARAMETER_ERROR,"Id为空");
|
|
}
|
|
//持久
|
|
service.pause(appVersion, this.getCurrentUser());
|
|
return buildSuccess();
|
|
}
|
|
|
|
@ApiOperation(value = "版本检查")
|
|
@GetMapping(value = "/check/{appType}/{appVersion}")
|
|
public Respond check(@PathVariable(name = "appType") Integer appType, @PathVariable(name = "appVersion") String appVersion) {
|
|
return buildSuccess(service.check(appType, appVersion));
|
|
}
|
|
|
|
} |