diff --git a/bweb/src/main/java/com/bweb/config/AuthConfig.java b/bweb/src/main/java/com/bweb/config/AuthConfig.java index 7dcb4e9..a93bd19 100644 --- a/bweb/src/main/java/com/bweb/config/AuthConfig.java +++ b/bweb/src/main/java/com/bweb/config/AuthConfig.java @@ -99,6 +99,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/test/*") .excludePathPatterns("/laKaLaNotify/merContract") .excludePathPatterns("/openApi/*") + .excludePathPatterns("/sysVersion/*") ; } diff --git a/bweb/src/main/java/com/bweb/controller/SecVersionController.java b/bweb/src/main/java/com/bweb/controller/SecVersionController.java new file mode 100644 index 0000000..f8012ec --- /dev/null +++ b/bweb/src/main/java/com/bweb/controller/SecVersionController.java @@ -0,0 +1,158 @@ +package com.bweb.controller; + +import com.bweb.config.SysConfig; +import com.bweb.config.SysConst; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.DateUtil; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.SecVersion; +import com.hfkj.model.ResponseData; +import com.hfkj.obs.HuaWeiYunObs; +import com.hfkj.service.SecVersionService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.multipart.commons.CommonsMultipartResolver; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileOutputStream; +import java.util.*; + +@Controller +@Api(value = "系统版本") +@RequestMapping(value = "/sysVersion") +public class SecVersionController { + + private static Logger log = LoggerFactory.getLogger(SecVersionController.class); + + @Resource + private SecVersionService secVersionService; + + @RequestMapping(value="/editVersion",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "编辑版本") + public ResponseData editVersion(@RequestBody SecVersion body) { + try { + + if (body == null + || body.getTermType() == null + || body.getVersionType() == null + || StringUtils.isBlank(body.getVersion()) + || StringUtils.isBlank(body.getContent()) + || StringUtils.isBlank(body.getFileUrl())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 版本 + SecVersion version = secVersionService.getDetailById(body.getId()); + if (version == null) { + version = new SecVersion(); + + Map param = new HashMap<>(); + param.put("term_type", body.getTermType()); + param.put("status", 2); + if (secVersionService.getList(param).size() > 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法创建新版本,有未发布的版本"); + } + version.setStatus(2); + } + version.setTermType(body.getTermType()); + version.setVersionType(body.getVersionType()); + version.setVersion(body.getVersion()); + version.setContent(body.getContent()); + version.setFileUrl(body.getFileUrl()); + secVersionService.editData(version); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/releaseVersion",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "发布版本") + public ResponseData releaseVersion(@RequestParam(name = "id", required = true) Integer id) { + try { + // 版本 + SecVersion version = secVersionService.getDetailById(id); + if (version == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + if (!version.getStatus().equals(2)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); + } + secVersionService.releaseVersion(version); + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/delVersion",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除版本") + public ResponseData delVersion(@RequestParam(name = "id", required = true) Integer id) { + try { + + // 版本 + SecVersion version = secVersionService.getDetailById(id); + if (version == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + if (!version.getStatus().equals(2)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); + } + version.setStatus(0); + secVersionService.editData(version); + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getVersionList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询版本列表") + public ResponseData getVersionList(@RequestParam(name = "termType", required = false) String termType, + @RequestParam(name = "versionType", required = false) Integer versionType, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + + Map param = new HashMap<>(); + param.put("termType", termType); + param.put("versionType", versionType); + param.put("status", status); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(secVersionService.getList(param))); + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/cweb/src/main/java/com/cweb/controller/SecVersionController.java b/cweb/src/main/java/com/cweb/controller/SecVersionController.java index de23cca..e11397b 100644 --- a/cweb/src/main/java/com/cweb/controller/SecVersionController.java +++ b/cweb/src/main/java/com/cweb/controller/SecVersionController.java @@ -9,6 +9,7 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsAudit; +import com.hfkj.entity.SecVersion; import com.hfkj.model.ResponseData; import com.hfkj.model.UserInfoModel; import com.hfkj.service.BsAuditService; @@ -43,7 +44,8 @@ public class SecVersionController { public ResponseData queryVersion(@RequestParam(name = "termType", required = true) String termType) { try { - return ResponseMsgUtil.success(secVersionService.getVersion(termType)); + SecVersion version = secVersionService.getCurrentVersion(termType); + return ResponseMsgUtil.success(version); } catch (Exception e) { log.error(e.getMessage(), e); diff --git a/service/src/main/java/com/hfkj/dao/SecVersionMapper.java b/service/src/main/java/com/hfkj/dao/SecVersionMapper.java index 4f84b05..02d3eff 100644 --- a/service/src/main/java/com/hfkj/dao/SecVersionMapper.java +++ b/service/src/main/java/com/hfkj/dao/SecVersionMapper.java @@ -41,12 +41,16 @@ public interface SecVersionMapper extends SecVersionMapperExt { @Insert({ "insert into sec_version (term_type, version_type, ", "version, content, ", - "file_url, ext_1, ext_2, ", - "ext_3)", + "file_url, `status`, ", + "create_time, release_time, ", + "update_time, ext_1, ", + "ext_2, ext_3)", "values (#{termType,jdbcType=VARCHAR}, #{versionType,jdbcType=INTEGER}, ", "#{version,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, ", - "#{fileUrl,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ", - "#{ext3,jdbcType=VARCHAR})" + "#{fileUrl,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", + "#{createTime,jdbcType=TIMESTAMP}, #{releaseTime,jdbcType=TIMESTAMP}, ", + "#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(SecVersion record); @@ -63,6 +67,10 @@ public interface SecVersionMapper extends SecVersionMapperExt { @Result(column="version", property="version", jdbcType=JdbcType.VARCHAR), @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR), @Result(column="file_url", property="fileUrl", jdbcType=JdbcType.VARCHAR), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="release_time", property="releaseTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) @@ -71,7 +79,8 @@ public interface SecVersionMapper extends SecVersionMapperExt { @Select({ "select", - "id, term_type, version_type, version, content, file_url, ext_1, ext_2, ext_3", + "id, term_type, version_type, version, content, file_url, `status`, create_time, ", + "release_time, update_time, ext_1, ext_2, ext_3", "from sec_version", "where id = #{id,jdbcType=INTEGER}" }) @@ -82,6 +91,10 @@ public interface SecVersionMapper extends SecVersionMapperExt { @Result(column="version", property="version", jdbcType=JdbcType.VARCHAR), @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR), @Result(column="file_url", property="fileUrl", jdbcType=JdbcType.VARCHAR), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="release_time", property="releaseTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) @@ -104,6 +117,10 @@ public interface SecVersionMapper extends SecVersionMapperExt { "version = #{version,jdbcType=VARCHAR},", "content = #{content,jdbcType=VARCHAR},", "file_url = #{fileUrl,jdbcType=VARCHAR},", + "`status` = #{status,jdbcType=INTEGER},", + "create_time = #{createTime,jdbcType=TIMESTAMP},", + "release_time = #{releaseTime,jdbcType=TIMESTAMP},", + "update_time = #{updateTime,jdbcType=TIMESTAMP},", "ext_1 = #{ext1,jdbcType=VARCHAR},", "ext_2 = #{ext2,jdbcType=VARCHAR},", "ext_3 = #{ext3,jdbcType=VARCHAR}", diff --git a/service/src/main/java/com/hfkj/dao/SecVersionSqlProvider.java b/service/src/main/java/com/hfkj/dao/SecVersionSqlProvider.java index 94e032c..3346ded 100644 --- a/service/src/main/java/com/hfkj/dao/SecVersionSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/SecVersionSqlProvider.java @@ -48,6 +48,22 @@ public class SecVersionSqlProvider { sql.VALUES("file_url", "#{fileUrl,jdbcType=VARCHAR}"); } + if (record.getStatus() != null) { + sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); + } + + if (record.getCreateTime() != null) { + sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getReleaseTime() != null) { + sql.VALUES("release_time", "#{releaseTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}"); + } + if (record.getExt1() != null) { sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); } @@ -75,6 +91,10 @@ public class SecVersionSqlProvider { sql.SELECT("version"); sql.SELECT("content"); sql.SELECT("file_url"); + sql.SELECT("`status`"); + sql.SELECT("create_time"); + sql.SELECT("release_time"); + sql.SELECT("update_time"); sql.SELECT("ext_1"); sql.SELECT("ext_2"); sql.SELECT("ext_3"); @@ -119,6 +139,22 @@ public class SecVersionSqlProvider { sql.SET("file_url = #{record.fileUrl,jdbcType=VARCHAR}"); } + if (record.getStatus() != null) { + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getReleaseTime() != null) { + sql.SET("release_time = #{record.releaseTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); + } + if (record.getExt1() != null) { sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); } @@ -145,6 +181,10 @@ public class SecVersionSqlProvider { sql.SET("version = #{record.version,jdbcType=VARCHAR}"); sql.SET("content = #{record.content,jdbcType=VARCHAR}"); sql.SET("file_url = #{record.fileUrl,jdbcType=VARCHAR}"); + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + sql.SET("release_time = #{record.releaseTime,jdbcType=TIMESTAMP}"); + sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); @@ -178,6 +218,22 @@ public class SecVersionSqlProvider { sql.SET("file_url = #{fileUrl,jdbcType=VARCHAR}"); } + if (record.getStatus() != null) { + sql.SET("`status` = #{status,jdbcType=INTEGER}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getReleaseTime() != null) { + sql.SET("release_time = #{releaseTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}"); + } + if (record.getExt1() != null) { sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); } diff --git a/service/src/main/java/com/hfkj/entity/SecVersion.java b/service/src/main/java/com/hfkj/entity/SecVersion.java index a26d884..33f7015 100644 --- a/service/src/main/java/com/hfkj/entity/SecVersion.java +++ b/service/src/main/java/com/hfkj/entity/SecVersion.java @@ -1,6 +1,7 @@ package com.hfkj.entity; import java.io.Serializable; +import java.util.Date; /** * sec_version @@ -39,6 +40,26 @@ public class SecVersion implements Serializable { */ private String fileUrl; + /** + * 状态 0:删除 1:已发布 2:待发布 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 发布时间 + */ + private Date releaseTime; + + /** + * 修改时间 + */ + private Date updateTime; + private String ext1; private String ext2; @@ -95,6 +116,38 @@ public class SecVersion implements Serializable { this.fileUrl = fileUrl; } + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getReleaseTime() { + return releaseTime; + } + + public void setReleaseTime(Date releaseTime) { + this.releaseTime = releaseTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + public String getExt1() { return ext1; } @@ -137,6 +190,10 @@ public class SecVersion implements Serializable { && (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion())) && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent())) && (this.getFileUrl() == null ? other.getFileUrl() == null : this.getFileUrl().equals(other.getFileUrl())) + && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getReleaseTime() == null ? other.getReleaseTime() == null : this.getReleaseTime().equals(other.getReleaseTime())) + && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) && (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) && (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); @@ -152,6 +209,10 @@ public class SecVersion implements Serializable { result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode()); result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode()); result = prime * result + ((getFileUrl() == null) ? 0 : getFileUrl().hashCode()); + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getReleaseTime() == null) ? 0 : getReleaseTime().hashCode()); + result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); @@ -170,6 +231,10 @@ public class SecVersion implements Serializable { sb.append(", version=").append(version); sb.append(", content=").append(content); sb.append(", fileUrl=").append(fileUrl); + sb.append(", status=").append(status); + sb.append(", createTime=").append(createTime); + sb.append(", releaseTime=").append(releaseTime); + sb.append(", updateTime=").append(updateTime); sb.append(", ext1=").append(ext1); sb.append(", ext2=").append(ext2); sb.append(", ext3=").append(ext3); diff --git a/service/src/main/java/com/hfkj/entity/SecVersionExample.java b/service/src/main/java/com/hfkj/entity/SecVersionExample.java index 1321223..37ccb03 100644 --- a/service/src/main/java/com/hfkj/entity/SecVersionExample.java +++ b/service/src/main/java/com/hfkj/entity/SecVersionExample.java @@ -1,6 +1,7 @@ package com.hfkj.entity; import java.util.ArrayList; +import java.util.Date; import java.util.List; public class SecVersionExample { @@ -524,6 +525,246 @@ public class SecVersionExample { return (Criteria) this; } + public Criteria andStatusIsNull() { + addCriterion("`status` is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("`status` is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Integer value) { + addCriterion("`status` =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Integer value) { + addCriterion("`status` <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Integer value) { + addCriterion("`status` >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("`status` >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Integer value) { + addCriterion("`status` <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Integer value) { + addCriterion("`status` <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("`status` not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Integer value1, Integer value2) { + addCriterion("`status` between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Integer value1, Integer value2) { + addCriterion("`status` not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Date value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Date value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Date value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Date value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Date value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Date value1, Date value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Date value1, Date value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeIsNull() { + addCriterion("release_time is null"); + return (Criteria) this; + } + + public Criteria andReleaseTimeIsNotNull() { + addCriterion("release_time is not null"); + return (Criteria) this; + } + + public Criteria andReleaseTimeEqualTo(Date value) { + addCriterion("release_time =", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeNotEqualTo(Date value) { + addCriterion("release_time <>", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeGreaterThan(Date value) { + addCriterion("release_time >", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeGreaterThanOrEqualTo(Date value) { + addCriterion("release_time >=", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeLessThan(Date value) { + addCriterion("release_time <", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeLessThanOrEqualTo(Date value) { + addCriterion("release_time <=", value, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeIn(List values) { + addCriterion("release_time in", values, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeNotIn(List values) { + addCriterion("release_time not in", values, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeBetween(Date value1, Date value2) { + addCriterion("release_time between", value1, value2, "releaseTime"); + return (Criteria) this; + } + + public Criteria andReleaseTimeNotBetween(Date value1, Date value2) { + addCriterion("release_time not between", value1, value2, "releaseTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Date value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Date value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Date value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Date value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Date value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Date value1, Date value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Date value1, Date value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } + public Criteria andExt1IsNull() { addCriterion("ext_1 is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/service/SecVersionService.java b/service/src/main/java/com/hfkj/service/SecVersionService.java index c5901a2..fa8d580 100644 --- a/service/src/main/java/com/hfkj/service/SecVersionService.java +++ b/service/src/main/java/com/hfkj/service/SecVersionService.java @@ -2,6 +2,9 @@ package com.hfkj.service; import com.hfkj.entity.SecVersion; +import java.util.List; +import java.util.Map; + /** * @className: SecVersionService * @author: HuRui @@ -9,7 +12,37 @@ import com.hfkj.entity.SecVersion; **/ public interface SecVersionService { + /** + * 编辑数据 + * @param version + */ void editData(SecVersion version); - SecVersion getVersion(String termType); + /** + * 发布版本 + * @param version + */ + void releaseVersion(SecVersion version); + + /** + * 查询详情 + * @param id + * @return + */ + SecVersion getDetailById(Integer id); + + /** + * 查询版本 + * @param termType + * @return + */ + SecVersion getCurrentVersion(String termType); + + /** + * 查询列表 + * @param param + * @return + */ + List getList(Map param); + } diff --git a/service/src/main/java/com/hfkj/service/impl/SecVersionServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/SecVersionServiceImpl.java index a7392f4..7bec535 100644 --- a/service/src/main/java/com/hfkj/service/impl/SecVersionServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/SecVersionServiceImpl.java @@ -2,14 +2,19 @@ package com.hfkj.service.impl; import com.alicp.jetcache.anno.CacheType; import com.alicp.jetcache.anno.Cached; +import com.hfkj.common.utils.RedisUtil; import com.hfkj.dao.SecVersionMapper; import com.hfkj.entity.SecVersion; import com.hfkj.entity.SecVersionExample; import com.hfkj.service.SecVersionService; +import org.apache.commons.collections4.MapUtils; +import org.apache.ibatis.annotations.Update; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Date; import java.util.List; +import java.util.Map; /** * @className: SecVersionServiceImpl @@ -21,20 +26,70 @@ public class SecVersionServiceImpl implements SecVersionService { @Resource private SecVersionMapper secVersionMapper; + @Resource + private RedisUtil redisUtil; + private final static String redisKey = "SYS_VERSION"; @Override public void editData(SecVersion version) { + version.setUpdateTime(new Date()); + + if (version.getId() == null) { + version.setCreateTime(new Date()); + secVersionMapper.insert(version); + } else { + secVersionMapper.updateByPrimaryKey(version); + } + } + + @Override + public void releaseVersion(SecVersion version) { + version.setStatus(1); + version.setReleaseTime(new Date()); + editData(version); + redisUtil.hset(redisKey, version.getTermType(), version); + } + @Override + public SecVersion getDetailById(Integer id) { + return secVersionMapper.selectByPrimaryKey(id); } @Override - @Cached(cacheType = CacheType.REMOTE, name="SYSTEM_VERSION:", key = "#termType") - public SecVersion getVersion(String termType) { + public SecVersion getCurrentVersion(String termType) { + termType = termType.toUpperCase(); + Object version = redisUtil.hget(redisKey, termType); + if (version != null) { + return (SecVersion) version; + } SecVersionExample example = new SecVersionExample(); - example.createCriteria().andTermTypeEqualTo(termType); + example.createCriteria().andTermTypeEqualTo(termType).andStatusEqualTo(1); + example.setOrderByClause("release_time desc"); List list = secVersionMapper.selectByExample(example); if (list.size() > 0) { + redisUtil.hset(redisKey, termType, list.get(0)); return list.get(0); } return null; } + + @Override + public List getList(Map param) { + SecVersionExample example = new SecVersionExample(); + SecVersionExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); + + if (MapUtils.getString(param, "termType") != null) { + criteria.andTermTypeEqualTo(MapUtils.getString(param, "termType")); + } + + if (MapUtils.getInteger(param, "versionType") != null) { + criteria.andVersionTypeEqualTo(MapUtils.getInteger(param, "versionType")); + } + + if (MapUtils.getInteger(param, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(param, "status")); + } + + example.setOrderByClause("create_time desc"); + return secVersionMapper.selectByExample(example); + } }