diff --git a/src/main/java/com/huoran/iasf/controller/SysColumnLongPageController.java b/src/main/java/com/huoran/iasf/controller/SysColumnLongPageController.java index 5528b7a..1514a80 100644 --- a/src/main/java/com/huoran/iasf/controller/SysColumnLongPageController.java +++ b/src/main/java/com/huoran/iasf/controller/SysColumnLongPageController.java @@ -1,10 +1,13 @@ package com.huoran.iasf.controller; +import com.alibaba.fastjson.JSONObject; +import com.huoran.iasf.vo.req.SysColumnLongRedisVO; import io.swagger.annotations.*; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.huoran.iasf.common.utils.R; import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -18,6 +21,8 @@ import com.huoran.iasf.service.SysColumnLongPageService; import com.huoran.iasf.entity.SysColumnLongPage; import javax.validation.Valid; +import java.util.List; +import java.util.concurrent.TimeUnit; /** @@ -33,6 +38,9 @@ public class SysColumnLongPageController { @Autowired public SysColumnLongPageService service; + @Autowired + private StringRedisTemplate redisTemplate; + @PostMapping("/findById") @ApiOperation(value = "查询详情", response = SysColumnLongPage.class) @@ -64,5 +72,34 @@ public class SysColumnLongPageController { boolean delState = service.removeById(id); return delState ? R.success() : R.fail("删除失败"); } + + + @PostMapping("/saveTheCache") + @ApiOperation(value = "预览至储存(整个页面存储)") + public R saveTheCache(@RequestBody @ApiParam(name = "预览至储存对象", required = true) SysColumnLongRedisVO vo) { + String key = "saveTheCache:columnId:" + vo.getColumnId(); + //保存到缓存中 + redisTemplate.opsForValue().set(key, vo.getJson()); + return R.success(); + } + + + @PostMapping("/getRedisCache") + @ApiOperation(value = "获取Redis缓存") + public R getRedisCache(@ApiParam(name = "columnId", value = "栏目id主键", required = true) @RequestParam Integer columnId) { + //保存的key名 + String key = "saveTheCache:columnId:" + columnId; + //查看缓存是否有数据 + String returnValue = redisTemplate.opsForValue().get(key); + + //使用缓存返回数据 + if (returnValue != null) { + return R.success(returnValue); + } + + + return R.success(); + } + } diff --git a/src/main/java/com/huoran/iasf/entity/SysColumnLongPage.java b/src/main/java/com/huoran/iasf/entity/SysColumnLongPage.java index ef7bae4..427db43 100644 --- a/src/main/java/com/huoran/iasf/entity/SysColumnLongPage.java +++ b/src/main/java/com/huoran/iasf/entity/SysColumnLongPage.java @@ -37,14 +37,12 @@ public class SysColumnLongPage implements Serializable { @NotNull(message = "排序不能为空!") private Integer sort; - @ApiModelProperty(value = "内容(json字符串)") - @NotNull(message = "内容不能为空!") - private String json; - @ApiModelProperty(value = "创建人id") + @NotNull(message = "创建人id不能为空!") private Integer founderId; @ApiModelProperty(value = "编辑人id") + @NotNull(message = "编辑人id不能为空!") private Integer editorId; @ApiModelProperty(value = "创建时间") @@ -56,10 +54,20 @@ public class SysColumnLongPage implements Serializable { private Date updateTime; @ApiModelProperty(value = "是否删除(1未删除;0已删除)") + @TableLogic private Integer deleted; @ApiModelProperty(value = "备注") private String remark; + @ApiModelProperty(value = "内容(编辑前存储的json字符串)") + private String jsonBeforeEditing; + + @ApiModelProperty(value = "内容(编辑后存储的json字符串)") + private String theEditedJson; + + @ApiModelProperty(value = "发布状态(0:草稿 1已发布)") + private Integer state; + } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/mapper/xml/SysColumnLongPageMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/SysColumnLongPageMapper.xml index a9019a5..a8893be 100644 --- a/src/main/java/com/huoran/iasf/mapper/xml/SysColumnLongPageMapper.xml +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysColumnLongPageMapper.xml @@ -6,8 +6,10 @@ + + - + diff --git a/src/main/java/com/huoran/iasf/vo/req/SysColumnLongRedisVO.java b/src/main/java/com/huoran/iasf/vo/req/SysColumnLongRedisVO.java new file mode 100644 index 0000000..5449877 --- /dev/null +++ b/src/main/java/com/huoran/iasf/vo/req/SysColumnLongRedisVO.java @@ -0,0 +1,31 @@ +package com.huoran.iasf.vo.req; + +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + * @描述:长页栏目拓展表 + * @作者: Rong + * @日期: 2022-08-09 + */ +@Data +public class SysColumnLongRedisVO { + + + @TableId(type = IdType.AUTO) + @ApiModelProperty(value = "栏目id") + private Integer columnId; + + + @ApiModelProperty(value = "预览储存的整个页面的json") + private String json; + + + +} \ No newline at end of file