forked from Gitlink/microservices
feat(文章操作基于代码仓库实现): 【专区管理】文章编辑需同时支持富文本与Markdown编辑器
This commit is contained in:
parent
c496d319a0
commit
9386346d6e
|
|
@ -117,6 +117,10 @@ public class CmsDoc extends BaseSortEntity {
|
|||
* 是否首页展示(0代表不展示 1代表展示)
|
||||
*/
|
||||
private String isHomepage;
|
||||
/**
|
||||
* 文本编辑器类型
|
||||
*/
|
||||
private String editorType;
|
||||
|
||||
public CmsDir copyToCmsDir() {
|
||||
CmsDir cmsDir = new CmsDir();
|
||||
|
|
@ -157,6 +161,7 @@ public class CmsDoc extends BaseSortEntity {
|
|||
cmsDocDto.setHeadImg(headImg);
|
||||
cmsDocDto.setIsHomepage(isHomepage);
|
||||
cmsDocDto.setSummary(summary);
|
||||
cmsDocDto.setEditorType(editorType);
|
||||
|
||||
if (visits == null) {
|
||||
cmsDocDto.setVisits(0L);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.ruoyi.cms.doc.domain;
|
||||
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -17,32 +16,27 @@ public class CmsDocBaseDto {
|
|||
/**
|
||||
* 文章标识
|
||||
*/
|
||||
@Excel(name = "文章标识")
|
||||
@ApiModelProperty("文章标识")
|
||||
private Long id;
|
||||
/**
|
||||
* 文章名称
|
||||
*/
|
||||
@Excel(name = "文章名称")
|
||||
@ApiModelProperty("文章名称")
|
||||
private String name;
|
||||
/**
|
||||
* 文章头图
|
||||
*/
|
||||
@Excel(name = "文章头图")
|
||||
@ApiModelProperty("文章头图")
|
||||
private String headImg;
|
||||
|
||||
/**
|
||||
* 文章概要
|
||||
*/
|
||||
@Excel(name = "文章概要")
|
||||
@ApiModelProperty("文章概要")
|
||||
private String summary;
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
@Excel(name = "发布时间")
|
||||
@ApiModelProperty("发布时间")
|
||||
private String publishTime;
|
||||
/**
|
||||
|
|
@ -66,9 +60,13 @@ public class CmsDocBaseDto {
|
|||
/**
|
||||
* 浏览量
|
||||
*/
|
||||
@Excel(name = "浏览量")
|
||||
@ApiModelProperty("浏览量")
|
||||
private Long visits;
|
||||
/**
|
||||
* 文本编辑器类型
|
||||
*/
|
||||
@ApiModelProperty("文本编辑器类型")
|
||||
private String editorType;
|
||||
/**
|
||||
* 是否首页展示(0代表不展示 1代表展示)
|
||||
*/
|
||||
|
|
@ -81,8 +79,4 @@ public class CmsDocBaseDto {
|
|||
this.publishTime = simpleDateFormat.format(publishTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPublishTime(String publishTime) {
|
||||
this.publishTime = publishTime;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.ruoyi.cms.doc.domain;
|
||||
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -19,7 +18,6 @@ public class CmsDocDetailDto extends CmsDocBaseDto {
|
|||
/**
|
||||
* 文章内容
|
||||
*/
|
||||
@Excel(name = "文章内容")
|
||||
@ApiModelProperty("文章内容")
|
||||
private String content;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.ruoyi.cms.doc.domain;
|
||||
|
||||
import com.ruoyi.cms.utils.CmsConstants;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -19,29 +18,34 @@ public class CmsDocInputDto {
|
|||
/**
|
||||
* 文章名称
|
||||
*/
|
||||
@Excel(name = "文章名称")
|
||||
|
||||
@ApiModelProperty(value = "文章名称", required = true)
|
||||
private String name;
|
||||
/**
|
||||
* 文章内容
|
||||
*/
|
||||
@Excel(name = "文章内容")
|
||||
|
||||
@ApiModelProperty(value = "文章内容", required = true)
|
||||
private String content;
|
||||
/**
|
||||
* 文章头图
|
||||
*/
|
||||
@Excel(name = "文章头图")
|
||||
|
||||
@ApiModelProperty(value = "文章头图")
|
||||
private String headImg;
|
||||
|
||||
/**
|
||||
* 文章概要
|
||||
*/
|
||||
@Excel(name = "文章概要")
|
||||
@ApiModelProperty("文章概要")
|
||||
private String summary;
|
||||
|
||||
/**
|
||||
* 文本编辑器类型
|
||||
*/
|
||||
@ApiModelProperty("文本编辑器类型")
|
||||
private String editorType;
|
||||
|
||||
public String getContent() {
|
||||
String base64decodedString;
|
||||
try {
|
||||
|
|
@ -61,4 +65,19 @@ public class CmsDocInputDto {
|
|||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public CmsDoc toCmsDoc(CmsDoc dirDoc) {
|
||||
CmsDoc cmsDoc = new CmsDoc();
|
||||
cmsDoc.setName(this.getName());
|
||||
String fileName = this.getName() + CmsConstants.MARKDOWN_SUFFIX;
|
||||
cmsDoc.setFileName(fileName);
|
||||
cmsDoc.setFilePath(dirDoc.getName() + CmsConstants.DIR_SEPARATOR + fileName);
|
||||
cmsDoc.setSummary(this.getSummary());
|
||||
cmsDoc.setDirName(dirDoc.getName());
|
||||
cmsDoc.setIsDir(false);
|
||||
cmsDoc.setHeadImg(this.getHeadImg());
|
||||
cmsDoc.setDeptId(dirDoc.getDeptId());
|
||||
cmsDoc.setEditorType(this.editorType);
|
||||
return cmsDoc;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,16 +230,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
throw new ServiceException("该栏目不存在(栏目Id[" + dirId + "])");
|
||||
}
|
||||
|
||||
CmsDoc cmsDoc = new CmsDoc();
|
||||
cmsDoc.setName(cmsDocInputDto.getName());
|
||||
String fileName = cmsDocInputDto.getName() + CmsConstants.MARKDOWN_SUFFIX;
|
||||
cmsDoc.setFileName(fileName);
|
||||
cmsDoc.setFilePath(dirDoc.getName() + CmsConstants.DIR_SEPARATOR + fileName);
|
||||
cmsDoc.setSummary(cmsDocInputDto.getSummary());
|
||||
cmsDoc.setDirName(dirDoc.getName());
|
||||
cmsDoc.setIsDir(false);
|
||||
cmsDoc.setHeadImg(cmsDocInputDto.getHeadImg());
|
||||
cmsDoc.setDeptId(dirDoc.getDeptId());
|
||||
CmsDoc cmsDoc = cmsDocInputDto.toCmsDoc(dirDoc);
|
||||
return insertCommonCmsDoc(cmsDoc, "创建文章:" + cmsDoc.getName(), cmsDocInputDto.getContent());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
<result property="dirName" column="dir_name"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="isHomepage" column="is_homepage"/>
|
||||
<result property="editorType" column="editor_type"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsDocVo">
|
||||
|
|
@ -57,6 +58,7 @@
|
|||
dir_name,
|
||||
dept_id,
|
||||
is_homepage,
|
||||
editor_type,
|
||||
is_dir
|
||||
from cms_doc
|
||||
</sql>
|
||||
|
|
@ -86,6 +88,7 @@
|
|||
cd.dir_name,
|
||||
cd.dept_id,
|
||||
cd.is_homepage,
|
||||
cd.editor_type,
|
||||
cd.is_dir
|
||||
from cms_doc cd
|
||||
</sql>
|
||||
|
|
@ -254,6 +257,7 @@
|
|||
<if test="dirName != null">dir_name,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
<if test="isHomepage != null">is_homepage,</if>
|
||||
<if test="editorType != null">editor_type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
|
|
@ -280,6 +284,7 @@
|
|||
<if test="dirName != null">#{dirName},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
<if test="isHomepage != null">#{isHomepage},</if>
|
||||
<if test="editorType != null">#{editorType},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
ALTER TABLE `ruoyi-gitlink`.`cms_doc`
|
||||
ADD COLUMN `editor_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'markdown_editor' COMMENT '编辑器类型';
|
||||
|
||||
INSERT INTO `ruoyi-gitlink`.`sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`,
|
||||
`update_by`, `update_time`, `remark`)
|
||||
VALUES ('文本编辑器类型', 'editor_type', '0', 'admin', '2023-07-05 10:42:31', '', NULL, NULL);
|
||||
|
||||
INSERT INTO `ruoyi-gitlink`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`,
|
||||
`list_class`, `is_default`, `status`, `create_by`, `create_time`,
|
||||
`update_by`, `update_time`, `remark`)
|
||||
VALUES (0, '富文本编辑器', 'rich_editor', 'editor_type', NULL, NULL, 'N', '0', 'admin', '2023-07-05 10:46:11', '', NULL,
|
||||
NULL);
|
||||
INSERT INTO `ruoyi-gitlink`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`,
|
||||
`list_class`, `is_default`, `status`, `create_by`, `create_time`,
|
||||
`update_by`, `update_time`, `remark`)
|
||||
VALUES (0, 'Markdown编辑器', 'markdown_editor', 'editor_type', NULL, NULL, 'N', '0', 'admin', '2023-07-05 10:46:31', '',
|
||||
NULL, NULL);
|
||||
|
||||
update `ruoyi-gitlink`.cms_doc
|
||||
set editor_type='markdown_editor'
|
||||
where is_dir = 0;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
Loading…
Reference in New Issue