完成表单设计的开发
This commit is contained in:
@@ -62,8 +62,8 @@ public class ArticleController extends BaseController {
|
|||||||
article.setActualViews(article.getActualViews() + 1);
|
article.setActualViews(article.getActualViews() + 1);
|
||||||
articleService.updateById(article);
|
articleService.updateById(article);
|
||||||
// 附加文字内容
|
// 附加文字内容
|
||||||
if(article != null){
|
ArticleContent content = articleContentService.getOne(new LambdaQueryWrapper<ArticleContent>().eq(ArticleContent::getArticleId,article.getArticleId()).last("limit 1"));
|
||||||
ArticleContent content = articleContentService.getOne(new LambdaQueryWrapper<ArticleContent>().eq(ArticleContent::getArticleId,article.getArticleId()));
|
if(content != null){
|
||||||
article.setContent(content.getContent());
|
article.setContent(content.getContent());
|
||||||
}
|
}
|
||||||
return success(article);
|
return success(article);
|
||||||
@@ -127,8 +127,10 @@ public class ArticleController extends BaseController {
|
|||||||
ArticleContent content = new ArticleContent();
|
ArticleContent content = new ArticleContent();
|
||||||
content.setArticleId(article.getArticleId());
|
content.setArticleId(article.getArticleId());
|
||||||
content.setContent(article.getContent());
|
content.setContent(article.getContent());
|
||||||
if(articleContentService.count(new LambdaQueryWrapper<ArticleContent>().eq(ArticleContent::getArticleId,article.getArticleId())) > 0){
|
ArticleContent one = articleContentService.getOne(new LambdaQueryWrapper<ArticleContent>().eq(ArticleContent::getArticleId, article.getArticleId()).last("limit 1"));
|
||||||
articleContentService.updateById(content);
|
if(one != null){
|
||||||
|
one.setContent(article.getContent());
|
||||||
|
articleContentService.updateById(one);
|
||||||
}else {
|
}else {
|
||||||
articleContentService.save(content);
|
articleContentService.save(content);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
package com.gxwebsoft.cms.controller;
|
package com.gxwebsoft.cms.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.gxwebsoft.cms.entity.Form;
|
import com.gxwebsoft.cms.entity.Form;
|
||||||
import com.gxwebsoft.cms.param.FormParam;
|
import com.gxwebsoft.cms.param.FormParam;
|
||||||
import com.gxwebsoft.cms.service.FormService;
|
import com.gxwebsoft.cms.service.FormService;
|
||||||
import com.gxwebsoft.common.core.web.*;
|
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||||
|
import com.gxwebsoft.common.core.web.ApiResult;
|
||||||
|
import com.gxwebsoft.common.core.web.BaseController;
|
||||||
|
import com.gxwebsoft.common.core.web.BatchParam;
|
||||||
|
import com.gxwebsoft.common.core.web.PageResult;
|
||||||
import com.gxwebsoft.common.system.entity.User;
|
import com.gxwebsoft.common.system.entity.User;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@@ -24,6 +30,8 @@ import java.util.List;
|
|||||||
public class FormController extends BaseController {
|
public class FormController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private FormService formService;
|
private FormService formService;
|
||||||
|
@Resource
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
@ApiOperation("分页查询表单设计表")
|
@ApiOperation("分页查询表单设计表")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@@ -42,6 +50,12 @@ public class FormController extends BaseController {
|
|||||||
@ApiOperation("根据id查询表单设计表")
|
@ApiOperation("根据id查询表单设计表")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ApiResult<Form> get(@PathVariable("id") Integer id) {
|
public ApiResult<Form> get(@PathVariable("id") Integer id) {
|
||||||
|
String key = "FormId:" + id;
|
||||||
|
final String formInfo = redisUtil.get(key);
|
||||||
|
// 从缓存读取信息
|
||||||
|
if(StrUtil.isNotBlank(formInfo)){
|
||||||
|
return success(JSONObject.parseObject(formInfo, Form.class));
|
||||||
|
}
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
return success(formService.getByIdRel(id));
|
return success(formService.getByIdRel(id));
|
||||||
}
|
}
|
||||||
@@ -64,6 +78,10 @@ public class FormController extends BaseController {
|
|||||||
@PutMapping()
|
@PutMapping()
|
||||||
public ApiResult<?> update(@RequestBody Form form) {
|
public ApiResult<?> update(@RequestBody Form form) {
|
||||||
if (formService.updateById(form)) {
|
if (formService.updateById(form)) {
|
||||||
|
if (form.getClearCache() != null) {
|
||||||
|
String key = "FormId:" + form.getFormId();
|
||||||
|
redisUtil.set(key,form);
|
||||||
|
}
|
||||||
return success("修改成功");
|
return success("修改成功");
|
||||||
}
|
}
|
||||||
return fail("修改失败");
|
return fail("修改失败");
|
||||||
|
|||||||
@@ -24,8 +24,11 @@ import java.util.Date;
|
|||||||
public class ArticleContent implements Serializable {
|
public class ArticleContent implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键ID")
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "文章ID")
|
@ApiModelProperty(value = "文章ID")
|
||||||
@TableId(value = "article_id", type = IdType.AUTO)
|
|
||||||
private Integer articleId;
|
private Integer articleId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "文章内容")
|
@ApiModelProperty(value = "文章内容")
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package com.gxwebsoft.cms.entity;
|
package com.gxwebsoft.cms.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -76,4 +73,8 @@ public class Form implements Serializable {
|
|||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否更新缓存")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer clearCache;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
SELECT a.*
|
SELECT a.*
|
||||||
FROM cms_article_content a
|
FROM cms_article_content a
|
||||||
<where>
|
<where>
|
||||||
|
<if test="param.id != null">
|
||||||
|
AND a.id = #{param.idd}
|
||||||
|
</if>
|
||||||
<if test="param.articleId != null">
|
<if test="param.articleId != null">
|
||||||
AND a.article_id = #{param.articleId}
|
AND a.article_id = #{param.articleId}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ import lombok.EqualsAndHashCode;
|
|||||||
public class ArticleContentParam extends BaseParam {
|
public class ArticleContentParam extends BaseParam {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ApiModelProperty(value = "文章ID")
|
@ApiModelProperty(value = "ID")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
private Integer articleId;
|
private Integer articleId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "文章内容")
|
@ApiModelProperty(value = "文章内容")
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class ArticleContentServiceImpl extends ServiceImpl<ArticleContentMapper,
|
|||||||
@Override
|
@Override
|
||||||
public ArticleContent getByIdRel(Integer id) {
|
public ArticleContent getByIdRel(Integer id) {
|
||||||
ArticleContentParam param = new ArticleContentParam();
|
ArticleContentParam param = new ArticleContentParam();
|
||||||
param.setArticleId(id);
|
param.setId(id);
|
||||||
return param.getOne(baseMapper.selectListRel(param));
|
return param.getOne(baseMapper.selectListRel(param));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class FormServiceImpl extends ServiceImpl<FormMapper, Form> implements Fo
|
|||||||
@Override
|
@Override
|
||||||
public PageResult<Form> pageRel(FormParam param) {
|
public PageResult<Form> pageRel(FormParam param) {
|
||||||
PageParam<Form, FormParam> page = new PageParam<>(param);
|
PageParam<Form, FormParam> page = new PageParam<>(param);
|
||||||
//page.setDefaultOrder("create_time desc");
|
page.setDefaultOrder("create_time desc");
|
||||||
List<Form> list = baseMapper.selectPageRel(page, param);
|
List<Form> list = baseMapper.selectPageRel(page, param);
|
||||||
return new PageResult<>(list, page.getTotal());
|
return new PageResult<>(list, page.getTotal());
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ public class FormServiceImpl extends ServiceImpl<FormMapper, Form> implements Fo
|
|||||||
List<Form> list = baseMapper.selectListRel(param);
|
List<Form> list = baseMapper.selectListRel(param);
|
||||||
// 排序
|
// 排序
|
||||||
PageParam<Form, FormParam> page = new PageParam<>();
|
PageParam<Form, FormParam> page = new PageParam<>();
|
||||||
//page.setDefaultOrder("create_time desc");
|
page.setDefaultOrder("create_time desc");
|
||||||
return page.sortRecords(list);
|
return page.sortRecords(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user