文章CRUD
This commit is contained in:
parent
db309a2740
commit
dca36af934
@ -20,7 +20,7 @@ public class CMSCategoryAPI extends BaseController {
|
||||
private ICmsCategoryService categoryService;
|
||||
|
||||
/**
|
||||
* 获取栏目及文章
|
||||
* 获取栏目了栏目
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public AjaxResult getCategory(CmsCategory category){
|
||||
@ -28,7 +28,7 @@ public class CMSCategoryAPI extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取栏目下的子栏目及文章
|
||||
* 获取栏目下的子栏目及内容
|
||||
* @param id 顶层栏目ID
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@ -37,7 +37,7 @@ public class CMSCategoryAPI extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个子栏目的文章
|
||||
* 获取某个子栏目的内容
|
||||
*/
|
||||
@GetMapping("/content/{id}")
|
||||
public AjaxResult getContentById(@PathVariable Long id){
|
||||
|
@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/api/content")
|
||||
@ -19,7 +20,7 @@ public class CMSContentAPI extends BaseController {
|
||||
private ICmsContentService contentService;
|
||||
|
||||
/**
|
||||
* 文章详情
|
||||
* 内容详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
@ -28,7 +28,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 文章Controller
|
||||
* 内容Controller
|
||||
*
|
||||
* @author 点亮信息
|
||||
* @date 2024-07-19
|
||||
@ -44,7 +44,7 @@ public class CmsContentController extends BaseController
|
||||
private ICmsCategoryService cmsCategoryService;
|
||||
|
||||
/**
|
||||
* 查询文章列表
|
||||
* 查询内容列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:content:list')")
|
||||
@GetMapping("/list")
|
||||
@ -56,20 +56,20 @@ public class CmsContentController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出文章列表
|
||||
* 导出内容列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:content:export')")
|
||||
@Log(title = "文章", businessType = BusinessType.EXPORT)
|
||||
@Log(title = "内容", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CmsContent cmsContent)
|
||||
{
|
||||
List<CmsContent> list = cmsContentService.selectCmsContentList(cmsContent);
|
||||
ExcelUtil<CmsContent> util = new ExcelUtil<CmsContent>(CmsContent.class);
|
||||
util.exportExcel(response, list, "文章数据");
|
||||
util.exportExcel(response, list, "内容数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文章详细信息
|
||||
* 获取内容详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:content:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ -79,21 +79,22 @@ public class CmsContentController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文章
|
||||
* 新增内容
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:content:add')")
|
||||
@Log(title = "文章", businessType = BusinessType.INSERT)
|
||||
@Log(title = "内容", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CmsContent cmsContent)
|
||||
{
|
||||
System.out.println(cmsContent);
|
||||
return toAjax(cmsContentService.insertCmsContent(cmsContent));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章
|
||||
* 修改内容
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:content:edit')")
|
||||
@Log(title = "文章", businessType = BusinessType.UPDATE)
|
||||
@Log(title = "内容", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CmsContent cmsContent)
|
||||
{
|
||||
@ -101,10 +102,10 @@ public class CmsContentController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章
|
||||
* 删除内容
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:content:remove')")
|
||||
@Log(title = "文章", businessType = BusinessType.DELETE)
|
||||
@Log(title = "内容", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids, Principal principal)
|
||||
{
|
||||
@ -124,7 +125,7 @@ public class CmsContentController extends BaseController
|
||||
/**
|
||||
* 恢复记录
|
||||
*/
|
||||
@Log(title = "文章", businessType = BusinessType.DELETE)
|
||||
@Log(title = "内容", businessType = BusinessType.DELETE)
|
||||
@PutMapping("/{ids}")
|
||||
public AjaxResult recoverContentByIds(@PathVariable Long[] ids, Principal principal)
|
||||
{
|
||||
@ -132,12 +133,12 @@ public class CmsContentController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布文章,改变文章状态时用
|
||||
* 发布内容,改变内容状态时用
|
||||
* @param ids
|
||||
* @param principal
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "文章", businessType = BusinessType.UPDATE)
|
||||
@Log(title = "内容", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus/{ids}")
|
||||
public AjaxResult changeContentByIds(@PathVariable Long[] ids, Principal principal){
|
||||
return toAjax(cmsContentService.changeContentByIds(ids, principal.getName()));
|
||||
|
@ -9,9 +9,9 @@ import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -20,7 +20,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Anonymous
|
||||
@ -102,4 +104,41 @@ public class UeditorController {
|
||||
public AjaxResult getLeavesCategoryList(){
|
||||
return AjaxResult.success(categoryService.getLeavesCategoryList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用上传请求(多个)
|
||||
*/
|
||||
// @PostMapping("/uploads")
|
||||
// public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// // 上传文件路径
|
||||
// String filePath = RuoYiConfig.getUploadPath();
|
||||
// List<String> urls = new ArrayList<String>();
|
||||
// List<String> fileNames = new ArrayList<String>();
|
||||
// List<String> newFileNames = new ArrayList<String>();
|
||||
// List<String> originalFilenames = new ArrayList<String>();
|
||||
// for (MultipartFile file : files)
|
||||
// {
|
||||
// // 上传并返回新文件名称
|
||||
// String fileName = FileUploadUtils.upload(filePath, file);
|
||||
// String url = serverConfig.getUrl() + fileName;
|
||||
// urls.add(url);
|
||||
// fileNames.add(fileName);
|
||||
// newFileNames.add(FileUtils.getName(fileName));
|
||||
// originalFilenames.add(file.getOriginalFilename());
|
||||
// }
|
||||
// AjaxResult ajax = AjaxResult.success();
|
||||
// ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
|
||||
// ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
|
||||
// ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
|
||||
// ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
|
||||
// return ajax;
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// return AjaxResult.error(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.ruoyi.cms.domain;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.ruoyi.system.handler.MysqlTypeHandler;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
@ -11,9 +13,10 @@ import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章对象 cms_content
|
||||
* 内容对象 cms_content
|
||||
*
|
||||
* @author 点亮信息
|
||||
* @date 2024-07-19
|
||||
@ -42,8 +45,8 @@ public class CmsContent extends BaseEntity
|
||||
@Excel(name = "缩略图")
|
||||
private String contentImg;
|
||||
|
||||
/** 文章内容 */
|
||||
@Excel(name = "文章内容")
|
||||
/** 内容 */
|
||||
@Excel(name = "内容")
|
||||
private String contentDetail;
|
||||
|
||||
/** 来源 */
|
||||
@ -90,13 +93,15 @@ public class CmsContent extends BaseEntity
|
||||
|
||||
/** 附件路径 */
|
||||
@Excel(name = "附件路径")
|
||||
private String accessoryUrl;
|
||||
private List<String> accessoryUrl;
|
||||
|
||||
/** 图片地址 */
|
||||
private String imageUrl;
|
||||
@Excel(name = "图片地址")
|
||||
private List<String> imageUrl;
|
||||
|
||||
/** 视频地址 */
|
||||
private String videoUrl;
|
||||
@Excel(name = "视频地址")
|
||||
private List<String> videoUrl;
|
||||
|
||||
/** 逻辑删除0未删除1真删除 */
|
||||
private Integer delFlag;
|
||||
|
@ -7,7 +7,7 @@ import com.ruoyi.cms.domain.CmsContent;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 文章Mapper接口
|
||||
* 内容Mapper接口
|
||||
*
|
||||
* @author 点亮信息
|
||||
* @date 2024-07-19
|
||||
@ -15,47 +15,47 @@ import org.apache.ibatis.annotations.Param;
|
||||
public interface CmsContentMapper extends BaseMapper<CmsContent>
|
||||
{
|
||||
/**
|
||||
* 查询文章
|
||||
* 查询内容
|
||||
*
|
||||
* @param id 文章主键
|
||||
* @return 文章
|
||||
* @param id 内容主键
|
||||
* @return 内容
|
||||
*/
|
||||
public CmsContent selectCmsContentById(Long id);
|
||||
|
||||
/**
|
||||
* 查询文章列表
|
||||
* 查询内容列表
|
||||
*
|
||||
* @param cmsContent 文章
|
||||
* @return 文章集合
|
||||
* @param cmsContent 内容
|
||||
* @return 内容集合
|
||||
*/
|
||||
public List<CmsContent> selectCmsContentList(CmsContent cmsContent);
|
||||
|
||||
/**
|
||||
* 新增文章
|
||||
* 新增内容
|
||||
*
|
||||
* @param cmsContent 文章
|
||||
* @param cmsContent 内容
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsContent(CmsContent cmsContent);
|
||||
|
||||
/**
|
||||
* 修改文章
|
||||
* 修改内容
|
||||
*
|
||||
* @param cmsContent 文章
|
||||
* @param cmsContent 内容
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsContent(CmsContent cmsContent);
|
||||
|
||||
/**
|
||||
* 删除文章
|
||||
* 删除内容
|
||||
*
|
||||
* @param id 文章主键
|
||||
* @param id 内容主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsContentById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除文章
|
||||
* 批量删除内容
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
|
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cms.domain.CmsContent;
|
||||
|
||||
/**
|
||||
* 文章Service接口
|
||||
* 内容Service接口
|
||||
*
|
||||
* @author 点亮信息
|
||||
* @date 2024-07-19
|
||||
@ -14,49 +14,49 @@ import com.ruoyi.cms.domain.CmsContent;
|
||||
public interface ICmsContentService extends IService<CmsContent>
|
||||
{
|
||||
/**
|
||||
* 查询文章
|
||||
* 查询内容
|
||||
*
|
||||
* @param id 文章主键
|
||||
* @return 文章
|
||||
* @param id 内容主键
|
||||
* @return 内容
|
||||
*/
|
||||
public CmsContent selectCmsContentById(Long id);
|
||||
|
||||
/**
|
||||
* 查询文章列表
|
||||
* 查询内容列表
|
||||
*
|
||||
* @param cmsContent 文章
|
||||
* @return 文章集合
|
||||
* @param cmsContent 内容
|
||||
* @return 内容集合
|
||||
*/
|
||||
public List<CmsContent> selectCmsContentList(CmsContent cmsContent);
|
||||
|
||||
/**
|
||||
* 新增文章
|
||||
* 新增内容
|
||||
*
|
||||
* @param cmsContent 文章
|
||||
* @param cmsContent 内容
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsContent(CmsContent cmsContent);
|
||||
|
||||
/**
|
||||
* 修改文章
|
||||
* 修改内容
|
||||
*
|
||||
* @param cmsContent 文章
|
||||
* @param cmsContent 内容
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsContent(CmsContent cmsContent);
|
||||
|
||||
/**
|
||||
* 批量删除文章
|
||||
* 批量删除内容
|
||||
*
|
||||
* @param ids 需要删除的文章主键集合
|
||||
* @param ids 需要删除的内容主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsContentByIds(Long[] ids, String username);
|
||||
|
||||
/**
|
||||
* 删除文章信息
|
||||
* 删除内容信息
|
||||
*
|
||||
* @param id 文章主键
|
||||
* @param id 内容主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsContentById(Long id);
|
||||
@ -67,7 +67,7 @@ public interface ICmsContentService extends IService<CmsContent>
|
||||
int recoverContentByIds(Long[] ids, String username);
|
||||
|
||||
/**
|
||||
* 发布文章,改变文章状态时用
|
||||
* 发布内容,改变内容状态时用
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
|
@ -26,8 +26,6 @@ import com.ruoyi.cms.mapper.CmsCategoryMapper;
|
||||
import com.ruoyi.cms.domain.CmsCategory;
|
||||
import com.ruoyi.cms.service.ICmsCategoryService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 栏目Service业务层处理
|
||||
*
|
||||
@ -237,13 +235,11 @@ public class CmsCategoryServiceImpl extends ServiceImpl<CmsCategoryMapper, CmsCa
|
||||
@Override
|
||||
public PageInfo<CmsContent> getContentById(Long id) {
|
||||
PageHelper.startPage(1, 10);
|
||||
List<CmsContent> contents = contentMapper.selectList(new QueryWrapper<CmsContent>()
|
||||
.and(item -> {
|
||||
item.eq("category_id", id)
|
||||
.eq("status", "1");
|
||||
})
|
||||
.orderByDesc("create_time")
|
||||
);
|
||||
CmsContent content = new CmsContent();
|
||||
content.setCategoryId(id);
|
||||
content.setStatus("1");
|
||||
content.setDelFlag(0);
|
||||
List<CmsContent> contents = contentMapper.selectCmsContentList(content);
|
||||
return new PageInfo<CmsContent>(contents);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import com.ruoyi.cms.domain.CmsContent;
|
||||
import com.ruoyi.cms.service.ICmsContentService;
|
||||
|
||||
/**
|
||||
* 文章Service业务层处理
|
||||
* 内容Service业务层处理
|
||||
*
|
||||
* @author 点亮信息
|
||||
* @date 2024-07-19
|
||||
@ -27,10 +27,10 @@ public class CmsContentServiceImpl extends ServiceImpl<CmsContentMapper, CmsCont
|
||||
private Snowflake snowflake;
|
||||
|
||||
/**
|
||||
* 查询文章
|
||||
* 查询内容
|
||||
*
|
||||
* @param id 文章主键
|
||||
* @return 文章
|
||||
* @param id 内容主键
|
||||
* @return 内容
|
||||
*/
|
||||
@Override
|
||||
public CmsContent selectCmsContentById(Long id)
|
||||
@ -39,10 +39,10 @@ public class CmsContentServiceImpl extends ServiceImpl<CmsContentMapper, CmsCont
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文章列表
|
||||
* 查询内容列表
|
||||
*
|
||||
* @param cmsContent 文章
|
||||
* @return 文章
|
||||
* @param cmsContent 内容
|
||||
* @return 内容
|
||||
*/
|
||||
@Override
|
||||
public List<CmsContent> selectCmsContentList(CmsContent cmsContent)
|
||||
@ -51,9 +51,9 @@ public class CmsContentServiceImpl extends ServiceImpl<CmsContentMapper, CmsCont
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文章
|
||||
* 新增内容
|
||||
*
|
||||
* @param cmsContent 文章
|
||||
* @param cmsContent 内容
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@ -65,9 +65,9 @@ public class CmsContentServiceImpl extends ServiceImpl<CmsContentMapper, CmsCont
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章
|
||||
* 修改内容
|
||||
*
|
||||
* @param cmsContent 文章
|
||||
* @param cmsContent 内容
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@ -78,9 +78,9 @@ public class CmsContentServiceImpl extends ServiceImpl<CmsContentMapper, CmsCont
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除文章
|
||||
* 批量删除内容
|
||||
*
|
||||
* @param ids 需要删除的文章主键
|
||||
* @param ids 需要删除的内容主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@ -103,9 +103,9 @@ public class CmsContentServiceImpl extends ServiceImpl<CmsContentMapper, CmsCont
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章信息
|
||||
* 删除内容信息
|
||||
*
|
||||
* @param id 文章主键
|
||||
* @param id 内容主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@ -132,7 +132,7 @@ public class CmsContentServiceImpl extends ServiceImpl<CmsContentMapper, CmsCont
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布文章,改变文章状态时用
|
||||
* 发布内容,改变内容状态时用
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
|
@ -21,15 +21,15 @@
|
||||
<result property="publishDate" column="publish_date" />
|
||||
<result property="offlineDate" column="offline_date" />
|
||||
<result property="isAccessory" column="is_accessory" />
|
||||
<result property="accessoryUrl" column="accessory_url" />
|
||||
<result property="accessoryUrl" column="accessory_url" javaType="java.util.List" typeHandler="com.ruoyi.system.handler.MysqlTypeHandler" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="imageUrl" column="image_url" />
|
||||
<result property="videoUrl" column="video_url" />
|
||||
<result property="imageUrl" column="image_url" javaType="java.util.List" typeHandler="com.ruoyi.system.handler.MysqlTypeHandler"/>
|
||||
<result property="videoUrl" column="video_url" javaType="java.util.List" typeHandler="com.ruoyi.system.handler.MysqlTypeHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsContentVo">
|
||||
@ -57,6 +57,7 @@
|
||||
<if test="accessoryUrl != null and accessoryUrl != ''"> and accessory_url = #{accessoryUrl}</if>
|
||||
<if test="delFlag != null"> and del_flag = #{delFlag}</if>
|
||||
</where>
|
||||
order by create_time desc, update_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectCmsContentById" parameterType="Long" resultMap="CmsContentResult">
|
||||
@ -71,50 +72,54 @@
|
||||
<if test="categoryId != null">category_id,</if>
|
||||
<if test="contentType != null">content_type,</if>
|
||||
<if test="contentTitle != null and contentTitle != ''">content_title,</if>
|
||||
<if test="contentImg != null">content_img,</if>
|
||||
<if test="contentDetail != null">content_detail,</if>
|
||||
<if test="source != null">source,</if>
|
||||
<if test="sourceUrl != null">source_url,</if>
|
||||
<if test="original != null">original,</if>
|
||||
<if test="author != null">author,</if>
|
||||
<if test="editor != null">editor,</if>
|
||||
<if test="summary != null">summary,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="contentImg != null and contentImg != ''">content_img,</if>
|
||||
<if test="contentDetail != null and contentDetail != ''">content_detail,</if>
|
||||
<if test="source != null and source != ''">source,</if>
|
||||
<if test="sourceUrl != null and sourceUrl != ''">source_url,</if>
|
||||
<if test="original != null and original != ''">original,</if>
|
||||
<if test="author != null and author != ''">author,</if>
|
||||
<if test="editor != null and editor != ''">editor,</if>
|
||||
<if test="summary != null and summary != ''">summary,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="publishDate != null">publish_date,</if>
|
||||
<if test="offlineDate != null">offline_date,</if>
|
||||
<if test="isAccessory != null">is_accessory,</if>
|
||||
<if test="accessoryUrl != null">accessory_url,</if>
|
||||
<if test="isAccessory != null and isAccessory != ''">is_accessory,</if>
|
||||
<if test="accessoryUrl != null and accessoryUrl.size() != 0">accessory_url,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="imageUrl != null and imageUrl.size() != 0">image_url,</if>
|
||||
<if test="videoUrl != null and videoUrl.size() != 0">video_url,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="categoryId != null">#{categoryId},</if>
|
||||
<if test="contentType != null">#{contentType},</if>
|
||||
<if test="contentTitle != null and contentTitle != ''">#{contentTitle},</if>
|
||||
<if test="contentImg != null">#{contentImg},</if>
|
||||
<if test="contentDetail != null">#{contentDetail},</if>
|
||||
<if test="source != null">#{source},</if>
|
||||
<if test="sourceUrl != null">#{sourceUrl},</if>
|
||||
<if test="original != null">#{original},</if>
|
||||
<if test="author != null">#{author},</if>
|
||||
<if test="editor != null">#{editor},</if>
|
||||
<if test="summary != null">#{summary},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="contentImg != null and contentImg != ''">#{contentImg},</if>
|
||||
<if test="contentDetail != null and contentDetail != ''">#{contentDetail},</if>
|
||||
<if test="source != null and source != ''">#{source},</if>
|
||||
<if test="sourceUrl != null and sourceUrl != ''">#{sourceUrl},</if>
|
||||
<if test="original != null and original != ''">#{original},</if>
|
||||
<if test="author != null and author != ''">#{author},</if>
|
||||
<if test="editor != null and editor != ''">#{editor},</if>
|
||||
<if test="summary != null and summary != ''">#{summary},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="publishDate != null">#{publishDate},</if>
|
||||
<if test="offlineDate != null">#{offlineDate},</if>
|
||||
<if test="isAccessory != null">#{isAccessory},</if>
|
||||
<if test="accessoryUrl != null">#{accessoryUrl},</if>
|
||||
<if test="isAccessory != null and isAccessory != ''">#{isAccessory},</if>
|
||||
<if test="accessoryUrl != null and accessoryUrl.size() != 0">#{accessoryUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="imageUrl != null and imageUrl.size() != 0">#{imageUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
<if test="videoUrl != null and videoUrl.size() != 0">#{videoUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -124,30 +129,31 @@
|
||||
<if test="categoryId != null">category_id = #{categoryId},</if>
|
||||
<if test="contentType != null">content_type = #{contentType},</if>
|
||||
<if test="contentTitle != null and contentTitle != ''">content_title = #{contentTitle},</if>
|
||||
<if test="contentImg != null">content_img = #{contentImg},</if>
|
||||
<if test="contentDetail != null">content_detail = #{contentDetail},</if>
|
||||
<if test="source != null">source = #{source},</if>
|
||||
<if test="sourceUrl != null">source_url = #{sourceUrl},</if>
|
||||
<if test="original != null">original = #{original},</if>
|
||||
<if test="author != null">author = #{author},</if>
|
||||
<if test="editor != null">editor = #{editor},</if>
|
||||
<if test="summary != null">summary = #{summary},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="contentImg != null and contentImg != ''">content_img = #{contentImg},</if>
|
||||
<if test="contentDetail != null and contentDetail != '' ">content_detail = #{contentDetail},</if>
|
||||
<if test="source != null and source != ''">source = #{source},</if>
|
||||
<if test="sourceUrl != null and sourceUrl != ''">source_url = #{sourceUrl},</if>
|
||||
<if test="original != null and original != ''">original = #{original},</if>
|
||||
<if test="author != null and author != ''">author = #{author},</if>
|
||||
<if test="editor != null and editor != ''">editor = #{editor},</if>
|
||||
<if test="summary != null and summary != ''">summary = #{summary},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="publishDate != null">publish_date = #{publishDate},</if>
|
||||
<if test="offlineDate != null">offline_date = #{offlineDate},</if>
|
||||
<if test="isAccessory != null">is_accessory = #{isAccessory},</if>
|
||||
<if test="accessoryUrl != null">accessory_url = #{accessoryUrl},</if>
|
||||
<if test="isAccessory != null and isAccessory != ''">is_accessory = #{isAccessory},</if>
|
||||
<if test="accessoryUrl != null and accessoryUrl.size() != 0">accessory_url = #{accessoryUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="imageUrl != null and imageUrl.size() != 0">image_url = #{imageUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
<if test="videoUrl != null and videoUrl.size() != 0">video_url = #{videoUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteCmsContentById" parameterType="Long">
|
||||
delete from cms_content where id = #{id}
|
||||
</delete>
|
||||
@ -158,4 +164,6 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
@ -16,5 +16,4 @@ PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
<!-- 使用驼峰命名法转换字段 -->
|
||||
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
|
||||
</settings>
|
||||
|
||||
</configuration>
|
||||
|
@ -21,19 +21,19 @@
|
||||
<result property="publishDate" column="publish_date" />
|
||||
<result property="offlineDate" column="offline_date" />
|
||||
<result property="isAccessory" column="is_accessory" />
|
||||
<result property="accessoryUrl" column="accessory_url" />
|
||||
<result property="accessoryUrl" column="accessory_url" javaType="java.util.List" typeHandler="com.ruoyi.system.handler.MysqlTypeHandler" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="imageUrl" column="image_url" />
|
||||
<result property="videoUrl" column="video_url" />
|
||||
<result property="imageUrl" column="image_url" javaType="java.util.List" typeHandler="com.ruoyi.system.handler.MysqlTypeHandler"/>
|
||||
<result property="videoUrl" column="video_url" javaType="java.util.List" typeHandler="com.ruoyi.system.handler.MysqlTypeHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsContentVo">
|
||||
select id, category_id, content_type,image_url, video_url content_title, content_img, content_detail, source, source_url, original, author, editor, summary, status, publish_date, offline_date, is_accessory, accessory_url, remark, del_flag, create_time, create_by, update_time, update_by from cms_content
|
||||
select id, category_id, content_type,image_url, video_url, content_title, content_img, content_detail, source, source_url, original, author, editor, summary, status, publish_date, offline_date, is_accessory, accessory_url, remark, del_flag, create_time, create_by, update_time, update_by from cms_content
|
||||
</sql>
|
||||
|
||||
<select id="selectCmsContentList" parameterType="CmsContent" resultMap="CmsContentResult">
|
||||
@ -41,7 +41,7 @@
|
||||
<where>
|
||||
<if test="categoryId != null "> and category_id = #{categoryId}</if>
|
||||
<if test="contentType != null "> and content_type = #{contentType}</if>
|
||||
<if test="contentTitle != null and contentTitle != ''"> and content_title = #{contentTitle}</if>
|
||||
<if test="contentTitle != null and contentTitle != ''"> and content_title like concat('%', #{contentTitle}, '%')</if>
|
||||
<if test="contentImg != null and contentImg != ''"> and content_img = #{contentImg}</if>
|
||||
<if test="contentDetail != null and contentDetail != ''"> and content_detail = #{contentDetail}</if>
|
||||
<if test="source != null and source != ''"> and source = #{source}</if>
|
||||
@ -55,7 +55,9 @@
|
||||
<if test="offlineDate != null "> and offline_date = #{offlineDate}</if>
|
||||
<if test="isAccessory != null "> and is_accessory = #{isAccessory}</if>
|
||||
<if test="accessoryUrl != null and accessoryUrl != ''"> and accessory_url = #{accessoryUrl}</if>
|
||||
<if test="delFlag != null"> and del_flag = #{delFlag}</if>
|
||||
</where>
|
||||
order by create_time desc, update_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectCmsContentById" parameterType="Long" resultMap="CmsContentResult">
|
||||
@ -70,50 +72,54 @@
|
||||
<if test="categoryId != null">category_id,</if>
|
||||
<if test="contentType != null">content_type,</if>
|
||||
<if test="contentTitle != null and contentTitle != ''">content_title,</if>
|
||||
<if test="contentImg != null">content_img,</if>
|
||||
<if test="contentDetail != null">content_detail,</if>
|
||||
<if test="source != null">source,</if>
|
||||
<if test="sourceUrl != null">source_url,</if>
|
||||
<if test="original != null">original,</if>
|
||||
<if test="author != null">author,</if>
|
||||
<if test="editor != null">editor,</if>
|
||||
<if test="summary != null">summary,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="contentImg != null and contentImg != ''">content_img,</if>
|
||||
<if test="contentDetail != null and contentDetail != ''">content_detail,</if>
|
||||
<if test="source != null and source != ''">source,</if>
|
||||
<if test="sourceUrl != null and sourceUrl != ''">source_url,</if>
|
||||
<if test="original != null and original != ''">original,</if>
|
||||
<if test="author != null and author != ''">author,</if>
|
||||
<if test="editor != null and editor != ''">editor,</if>
|
||||
<if test="summary != null and summary != ''">summary,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="publishDate != null">publish_date,</if>
|
||||
<if test="offlineDate != null">offline_date,</if>
|
||||
<if test="isAccessory != null">is_accessory,</if>
|
||||
<if test="accessoryUrl != null">accessory_url,</if>
|
||||
<if test="isAccessory != null and isAccessory != ''">is_accessory,</if>
|
||||
<if test="accessoryUrl != null and accessoryUrl.size() != 0">accessory_url,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="imageUrl != null and imageUrl.size() != 0">image_url,</if>
|
||||
<if test="videoUrl != null and videoUrl.size() != 0">video_url,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="categoryId != null">#{categoryId},</if>
|
||||
<if test="contentType != null">#{contentType},</if>
|
||||
<if test="contentTitle != null and contentTitle != ''">#{contentTitle},</if>
|
||||
<if test="contentImg != null">#{contentImg},</if>
|
||||
<if test="contentDetail != null">#{contentDetail},</if>
|
||||
<if test="source != null">#{source},</if>
|
||||
<if test="sourceUrl != null">#{sourceUrl},</if>
|
||||
<if test="original != null">#{original},</if>
|
||||
<if test="author != null">#{author},</if>
|
||||
<if test="editor != null">#{editor},</if>
|
||||
<if test="summary != null">#{summary},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="contentImg != null and contentImg != ''">#{contentImg},</if>
|
||||
<if test="contentDetail != null and contentDetail != ''">#{contentDetail},</if>
|
||||
<if test="source != null and source != ''">#{source},</if>
|
||||
<if test="sourceUrl != null and sourceUrl != ''">#{sourceUrl},</if>
|
||||
<if test="original != null and original != ''">#{original},</if>
|
||||
<if test="author != null and author != ''">#{author},</if>
|
||||
<if test="editor != null and editor != ''">#{editor},</if>
|
||||
<if test="summary != null and summary != ''">#{summary},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="publishDate != null">#{publishDate},</if>
|
||||
<if test="offlineDate != null">#{offlineDate},</if>
|
||||
<if test="isAccessory != null">#{isAccessory},</if>
|
||||
<if test="accessoryUrl != null">#{accessoryUrl},</if>
|
||||
<if test="isAccessory != null and isAccessory != ''">#{isAccessory},</if>
|
||||
<if test="accessoryUrl != null and accessoryUrl.size() != 0">#{accessoryUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="imageUrl != null and imageUrl.size() != 0">#{imageUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
<if test="videoUrl != null and videoUrl.size() != 0">#{videoUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -123,25 +129,27 @@
|
||||
<if test="categoryId != null">category_id = #{categoryId},</if>
|
||||
<if test="contentType != null">content_type = #{contentType},</if>
|
||||
<if test="contentTitle != null and contentTitle != ''">content_title = #{contentTitle},</if>
|
||||
<if test="contentImg != null">content_img = #{contentImg},</if>
|
||||
<if test="contentDetail != null">content_detail = #{contentDetail},</if>
|
||||
<if test="source != null">source = #{source},</if>
|
||||
<if test="sourceUrl != null">source_url = #{sourceUrl},</if>
|
||||
<if test="original != null">original = #{original},</if>
|
||||
<if test="author != null">author = #{author},</if>
|
||||
<if test="editor != null">editor = #{editor},</if>
|
||||
<if test="summary != null">summary = #{summary},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="contentImg != null and contentImg != ''">content_img = #{contentImg},</if>
|
||||
<if test="contentDetail != null and contentDetail != '' ">content_detail = #{contentDetail},</if>
|
||||
<if test="source != null and source != ''">source = #{source},</if>
|
||||
<if test="sourceUrl != null and sourceUrl != ''">source_url = #{sourceUrl},</if>
|
||||
<if test="original != null and original != ''">original = #{original},</if>
|
||||
<if test="author != null and author != ''">author = #{author},</if>
|
||||
<if test="editor != null and editor != ''">editor = #{editor},</if>
|
||||
<if test="summary != null and summary != ''">summary = #{summary},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="publishDate != null">publish_date = #{publishDate},</if>
|
||||
<if test="offlineDate != null">offline_date = #{offlineDate},</if>
|
||||
<if test="isAccessory != null">is_accessory = #{isAccessory},</if>
|
||||
<if test="accessoryUrl != null">accessory_url = #{accessoryUrl},</if>
|
||||
<if test="isAccessory != null and isAccessory != ''">is_accessory = #{isAccessory},</if>
|
||||
<if test="accessoryUrl != null and accessoryUrl.size() != 0">accessory_url = #{accessoryUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="imageUrl != null and imageUrl.size() != 0">image_url = #{imageUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
<if test="videoUrl != null and videoUrl.size() != 0">video_url = #{videoUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@ -156,4 +164,6 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
@ -16,5 +16,4 @@ PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
<!-- 使用驼峰命名法转换字段 -->
|
||||
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
|
||||
</settings>
|
||||
|
||||
</configuration>
|
||||
|
@ -0,0 +1,69 @@
|
||||
package com.ruoyi.system.handler;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class MysqlTypeHandler<T extends Object> extends BaseTypeHandler<T> {
|
||||
|
||||
private Class<T> clazz;
|
||||
/**
|
||||
* 设置非空参数
|
||||
* @param ps
|
||||
* @param i
|
||||
* @param parameter
|
||||
* @param jdbcType
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
|
||||
ps.setString(i, JSON.toJSONString(parameter));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据列名,获取可以为空的结果
|
||||
* @param rs
|
||||
* @param columnName
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Override
|
||||
public T getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
String sqlJson = rs.getString(columnName);
|
||||
if (null != sqlJson){
|
||||
return JSON.parseObject(sqlJson, clazz);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据列索引,获取可以为空的结果
|
||||
* @param rs
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Override
|
||||
public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
String sqlJson = rs.getString(columnIndex);
|
||||
if (null != sqlJson){
|
||||
return JSON.parseObject(sqlJson, clazz);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
String sqlJson = cs.getString(columnIndex);
|
||||
if (null != sqlJson){
|
||||
return JSON.parseObject(sqlJson, clazz);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询文章列表
|
||||
// 查询内容列表
|
||||
export function listContent(query) {
|
||||
return request({
|
||||
url: '/cms/content/list',
|
||||
@ -9,7 +9,7 @@ export function listContent(query) {
|
||||
})
|
||||
}
|
||||
|
||||
// 查询文章详细
|
||||
// 查询内容详细
|
||||
export function getContent(id) {
|
||||
return request({
|
||||
url: '/cms/content/' + id,
|
||||
@ -17,7 +17,7 @@ export function getContent(id) {
|
||||
})
|
||||
}
|
||||
|
||||
// 新增文章
|
||||
// 新增内容
|
||||
export function addContent(data) {
|
||||
return request({
|
||||
url: '/cms/content',
|
||||
@ -26,7 +26,7 @@ export function addContent(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 修改文章
|
||||
// 修改内容
|
||||
export function updateContent(data) {
|
||||
return request({
|
||||
url: '/cms/content',
|
||||
@ -35,7 +35,7 @@ export function updateContent(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 删除文章
|
||||
// 删除内容
|
||||
export function delContent(id) {
|
||||
return request({
|
||||
url: '/cms/content/' + id,
|
||||
@ -51,7 +51,7 @@ export function categoryTreeSelect() {
|
||||
})
|
||||
}
|
||||
|
||||
// 恢复文章
|
||||
// 恢复内容
|
||||
export function recoverContentByIds(id) {
|
||||
return request({
|
||||
url: "/cms/content/" + id,
|
||||
@ -59,7 +59,7 @@ export function recoverContentByIds(id) {
|
||||
})
|
||||
}
|
||||
|
||||
// 发布文章
|
||||
// 发布内容
|
||||
export function changeContentByIds(id) {
|
||||
return request({
|
||||
url: "/cms/content/changeStatus/" + id,
|
||||
|
239
ruoyi-ui/src/components/VideoUpload/index.vue
Normal file
239
ruoyi-ui/src/components/VideoUpload/index.vue
Normal file
@ -0,0 +1,239 @@
|
||||
<template>
|
||||
<div class="component-upload-image">
|
||||
<el-upload
|
||||
multiple
|
||||
:action="uploadImgUrl"
|
||||
list-type="picture-card"
|
||||
:on-success="handleUploadSuccess"
|
||||
:before-upload="handleBeforeUpload"
|
||||
:limit="limit"
|
||||
:on-error="handleUploadError"
|
||||
:on-exceed="handleExceed"
|
||||
ref="imageUpload"
|
||||
:on-remove="handleDelete"
|
||||
:show-file-list="true"
|
||||
:headers="headers"
|
||||
:file-list="fileList"
|
||||
:on-preview="handlePictureCardPreview"
|
||||
:class="{hide: this.fileList.length >= this.limit}"
|
||||
>
|
||||
<i class="el-icon-plus"></i>
|
||||
<div slot="file" slot-scope="{file}">
|
||||
<video :src="file.url" controls style="width: 100%; height: auto;"></video>
|
||||
</div>
|
||||
</el-upload>
|
||||
|
||||
<!-- 上传提示 -->
|
||||
<div class="el-upload__tip" slot="tip" v-if="showTip">
|
||||
请上传
|
||||
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
|
||||
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
|
||||
的文件
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
:visible.sync="dialogVisible"
|
||||
title="预览"
|
||||
width="800"
|
||||
append-to-body
|
||||
>
|
||||
<video
|
||||
:src="dialogImageUrl"
|
||||
controls="controls"
|
||||
style="display: block; max-width: 100%; margin: 0 auto;object-fit: fill"
|
||||
/>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: [String, Object, Array],
|
||||
// 视频数量限制
|
||||
limit: {
|
||||
type: Number,
|
||||
default: 5,
|
||||
},
|
||||
// 大小限制(MB)
|
||||
fileSize: {
|
||||
type: Number,
|
||||
default: 500,
|
||||
},
|
||||
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
||||
fileType: {
|
||||
type: Array,
|
||||
default: () => ["mp4", "ogg", "flv", "avi", "wmv", "rmvb", "mov"],
|
||||
},
|
||||
// 是否显示提示
|
||||
isShowTip: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
number: 0,
|
||||
uploadList: [],
|
||||
dialogImageUrl: "",
|
||||
dialogVisible: false,
|
||||
hideUpload: false,
|
||||
baseUrl: process.env.VUE_APP_BASE_API,
|
||||
uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的视频服务器地址
|
||||
headers: {
|
||||
Authorization: "Bearer " + getToken(),
|
||||
},
|
||||
fileList: []
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
handler(val) {
|
||||
if (val) {
|
||||
// 首先将值转为数组
|
||||
const list = Array.isArray(val) ? val : this.value.split(',');
|
||||
// 然后将数组转为对象数组
|
||||
this.fileList = list.map(item => {
|
||||
if (typeof item === "string") {
|
||||
if (item.indexOf(this.baseUrl) === -1) {
|
||||
item = { name: this.baseUrl + item, url: this.baseUrl + item };
|
||||
} else {
|
||||
item = { name: item, url: item };
|
||||
}
|
||||
}
|
||||
return item;
|
||||
});
|
||||
} else {
|
||||
this.fileList = [];
|
||||
return [];
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 是否显示提示
|
||||
showTip() {
|
||||
return this.isShowTip && (this.fileType || this.fileSize);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 上传前loading加载
|
||||
handleBeforeUpload(file) {
|
||||
let isImg = false;
|
||||
if (this.fileType.length) {
|
||||
let fileExtension = "";
|
||||
if (file.name.lastIndexOf(".") > -1) {
|
||||
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
|
||||
}
|
||||
isImg = this.fileType.some(type => {
|
||||
if (file.type.indexOf(type) > -1) return true;
|
||||
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
isImg = file.type.indexOf("image") > -1;
|
||||
}
|
||||
|
||||
if (!isImg) {
|
||||
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}视频格式文件!`);
|
||||
return false;
|
||||
}
|
||||
if (this.fileSize) {
|
||||
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
||||
if (!isLt) {
|
||||
this.$modal.msgError(`上传头像视频大小不能超过 ${this.fileSize} MB!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.$modal.loading("正在上传视频,请稍候...");
|
||||
this.number++;
|
||||
},
|
||||
// 文件个数超出
|
||||
handleExceed() {
|
||||
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
|
||||
},
|
||||
// 上传成功回调
|
||||
handleUploadSuccess(res, file) {
|
||||
if (res.code === 200) {
|
||||
this.uploadList.push({ name: res.fileName, url: res.fileName });
|
||||
this.uploadedSuccessfully();
|
||||
} else {
|
||||
this.number--;
|
||||
this.$modal.closeLoading();
|
||||
this.$modal.msgError(res.msg);
|
||||
this.$refs.imageUpload.handleRemove(file);
|
||||
this.uploadedSuccessfully();
|
||||
}
|
||||
},
|
||||
// 删除视频
|
||||
handleDelete(file) {
|
||||
const findex = this.fileList.map(f => f.name).indexOf(file.name);
|
||||
if (findex > -1) {
|
||||
this.fileList.splice(findex, 1);
|
||||
this.$emit("input", this.listToString(this.fileList));
|
||||
}
|
||||
},
|
||||
// 上传失败
|
||||
handleUploadError() {
|
||||
this.$modal.msgError("上传视频失败,请重试");
|
||||
this.$modal.closeLoading();
|
||||
},
|
||||
// 上传结束处理
|
||||
uploadedSuccessfully() {
|
||||
if (this.number > 0 && this.uploadList.length === this.number) {
|
||||
this.fileList = this.fileList.concat(this.uploadList);
|
||||
this.uploadList = [];
|
||||
this.number = 0;
|
||||
this.$emit("input", this.listToString(this.fileList));
|
||||
this.$modal.closeLoading();
|
||||
}
|
||||
},
|
||||
// 预览
|
||||
handlePictureCardPreview(file) {
|
||||
this.dialogImageUrl = file.url;
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
// 对象转成指定字符串分隔
|
||||
listToString(list, separator) {
|
||||
let strs = "";
|
||||
separator = separator || ",";
|
||||
for (let i in list) {
|
||||
if (list[i].url) {
|
||||
strs += list[i].url.replace(this.baseUrl, "") + separator;
|
||||
}
|
||||
}
|
||||
return strs != '' ? strs.substr(0, strs.length - 1) : '';
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
// .el-upload--picture-card 控制加号部分
|
||||
::v-deep.hide .el-upload--picture-card {
|
||||
display: none;
|
||||
}
|
||||
// 去掉动画效果
|
||||
::v-deep .el-list-enter-active,
|
||||
::v-deep .el-list-leave-active {
|
||||
transition: all 0s;
|
||||
}
|
||||
|
||||
::v-deep .el-list-enter, .el-list-leave-active {
|
||||
opacity: 0;
|
||||
transform: translateY(0);
|
||||
}
|
||||
::v-deep .el-upload-list--picture-card .el-upload-list__item{
|
||||
width: 222px;
|
||||
height: 110px;
|
||||
}
|
||||
::v-deep .el-upload--picture-card{
|
||||
width: 222px;
|
||||
height: 110px;
|
||||
line-height: 110px;
|
||||
}
|
||||
</style>
|
||||
|
@ -39,6 +39,8 @@ import VueMeta from 'vue-meta'
|
||||
import DictData from '@/components/DictData'
|
||||
// UEditorPlus
|
||||
import VueUeditorWrap from 'vue-ueditor-wrap'
|
||||
// 视频上传组件
|
||||
import VideoUpload from "@/components/VideoUpload"
|
||||
|
||||
// 全局方法挂载
|
||||
Vue.prototype.getDicts = getDicts
|
||||
@ -60,6 +62,7 @@ Vue.component('FileUpload', FileUpload)
|
||||
Vue.component('ImageUpload', ImageUpload)
|
||||
Vue.component('ImagePreview', ImagePreview)
|
||||
Vue.component('VueUeditorWrap', VueUeditorWrap)
|
||||
Vue.component('VideoUpload', VideoUpload)
|
||||
|
||||
Vue.use(directive)
|
||||
Vue.use(plugins)
|
||||
|
@ -20,16 +20,6 @@
|
||||
@click="handleDelete">删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
plain
|
||||
type="primary"
|
||||
icon="el-icon-timer"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleUpdate">修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
plain
|
||||
@ -58,7 +48,7 @@
|
||||
<el-form-item prop="contentTitle">
|
||||
<el-input
|
||||
v-model="queryParams.contentTitle"
|
||||
placeholder="请输入文章标题"
|
||||
placeholder="请输入内容标题"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
@keyup.enter.native="handleQuery"/>
|
||||
@ -66,7 +56,7 @@
|
||||
<el-form-item prop="contentType">
|
||||
<el-select
|
||||
v-model="queryParams.contentType"
|
||||
placeholder="文章类型"
|
||||
placeholder="内容类型"
|
||||
clearable
|
||||
style="width: 125px">
|
||||
<el-option
|
||||
@ -104,12 +94,11 @@
|
||||
ref="tableContentList"
|
||||
:data="contentList"
|
||||
size="small"
|
||||
@row-click="handleRowClick"
|
||||
@cell-dblclick="handleEdit"
|
||||
@selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="50" align="center"/>
|
||||
<el-table-column label="文章标题" align="center" prop="contentTitle"/>
|
||||
<el-table-column label="文章类型" align="center" prop="contentType">
|
||||
<el-table-column label="内容标题" align="center" prop="contentTitle"/>
|
||||
<el-table-column label="内容类型" align="center" prop="contentType">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.cms_content_type" :value="scope.row.contentType"/>
|
||||
</template>
|
||||
@ -225,7 +214,7 @@ export default {
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id ? [row.id] : this.selectedRows.map(row => row.id);
|
||||
this.$modal.confirm('是否确认删除所选文章?').then(function () {
|
||||
this.$modal.confirm('是否确认删除所选内容?').then(function () {
|
||||
return delContent(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
@ -245,21 +234,21 @@ export default {
|
||||
getContent(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改文章";
|
||||
this.title = "修改内容";
|
||||
});
|
||||
},
|
||||
// 发布
|
||||
handlePublish(row) {
|
||||
const statues = row.status ? [row.status] : this.selectedRows.map(row => row.status)
|
||||
if (statues.includes("1")) {
|
||||
this.$modal.msgError("所选文章已发布!!!");
|
||||
this.$modal.msgError("所选内容已发布!!!");
|
||||
} else {
|
||||
const ids = row.id ? [row.id] : this.selectedRows.map(row => row.id);
|
||||
this.$modal.confirm('是否确认下线所选文章?').then(function () {
|
||||
this.$modal.confirm('是否确认发布所选内容?').then(function () {
|
||||
return changeContentByIds(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("下线成功");
|
||||
this.$modal.msgSuccess("发布成功");
|
||||
}).catch(() => {
|
||||
});
|
||||
}
|
||||
@ -268,10 +257,10 @@ export default {
|
||||
handleOffline(row) {
|
||||
const statues = row.status ? [row.status] : this.selectedRows.map(row => row.status)
|
||||
if (!statues.includes("1")) {
|
||||
this.$modal.msgError("所选文章为初稿或已下线文章,不能下线!!!");
|
||||
this.$modal.msgError("所选内容为初稿或已下线内容,不能下线!!!");
|
||||
} else {
|
||||
const ids = row.id ? [row.id] : this.selectedRows.map(row => row.id);
|
||||
this.$modal.confirm('是否确认下线所选文章?').then(function () {
|
||||
this.$modal.confirm('是否确认下线所选内容?').then(function () {
|
||||
return changeContentByIds(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
@ -285,7 +274,7 @@ export default {
|
||||
this.queryParams.page = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 查询文章列表 */
|
||||
/** 查询内容列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listContent(this.queryParams).then(response => {
|
||||
@ -299,20 +288,9 @@ export default {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 单击数据
|
||||
handleRowClick(currentRow) {
|
||||
this.toggleAllCheckedRows();
|
||||
this.$refs.tableContentList.toggleRowSelection(currentRow);
|
||||
},
|
||||
// 双击数据
|
||||
handleEdit(row) {
|
||||
// this.handleAdd(row.catalogId, row.contentId, row.contentType);
|
||||
},
|
||||
toggleAllCheckedRows() {
|
||||
// this.selectedRows.forEach(row => {
|
||||
// this.$refs.tableContentList.toggleRowSelection(row, false);
|
||||
// });
|
||||
// this.selectedRows = [];
|
||||
this.$router.push({path: '/content/editor', query: {"contentId": row.id}})
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -35,7 +35,7 @@
|
||||
<el-form-item prop="contentTitle">
|
||||
<el-input
|
||||
v-model="queryParams.contentTitle"
|
||||
placeholder="请输入文章标题"
|
||||
placeholder="请输入内容标题"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
@keyup.enter.native="handleQuery" />
|
||||
@ -43,7 +43,7 @@
|
||||
<el-form-item prop="contentType">
|
||||
<el-select
|
||||
v-model="queryParams.contentType"
|
||||
placeholder="文章类型"
|
||||
placeholder="内容类型"
|
||||
clearable
|
||||
style="width: 125px">
|
||||
<el-option
|
||||
@ -91,8 +91,8 @@
|
||||
type="selection"
|
||||
width="50"
|
||||
align="center" />
|
||||
<el-table-column label="文章标题" :show-overflow-tooltip="true" prop="contentTitle" />
|
||||
<el-table-column label="文章类型" align="center" prop="contentType">
|
||||
<el-table-column label="内容标题" :show-overflow-tooltip="true" prop="contentTitle" />
|
||||
<el-table-column label="内容类型" align="center" prop="contentType">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.cms_content_type" :value="scope.row.contentType"/>
|
||||
</template>
|
||||
@ -194,7 +194,7 @@ export default {
|
||||
// 恢复
|
||||
handleRecover(row) {
|
||||
const ids = row.id ? [ row.id ] : this.selectedRows.map(row => row.id);
|
||||
this.$modal.confirm('是否确认恢复所选文章?').then(function () {
|
||||
this.$modal.confirm('是否确认恢复所选内容?').then(function () {
|
||||
return recoverContentByIds(ids);
|
||||
}).then(() => {
|
||||
this.getRecycleList();
|
||||
@ -204,7 +204,14 @@ export default {
|
||||
},
|
||||
// 彻底删除
|
||||
handleDelete(row) {
|
||||
|
||||
const ids = row.id ? [row.id] : this.selectedRows.map(row => row.id);
|
||||
this.$modal.confirm('该操作不可逆,确认删除所选内容?').then(function () {
|
||||
return delContent(ids);
|
||||
}).then(() => {
|
||||
this.getRecycleList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {
|
||||
});
|
||||
},
|
||||
// 查询
|
||||
handleQuery () {
|
||||
|
@ -56,7 +56,7 @@ export default {
|
||||
return {
|
||||
selectCategoryId: '',
|
||||
activeName: "contentList",
|
||||
// 文章表格数据
|
||||
// 内容表格数据
|
||||
contentList: null,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
@ -87,10 +87,10 @@ export default {
|
||||
multiple: true,
|
||||
// 列信息
|
||||
columns: [
|
||||
{key: 0, label: `文章标题`, visible: true},
|
||||
{key: 1, label: `文章描述`, visible: true},
|
||||
{key: 2, label: `文章类型`, visible: true},
|
||||
{key: 3, label: `文章状态`, visible: true},
|
||||
{key: 0, label: `内容标题`, visible: true},
|
||||
{key: 1, label: `内容描述`, visible: true},
|
||||
{key: 2, label: `内容类型`, visible: true},
|
||||
{key: 3, label: `内容状态`, visible: true},
|
||||
{key: 4, label: `创建时间`, visible: true},
|
||||
],
|
||||
}
|
||||
@ -144,7 +144,7 @@ export default {
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 查询文章列表 */
|
||||
/** 查询内容列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listContent(this.queryParams).then(response => {
|
||||
|
@ -3,8 +3,8 @@
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<div class="grid-btn-bar bg-purple-white">
|
||||
<el-button plain type="success" size="mini" icon="el-icon-edit">保存</el-button>
|
||||
<el-button plain type="primary" size="mini" icon="el-icon-s-promotion">发布</el-button>
|
||||
<el-button plain type="success" size="mini" icon="el-icon-edit" @click="handleSave">保存</el-button>
|
||||
<el-button plain type="primary" size="mini" icon="el-icon-s-promotion" @click="handlePublish">发布</el-button>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -15,7 +15,7 @@
|
||||
<el-col class="pr10" style="margin: 15px 0 20px 0 ">
|
||||
<el-card shadow="always" class="card-title">
|
||||
<div class="art-title bg-purple-white">
|
||||
<el-form-item label="文章标题" prop="contentTitle">
|
||||
<el-form-item label="内容标题" prop="contentTitle">
|
||||
<el-input
|
||||
v-model="form.contentTitle"
|
||||
maxlength="360"
|
||||
@ -24,7 +24,7 @@
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="art-title bg-purple-white">
|
||||
<el-form-item label="文章描述" prop="summary">
|
||||
<el-form-item label="内容描述" prop="summary">
|
||||
<el-input
|
||||
v-model="form.summary"
|
||||
maxlength="360"
|
||||
@ -33,14 +33,14 @@
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="art-title bg-purple-white">
|
||||
<el-form-item label="文章类型" prop="contentType">
|
||||
<el-form-item label="内容类型" prop="contentType">
|
||||
<el-radio-group v-model="form.contentType" @change="handleChangeType">
|
||||
<el-radio-button
|
||||
v-for="dict in dict.type.cms_content_type"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>
|
||||
{{dict.label}}
|
||||
{{ dict.label }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
@ -51,24 +51,18 @@
|
||||
<el-row>
|
||||
<el-col class="pr10">
|
||||
<el-card shadow="always" class="card-editor">
|
||||
<div v-if="isType === '0'" class="content bg-purple-white">
|
||||
<vue-ueditor-wrap v-model="form.content"
|
||||
<div v-show="isType === '0'" class="content bg-purple-white">
|
||||
<vue-ueditor-wrap v-model="form.contentDetail"
|
||||
editor-id="editor"
|
||||
:config="editorConfig"
|
||||
:editorDependencies="['ueditor.config.js','ueditor.all.js']"
|
||||
/>
|
||||
/>
|
||||
</div>
|
||||
<div v-if="isType === '1'" class="content bg-purple-white">
|
||||
<div class="btn-add-image bg-purple-white" @click="addImage">
|
||||
<svg-icon icon-class="image" style="width:60px;height:60px;"></svg-icon>
|
||||
<div>添加图片</div>
|
||||
</div>
|
||||
<div v-show="isType === '1'" class="content bg-purple-white btn-add-image">
|
||||
<image-upload v-model="form.imageUrl"/>
|
||||
</div>
|
||||
<div v-if="isType === '2'" class="content bg-purple-white">
|
||||
<div class="btn-add bg-purple-white" @click="addItem">
|
||||
<svg-icon icon-class="video" style="width:60px;height:60px;"></svg-icon>
|
||||
<div>添加视频</div>
|
||||
</div>
|
||||
<div v-show="isType === '2'" class="content bg-purple-white btn-add-image">
|
||||
<video-upload v-model="form.videoUrl"></video-upload>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
@ -78,7 +72,7 @@
|
||||
<div class="bg-purple-white">
|
||||
<el-card shadow="always">
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane label="文章属性" name="basic">
|
||||
<el-tab-pane label="内容属性" name="basic">
|
||||
<el-form-item label="所属栏目" prop="categoryId">
|
||||
<el-select v-model="form.categoryId" placeholder="所属栏目">
|
||||
<el-option
|
||||
@ -89,16 +83,14 @@
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="缩略图" prop="logo" >
|
||||
<div class="no-picture" style="width: 200px;height: 140px;font-size: 145px">
|
||||
<svg-icon icon-class="upload" @click="handleEdit"></svg-icon>
|
||||
</div>
|
||||
<el-form-item label="缩略图" prop="logo">
|
||||
<image-upload :limit="1" v-model="form.contentImg"></image-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="作者" prop="author">
|
||||
<el-input v-model="form.author" />
|
||||
<el-input v-model="form.author"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="编辑" prop="editor">
|
||||
<el-input v-model="form.editor" />
|
||||
<el-input v-model="form.editor"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="原创" prop="original">
|
||||
<el-switch
|
||||
@ -108,17 +100,13 @@
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="来源" prop="source">
|
||||
<el-input v-model="form.source" />
|
||||
<el-input v-model="form.source"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="来源地址" prop="sourceUrl">
|
||||
<el-input v-model="form.sourceUrl" placeholder="http(s)://" />
|
||||
<el-input v-model="form.sourceUrl" placeholder="http(s)://"/>
|
||||
</el-form-item>
|
||||
<el-divider></el-divider>
|
||||
<el-form-item label="发布时间" prop="publishDate">
|
||||
<el-date-picker v-model="form.publishDate" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" style="width:195px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="下线时间" prop="offlineDate">
|
||||
<el-date-picker v-model="form.offlineDate" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" style="width:195px;" />
|
||||
<el-form-item label="附件" prop="accessoryUrl">
|
||||
<file-upload v-model="form.accessoryUrl"/>
|
||||
</el-form-item>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@ -133,6 +121,8 @@
|
||||
<script>
|
||||
import VueUeditorWrap from "vue-ueditor-wrap";
|
||||
import {getLeavesCategoryList} from "@/api/cms/editor"
|
||||
import {addContent, getContent, updateContent} from "@/api/cms/content";
|
||||
|
||||
export default {
|
||||
name: "Content",
|
||||
dicts: ['cms_content_type'],
|
||||
@ -140,8 +130,28 @@ export default {
|
||||
VueUeditorWrap
|
||||
},
|
||||
created() {
|
||||
this.reset()
|
||||
this.getCategoryList()
|
||||
},
|
||||
watch: {
|
||||
// 监听内容管理传过来的categoryId
|
||||
"$route.query.categoryId": {
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.reset()
|
||||
this.getCategoryList()
|
||||
},
|
||||
},
|
||||
"$route.query.contentId": {
|
||||
immediate: true,
|
||||
handler(val) {
|
||||
if (val !== undefined) {
|
||||
this.reset()
|
||||
this.getContentById(val)
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadLimit: 1,
|
||||
@ -149,23 +159,29 @@ export default {
|
||||
imgUploadUrl: process.env.VUE_APP_BASE_API + "/ueditor/config?action=uploadimage",
|
||||
isType: "0",
|
||||
activeName: "basic",
|
||||
summaryInputSize: { minRows: 3, maxRows: 6 },
|
||||
summaryInputSize: {minRows: 3, maxRows: 6},
|
||||
// 表单参数
|
||||
form: {
|
||||
contentType: "0",
|
||||
attributes: [],
|
||||
contentJson: [],
|
||||
contentHtml: "",
|
||||
downloadRemoteImage: "Y",
|
||||
original: "0",
|
||||
publishPipe: [],
|
||||
imageList: [],
|
||||
tags:[],
|
||||
keywords:[]
|
||||
categoryId: '',
|
||||
imageUrl: [],
|
||||
videoUrl: [],
|
||||
contentTitle: '',
|
||||
contentImg: '',
|
||||
contentDetail: '',
|
||||
source: '',
|
||||
sourceUrl: '',
|
||||
author: '',
|
||||
editor: '',
|
||||
summary: '',
|
||||
status: '0',
|
||||
isAccessory: '0',
|
||||
accessoryUrl: []
|
||||
},
|
||||
rules: {
|
||||
contentTitle: [{ required: true, message: "文章标题不能为空", trigger: "blur" }],
|
||||
categoryId: [{required: true, methods: "所属栏目不能为空", trigger: "blur"}]
|
||||
contentTitle: [{required: true, message: "内容标题不能为空", trigger: "blur"}],
|
||||
categoryId: [{required: true, message: "所属栏目不能为空", trigger: "blur"}]
|
||||
},
|
||||
editorConfig: {
|
||||
initialFrameHeight: 1000, // 初始高度
|
||||
@ -176,10 +192,31 @@ export default {
|
||||
UEDITOR_HOME_URL: '/static/UEditorPlus/',
|
||||
UEDITOR_CORS_URL: '/static/UEditorPlus/',
|
||||
},
|
||||
categoryList:"",
|
||||
categoryList: "",
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 清空form
|
||||
reset() {
|
||||
this.form = {
|
||||
contentType: this.isType,
|
||||
original: "0",
|
||||
categoryId: this.$route.query.categoryId === "0" ? this.form.categoryId : this.$route.query.categoryId,
|
||||
imageUrl: [],
|
||||
videoUrl: [],
|
||||
contentTitle: '',
|
||||
contentImg: '',
|
||||
contentDetail: '',
|
||||
source: '',
|
||||
sourceUrl: '',
|
||||
author: '',
|
||||
editor: '',
|
||||
summary: '',
|
||||
status: '0',
|
||||
isAccessory: '0',
|
||||
accessoryUrl: []
|
||||
}
|
||||
},
|
||||
handleCatalogChange() {
|
||||
this.openCatalogSelector = true;
|
||||
this.disableLinkCatalog = false;
|
||||
@ -188,24 +225,73 @@ export default {
|
||||
getCategoryList() {
|
||||
getLeavesCategoryList().then(response => {
|
||||
this.categoryList = response.data
|
||||
this.categoryList.forEach(item => {
|
||||
if (item.id === this.$route.query.categoryId) {
|
||||
this.form.categoryId = this.$route.query.categoryId.toString()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
handleChangeType(){
|
||||
handleChangeType() {
|
||||
this.isType = this.form.contentType
|
||||
},
|
||||
addImage () {
|
||||
this.editIndex = -1;
|
||||
this.uploadLimit = 1;
|
||||
handleEdit() {
|
||||
this.openResourceDialog = true;
|
||||
},
|
||||
addItem () {
|
||||
this.editIndex = -1;
|
||||
this.uploadLimit = 1;
|
||||
this.resourceType = 'video';
|
||||
this.openResourceDialog = true;
|
||||
// 发布
|
||||
handlePublish() {
|
||||
this.form.status = "1"
|
||||
this.handleSave();
|
||||
},
|
||||
handleEdit () {
|
||||
this.openResourceDialog = true;
|
||||
// 新增
|
||||
handleSave() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
this.$modal.loading("正在" + (this.form.status == "0" ? "保存" : "发布") + "内容,请稍候...");
|
||||
// if:修改,else:新增
|
||||
if (this.form.id != null) {
|
||||
this.form.status = "3"
|
||||
this.changeUrl()
|
||||
updateContent(this.form).then(res => {
|
||||
if (res.code == 200) {
|
||||
this.$modal.msgSuccess(this.form.status == "0" ? "保存成功" : "发布成功");
|
||||
this.reset()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.changeUrl()
|
||||
addContent(this.form).then(res => {
|
||||
if (res.code == 200) {
|
||||
this.$modal.msgSuccess(this.form.status == "0" ? "保存成功" : "发布成功");
|
||||
this.reset()
|
||||
}
|
||||
})
|
||||
}
|
||||
this.$modal.closeLoading();
|
||||
}
|
||||
})
|
||||
},
|
||||
// 查询单条记录回显
|
||||
getContentById(contentId) {
|
||||
getContent(contentId).then(res => {
|
||||
this.form = res.data
|
||||
this.isType = this.form.contentType
|
||||
})
|
||||
},
|
||||
StrToArr(value) {
|
||||
return value.toString().split(",")
|
||||
},
|
||||
changeUrl() {
|
||||
if (this.form.accessoryUrl !== null && this.form.accessoryUrl.length !== 0) {
|
||||
this.form.isAccessory = "1"
|
||||
this.form.accessoryUrl = this.StrToArr(this.form.accessoryUrl)
|
||||
}
|
||||
if (this.form.imageUrl !== null && this.form.imageUrl.length !== 0) {
|
||||
this.form.imageUrl = this.StrToArr(this.form.imageUrl)
|
||||
}
|
||||
if (this.form.videoUrl !== null && this.form.videoUrl.length !== 0) {
|
||||
this.form.videoUrl = this.StrToArr(this.form.videoUrl)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -219,9 +305,11 @@ export default {
|
||||
cursor: pointer;
|
||||
fill: #5a5e66;
|
||||
}
|
||||
|
||||
.btn-add-image:hover {
|
||||
color:#1890ff;
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.btn-add {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
@ -229,15 +317,18 @@ export default {
|
||||
cursor: pointer;
|
||||
fill: #5a5e66;
|
||||
}
|
||||
|
||||
.btn-add:hover {
|
||||
color:#1890ff;
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.no-picture {
|
||||
border: 3px dashed #a7a7a7;
|
||||
text-align: center;
|
||||
color: #777;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.no-picture:hover {
|
||||
color: #409EFF;
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
// 页面加载完毕调用
|
||||
// this.tabLsit();
|
||||
this.tabLsit();
|
||||
},
|
||||
computed: {
|
||||
customswiper() {
|
||||
@ -342,13 +342,12 @@ export default {
|
||||
if(res.code == 200){
|
||||
let list = res.data[3].children.list
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
this.bannerlist.push(process.env.VUE_APP_BASE_API+list[i].imageUrl)
|
||||
this.bannerlist.push(process.env.VUE_APP_BASE_API+list[i].imageUrl[0])
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
this.categoryList()
|
||||
console.log(this.tablist)
|
||||
})
|
||||
},
|
||||
/** 获取首页下的所有子栏目 */
|
||||
|
@ -81,7 +81,7 @@ INSERT INTO `cms_category` VALUES (1813832334466748416, '联系我们', 12, 'con
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `cms_content`;
|
||||
CREATE TABLE `cms_content` (
|
||||
`id` bigint(20) NOT NULL COMMENT '文章ID',
|
||||
`id` bigint(20) NOT NULL COMMENT '内容ID',
|
||||
`category_id` bigint(20) NOT NULL COMMENT '所属栏目',
|
||||
`content_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文章标题',
|
||||
`content_details` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '文章内容',
|
||||
|
Loading…
Reference in New Issue
Block a user