新增:软件版本更新功能

This commit is contained in:
gxwebsoft
2024-01-15 21:29:27 +08:00
parent 359e880aa3
commit 926734041c
10 changed files with 500 additions and 6 deletions

View File

@@ -73,10 +73,10 @@ public class SocketIOConfig implements InitializingBean {
config.setKeyStorePassword("123456"); // 设置证书密码
// 启动socket服务
SocketIOServer server = new SocketIOServer(config);
server.addListeners(socketIOHandler);
server.start();
ClientCache.setSocketIOServer(server);
logger.debug("Netty SocketIO启动{}:{}",host,port);
// SocketIOServer server = new SocketIOServer(config);
// server.addListeners(socketIOHandler);
// server.start();
// ClientCache.setSocketIOServer(server);
// logger.debug("Netty SocketIO启动{}:{}",host,port);
}
}

View File

@@ -0,0 +1,138 @@
package com.gxwebsoft.common.system.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.service.VersionService;
import com.gxwebsoft.common.system.entity.Version;
import com.gxwebsoft.common.system.param.VersionParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 版本更新控制器
*
* @author 科技小王子
* @since 2024-01-15 18:52:24
*/
@Api(tags = "版本更新管理")
@RestController
@RequestMapping("/api/system/version")
public class VersionController extends BaseController {
@Resource
private VersionService versionService;
@PreAuthorize("hasAuthority('sys:version:list')")
@OperationLog
@ApiOperation("分页查询版本更新")
@GetMapping("/page")
public ApiResult<PageResult<Version>> page(VersionParam param) {
PageParam<Version, VersionParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
return success(versionService.page(page, page.getWrapper()));
// 使用关联查询
//return success(versionService.pageRel(param));
}
@PreAuthorize("hasAuthority('sys:version:list')")
@OperationLog
@ApiOperation("查询全部版本更新")
@GetMapping()
public ApiResult<List<Version>> list(VersionParam param) {
PageParam<Version, VersionParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
return success(versionService.list(page.getOrderWrapper()));
// 使用关联查询
//return success(versionService.listRel(param));
}
@PreAuthorize("hasAuthority('sys:version:list')")
@OperationLog
@ApiOperation("根据id查询版本更新")
@GetMapping("/{id}")
public ApiResult<Version> get(@PathVariable("id") Integer id) {
return success(versionService.getById(id));
// 使用关联查询
//return success(versionService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('sys:version:save')")
@OperationLog
@ApiOperation("添加版本更新")
@PostMapping()
public ApiResult<?> save(@RequestBody Version version) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
version.setUserId(loginUser.getUserId());
}
if (versionService.save(version)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('sys:version:save')")
@OperationLog
@ApiOperation("修改版本更新")
@PutMapping()
public ApiResult<?> update(@RequestBody Version version) {
if (versionService.updateById(version)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:version:save')")
@OperationLog
@ApiOperation("删除版本更新")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (versionService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('sys:version:save')")
@OperationLog
@ApiOperation("批量添加版本更新")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<Version> list) {
if (versionService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('sys:version:save')")
@OperationLog
@ApiOperation("批量修改版本更新")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<Version> batchParam) {
if (batchParam.update(versionService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:version:save')")
@OperationLog
@ApiOperation("批量删除版本更新")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (versionService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

View File

@@ -70,6 +70,12 @@ public class Company implements Serializable {
@ApiModelProperty(value = "应用版本 10体验版 20授权版 30旗舰版")
private Integer version;
@ApiModelProperty(value = "版本名称")
private String versionName;
@ApiModelProperty(value = "版本号")
private String versionCode;
@ApiModelProperty(value = "企业成员(当前)")
private Integer users;

View File

@@ -0,0 +1,81 @@
package com.gxwebsoft.common.system.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 版本更新
*
* @author 科技小王子
* @since 2024-01-15 18:52:24
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "Version对象", description = "版本更新")
@TableName("sys_version")
public class Version implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "版本名")
private String versionName;
@ApiModelProperty(value = "版本号")
private Integer versionCode;
@ApiModelProperty(value = "下载链接")
private String vueDownloadUrl;
@ApiModelProperty(value = "下载链接")
private String androidDownloadUrl;
@ApiModelProperty(value = "下载链接")
private String iosDownloadUrl;
@ApiModelProperty(value = "更新日志")
private String updateInfo;
@ApiModelProperty(value = "强制更新")
private Integer isHard;
@ApiModelProperty(value = "热更")
private Integer isHot;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "文章排序(数字越小越靠前)")
private Integer sortNumber;
private Integer userId;
@ApiModelProperty(value = "状态, 0正常, 1冻结")
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "注册时间")
private Date createTime;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
}

View File

@@ -0,0 +1,37 @@
package com.gxwebsoft.common.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.common.system.entity.Version;
import com.gxwebsoft.common.system.param.VersionParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 版本更新Mapper
*
* @author 科技小王子
* @since 2024-01-15 18:52:24
*/
public interface VersionMapper extends BaseMapper<Version> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<Version>
*/
List<Version> selectPageRel(@Param("page") IPage<Version> page,
@Param("param") VersionParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<Version> selectListRel(@Param("param") VersionParam param);
}

View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.common.system.mapper.VersionMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM sys_version a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.versionName != null">
AND a.version_name LIKE CONCAT('%', #{param.versionName}, '%')
</if>
<if test="param.versionCode != null">
AND a.version_code = #{param.versionCode}
</if>
<if test="param.androidDownloadUrl != null">
AND a.android_download_url LIKE CONCAT('%', #{param.androidDownloadUrl}, '%')
</if>
<if test="param.iosDownloadUrl != null">
AND a.ios_download_url LIKE CONCAT('%', #{param.iosDownloadUrl}, '%')
</if>
<if test="param.updateInfo != null">
AND a.update_info LIKE CONCAT('%', #{param.updateInfo}, '%')
</if>
<if test="param.isHard != null">
AND a.is_hard = #{param.isHard}
</if>
<if test="param.isHot != null">
AND a.is_hot = #{param.isHot}
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.common.system.entity.Version">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.common.system.entity.Version">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -0,0 +1,71 @@
package com.gxwebsoft.common.system.param;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 版本更新查询参数
*
* @author 科技小王子
* @since 2024-01-15 18:52:24
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "VersionParam对象", description = "版本更新查询参数")
public class VersionParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@QueryField(type = QueryType.EQ)
private Integer id;
@ApiModelProperty(value = "版本名")
private String versionName;
@ApiModelProperty(value = "版本号")
@QueryField(type = QueryType.EQ)
private Integer versionCode;
@ApiModelProperty(value = "下载链接")
private String androidDownloadUrl;
@ApiModelProperty(value = "下载链接")
private String iosDownloadUrl;
@ApiModelProperty(value = "更新日志")
private String updateInfo;
@ApiModelProperty(value = "强制更新")
@QueryField(type = QueryType.EQ)
private Integer isHard;
@ApiModelProperty(value = "热更")
@QueryField(type = QueryType.EQ)
private Integer isHot;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "文章排序(数字越小越靠前)")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@QueryField(type = QueryType.EQ)
private Integer userId;
@ApiModelProperty(value = "状态, 0正常, 1冻结")
@QueryField(type = QueryType.EQ)
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}

View File

@@ -0,0 +1,42 @@
package com.gxwebsoft.common.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Version;
import com.gxwebsoft.common.system.param.VersionParam;
import java.util.List;
/**
* 版本更新Service
*
* @author 科技小王子
* @since 2024-01-15 18:52:24
*/
public interface VersionService extends IService<Version> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<Version>
*/
PageResult<Version> pageRel(VersionParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<Version>
*/
List<Version> listRel(VersionParam param);
/**
* 根据id查询
*
* @param id ID
* @return Version
*/
Version getByIdRel(Integer id);
}

View File

@@ -0,0 +1,47 @@
package com.gxwebsoft.common.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.VersionMapper;
import com.gxwebsoft.common.system.service.VersionService;
import com.gxwebsoft.common.system.entity.Version;
import com.gxwebsoft.common.system.param.VersionParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 版本更新Service实现
*
* @author 科技小王子
* @since 2024-01-15 18:52:24
*/
@Service
public class VersionServiceImpl extends ServiceImpl<VersionMapper, Version> implements VersionService {
@Override
public PageResult<Version> pageRel(VersionParam param) {
PageParam<Version, VersionParam> page = new PageParam<>(param);
//page.setDefaultOrder("create_time desc");
List<Version> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<Version> listRel(VersionParam param) {
List<Version> list = baseMapper.selectListRel(param);
// 排序
PageParam<Version, VersionParam> page = new PageParam<>();
//page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}
@Override
public Version getByIdRel(Integer id) {
VersionParam param = new VersionParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}

View File

@@ -63,7 +63,8 @@ public class SysGenerator {
// "sys_app",
// "sys_app_user",
// "sys_app_url",
"sys_app_renew"
// "sys_app_renew"
"sys_version"
};
// 需要去除的表前缀
private static final String[] TABLE_PREFIX = new String[]{