From 7cb3edd7691ed48f51d8744e5b5140fe4712f759 Mon Sep 17 00:00:00 2001 From: xierz Date: Tue, 24 Nov 2020 19:24:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E9=9D=A2=E6=A0=8F=E7=9B=AE=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mingsoft/cms/action/ContentAction.java | 18 +++++++ .../WEB-INF/manager/cms/content/form.ftl | 49 ++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/mingsoft/cms/action/ContentAction.java b/src/main/java/net/mingsoft/cms/action/ContentAction.java index 5e360bc1..46bd8a0e 100644 --- a/src/main/java/net/mingsoft/cms/action/ContentAction.java +++ b/src/main/java/net/mingsoft/cms/action/ContentAction.java @@ -117,6 +117,24 @@ public class ContentAction extends BaseAction { ContentEntity _content = contentBiz.getById(content.getId()); return ResultData.build().success(_content); } + /** + * 获取文章 + * @param content 文章实体 + */ + @ApiOperation(value = "根据封面获取文章列表接口") + @ApiImplicitParam(name = "categoryId", value = "分类编号", required =true,paramType="query") + @GetMapping("/getByFengMian") + @ResponseBody + public ResultData getByFengMian(@ModelAttribute @ApiIgnore ContentEntity content){ + if(content.getCategoryId() == null) { + return ResultData.build().error(); + } + List list = contentBiz.lambdaQuery().eq(ContentEntity::getCategoryId, content.getCategoryId()).list(); + if (list.size() > 1) { + LOG.error("获取封面文章异常"); + } + return ResultData.build().success(list.size() > 0 ? list.get(0) : null); + } @ApiOperation(value = "保存文章列表接口") @ApiImplicitParams({ diff --git a/src/main/webapp/WEB-INF/manager/cms/content/form.ftl b/src/main/webapp/WEB-INF/manager/cms/content/form.ftl index 9b2aa92e..55188ea1 100644 --- a/src/main/webapp/WEB-INF/manager/cms/content/form.ftl +++ b/src/main/webapp/WEB-INF/manager/cms/content/form.ftl @@ -524,6 +524,52 @@ console.log(err); }); }, + //根据封面获取当前文章 + getByFengMian: function (categoryId) { + var that = this; + ms.http.get(ms.manager + "/cms/content/getByFengMian.do", { + "categoryId": categoryId + }).then(function (res) { + if (res.result) { + if (res.data != null) { + if (res.data.contentType && res.data.contentType != '') { + res.data.contentType = res.data.contentType.split(','); + } else { + res.data.contentType = []; + } + + if (res.data.contentImg) { + res.data.contentImg = JSON.parse(res.data.contentImg); + res.data.contentImg.forEach(function (value) { + value.url = ms.base + value.path; + }); + } else { + res.data.contentImg = []; + } + + that.form = res.data; + var category = that.categoryIdOptions.filter(function (f) { + return f['id'] == that.form.categoryId; + }); + + if (category.length == 1) { + if (category[0].categoryType == '2') { + that.returnIsShow = false; + } + } + that.changeModel(); + } + } else { + that.$notify({ + title: '失败', + message: "获取错误", + type: 'warning' + }); + } + }).catch(function (err) { + console.log(err); + }); + }, //获取contentCategoryId数据源 contentCategoryIdOptionsGet: function () { var that = this; @@ -633,9 +679,8 @@ if (this.form.id) { this.get(this.form.id); } - if (this.type) { - this.list(this.form.categoryId); + this.getByFengMian(this.form.categoryId); this.returnIsShow = false; } }