新增系统版本控制功能
This commit is contained in:
@@ -44,6 +44,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@@ -184,8 +185,12 @@ public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEv
|
||||
} else {
|
||||
this.save(rmpEventDetailPO);
|
||||
//推送MQTT消息给前端,用于展示告警消息和弹窗
|
||||
//如果是补招数据,如果事件的时间跟当前时间相差1小时,则不出弹窗。
|
||||
Duration duration = Duration.between(rmpEventDetailPO.getStartTime(), LocalDateTime.now());
|
||||
if (duration.toHours() <= 1 && !duration.isNegative()) {
|
||||
pushEvent(rmpEventDetailPO);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.system.pojo.param;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class AppVersionParam implements Serializable {
|
||||
|
||||
@ApiModelProperty("app版本信息")
|
||||
@NotBlank(message = "app版本信息不能为空")
|
||||
private String appVersion;
|
||||
|
||||
@ApiModelProperty("严重度(0:优化 1:bug调整)")
|
||||
@NotNull(message = "更新严重度不能为空")
|
||||
private Integer sev;
|
||||
|
||||
@ApiModelProperty("整改内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("版本类型 APP WEB")
|
||||
@NotNull(message = "版本类型不能为空")
|
||||
private String versionType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.njcn.system.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-11-21
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("app_version")
|
||||
public class AppVersion extends BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* app版本名称
|
||||
*/
|
||||
private String versionName;
|
||||
|
||||
/**
|
||||
* 版本发布时间
|
||||
*/
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
/**
|
||||
* 严重度(0:优化 1:bug调整)
|
||||
*/
|
||||
private Integer sev;
|
||||
|
||||
/**
|
||||
* 版本类型 APP Web
|
||||
*/
|
||||
private String versionType;
|
||||
|
||||
/**
|
||||
* 修改内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.system.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class AppVersionVo implements Serializable {
|
||||
|
||||
@ApiModelProperty("app版本名称")
|
||||
private String versionName;
|
||||
|
||||
@ApiModelProperty("版本发布时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
@ApiModelProperty("严重度(0:优化 1:bug调整)")
|
||||
private Integer sev;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.system.pojo.param.AppVersionParam;
|
||||
import com.njcn.system.pojo.po.AppVersion;
|
||||
import com.njcn.system.pojo.vo.AppVersionVo;
|
||||
import com.njcn.system.service.IAppVersionService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-11-21
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/appVersion")
|
||||
@Api(tags = "版本信息")
|
||||
@AllArgsConstructor
|
||||
public class VersionController extends BaseController {
|
||||
|
||||
private final IAppVersionService appVersionService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增版本信息")
|
||||
@ApiImplicitParam(name = "param", value = "app版本信息", required = true)
|
||||
public HttpResult<String> add(@RequestBody @Validated AppVersionParam param){
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
boolean result = appVersionService.add(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "新增成功", methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "新增失败", methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getLastData")
|
||||
@ApiOperation("查询最新版本信息")
|
||||
@ApiImplicitParam(name = "versionType", value = "版本类型(APP WEB)", required = true)
|
||||
public HttpResult<AppVersionVo> getLastData(@RequestParam("versionType") String versionType){
|
||||
String methodDescribe = getMethodDescribe("getLastData");
|
||||
AppVersionVo vo = appVersionService.getLastData(versionType);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getAllData")
|
||||
@ApiOperation("查询所有版本信息")
|
||||
@ApiImplicitParam(name = "versionType", value = "版本类型(APP WEB)")
|
||||
public HttpResult< List<AppVersion>> getAllData(@RequestParam(value = "versionType",required = false) String versionType){
|
||||
String methodDescribe = getMethodDescribe("getAllData");
|
||||
List<AppVersion> list = appVersionService.getAllData(versionType);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.system.pojo.po.AppVersion;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-11-21
|
||||
*/
|
||||
public interface AppVersionMapper extends BaseMapper<AppVersion> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.system.pojo.param.AppVersionParam;
|
||||
import com.njcn.system.pojo.po.AppVersion;
|
||||
import com.njcn.system.pojo.vo.AppVersionVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-11-21
|
||||
*/
|
||||
public interface IAppVersionService extends IService<AppVersion> {
|
||||
|
||||
boolean add(AppVersionParam param);
|
||||
|
||||
AppVersionVo getLastData(String versionType);
|
||||
|
||||
List<AppVersion> getAllData(String versionType);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.system.mapper.AppVersionMapper;
|
||||
import com.njcn.system.pojo.param.AppVersionParam;
|
||||
import com.njcn.system.pojo.po.AppVersion;
|
||||
import com.njcn.system.pojo.vo.AppVersionVo;
|
||||
import com.njcn.system.service.IAppVersionService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-11-21
|
||||
*/
|
||||
@Service
|
||||
public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVersion> implements IAppVersionService {
|
||||
|
||||
@Override
|
||||
public boolean add(AppVersionParam param) {
|
||||
AppVersion appVersion = new AppVersion();
|
||||
appVersion.setVersionName(param.getAppVersion());
|
||||
appVersion.setPublishTime(LocalDateTime.now());
|
||||
appVersion.setSev(param.getSev());
|
||||
appVersion.setVersionType(param.getVersionType());
|
||||
appVersion.setContent(param.getContent());
|
||||
return this.save(appVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppVersionVo getLastData(String versionType) {
|
||||
AppVersionVo vo = new AppVersionVo();
|
||||
LambdaQueryWrapper<AppVersion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AppVersion::getVersionType, versionType);
|
||||
queryWrapper.orderByDesc(AppVersion::getPublishTime).last("limit 1");
|
||||
AppVersion appVersion = this.getOne(queryWrapper);
|
||||
if (Objects.nonNull(appVersion)) {
|
||||
BeanUtils.copyProperties(appVersion, vo);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppVersion> getAllData(String versionType) {
|
||||
LambdaQueryWrapper<AppVersion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (Objects.nonNull(versionType)) {
|
||||
queryWrapper.eq(AppVersion::getVersionType, versionType);
|
||||
}
|
||||
queryWrapper.orderByDesc(AppVersion::getPublishTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user