2024.7.10 新元素官网

This commit is contained in:
lee 2024-07-26 15:42:38 +08:00
parent 25a85220ba
commit 6977fa5c50
17 changed files with 2025 additions and 1100 deletions

View File

@ -33,8 +33,19 @@ public class DoorController extends BaseController
@Autowired @Autowired
private IXysImgService xysImgService; private IXysImgService xysImgService;
/** /**
* 查询文章列表 * 首页文章
*/
@GetMapping("/getHomeArticleList")
public TableDataInfo getHomeArticleList(XysArticle xysArticle)
{
List<XysArticle> list = xysArticleService.selectHomeArticleList(xysArticle);
return getDataTable(list);
}
/**
* 查询新闻动态文章列表
*/ */
@GetMapping("/getArticleList") @GetMapping("/getArticleList")
public TableDataInfo getArticleList(XysArticle xysArticle) public TableDataInfo getArticleList(XysArticle xysArticle)
@ -58,7 +69,7 @@ public class DoorController extends BaseController
/** /**
* 获取文章管理详细信息 * 获取文章管理详细信息
*/ */
@GetMapping(value = "/{id}") @GetMapping(value = "/getArticle/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id)
{ {
return success(xysArticleService.selectXysArticleById(id)); return success(xysArticleService.selectXysArticleById(id));

View File

@ -0,0 +1,104 @@
package com.ruoyi.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.XysCategory;
import com.ruoyi.system.service.IXysCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 文章分类Controller
*
* @author libao
* @date 2024-07-25
*/
@RestController
@RequestMapping("/system/category")
public class XysCategoryController extends BaseController
{
@Autowired
private IXysCategoryService xysCategoryService;
/**
* 查询文章分类列表
*/
@PreAuthorize("@ss.hasPermi('system:category:list')")
@GetMapping("/list")
public TableDataInfo list(XysCategory xysCategory)
{
startPage();
List<XysCategory> list = xysCategoryService.selectXysCategoryList(xysCategory);
return getDataTable(list);
}
/**
* 导出文章分类列表
*/
@PreAuthorize("@ss.hasPermi('system:category:export')")
@Log(title = "文章分类", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, XysCategory xysCategory)
{
List<XysCategory> list = xysCategoryService.selectXysCategoryList(xysCategory);
ExcelUtil<XysCategory> util = new ExcelUtil<XysCategory>(XysCategory.class);
util.exportExcel(response, list, "文章分类数据");
}
/**
* 获取文章分类详细信息
*/
@PreAuthorize("@ss.hasPermi('system:category:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(xysCategoryService.selectXysCategoryById(id));
}
/**
* 新增文章分类
*/
@PreAuthorize("@ss.hasPermi('system:category:add')")
@Log(title = "文章分类", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody XysCategory xysCategory)
{
return toAjax(xysCategoryService.insertXysCategory(xysCategory));
}
/**
* 修改文章分类
*/
@PreAuthorize("@ss.hasPermi('system:category:edit')")
@Log(title = "文章分类", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody XysCategory xysCategory)
{
return toAjax(xysCategoryService.updateXysCategory(xysCategory));
}
/**
* 删除文章分类
*/
@PreAuthorize("@ss.hasPermi('system:category:remove')")
@Log(title = "文章分类", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(xysCategoryService.deleteXysCategoryByIds(ids));
}
}

View File

@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage").permitAll() .antMatchers("/login", "/register", "/captchaImage","/door/**").permitAll()
// 静态资源可匿名访问 // 静态资源可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

View File

@ -26,6 +26,18 @@ public class XysArticle extends BaseEntity
@Excel(name = "封面图") @Excel(name = "封面图")
private String coverImg; private String coverImg;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
/** 简介 */
@Excel(name = "简介")
private String description;
/** 内容 */ /** 内容 */
@Excel(name = "内容") @Excel(name = "内容")
private String content; private String content;

View File

@ -0,0 +1,111 @@
package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 文章分类对象 xys_category
*
* @author libao
* @date 2024-07-25
*/
public class XysCategory extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 文章分类 */
private Long id;
/** 上级分类 */
@Excel(name = "上级分类")
private Long parentId;
/** 分类名称 */
@Excel(name = "分类名称")
private String title;
/** 封面图 */
@Excel(name = "封面图")
private String coverImg;
/** 简介 */
@Excel(name = "简介")
private String description;
/** */
private String delFlag;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
public Long getParentId()
{
return parentId;
}
public void setTitle(String title)
{
this.title = title;
}
public String getTitle()
{
return title;
}
public void setCoverImg(String coverImg)
{
this.coverImg = coverImg;
}
public String getCoverImg()
{
return coverImg;
}
public void setDescription(String description)
{
this.description = description;
}
public String getDescription()
{
return description;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getDelFlag()
{
return delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("parentId", getParentId())
.append("title", getTitle())
.append("coverImg", getCoverImg())
.append("description", getDescription())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.append("remark", getRemark())
.append("delFlag", getDelFlag())
.toString();
}
}

View File

@ -27,6 +27,13 @@ public interface XysArticleMapper
*/ */
public List<XysArticle> selectXysArticleList(XysArticle xysArticle); public List<XysArticle> selectXysArticleList(XysArticle xysArticle);
/**
* 首页文章
* @param xysArticle
* @return
*/
public List<XysArticle> selectHomeArticleList(XysArticle xysArticle);
/** /**
* 新增文章管理 * 新增文章管理
* *

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.XysCategory;
/**
* 文章分类Mapper接口
*
* @author libao
* @date 2024-07-25
*/
public interface XysCategoryMapper
{
/**
* 查询文章分类
*
* @param id 文章分类主键
* @return 文章分类
*/
public XysCategory selectXysCategoryById(Long id);
/**
* 查询文章分类列表
*
* @param xysCategory 文章分类
* @return 文章分类集合
*/
public List<XysCategory> selectXysCategoryList(XysCategory xysCategory);
/**
* 新增文章分类
*
* @param xysCategory 文章分类
* @return 结果
*/
public int insertXysCategory(XysCategory xysCategory);
/**
* 修改文章分类
*
* @param xysCategory 文章分类
* @return 结果
*/
public int updateXysCategory(XysCategory xysCategory);
/**
* 删除文章分类
*
* @param id 文章分类主键
* @return 结果
*/
public int deleteXysCategoryById(Long id);
/**
* 批量删除文章分类
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteXysCategoryByIds(Long[] ids);
}

View File

@ -27,6 +27,13 @@ public interface IXysArticleService
*/ */
public List<XysArticle> selectXysArticleList(XysArticle xysArticle); public List<XysArticle> selectXysArticleList(XysArticle xysArticle);
/**
* 首页文章
* @param xysArticle
* @return
*/
public List<XysArticle> selectHomeArticleList(XysArticle xysArticle);
/** /**
* 新增文章管理 * 新增文章管理
* *

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.XysCategory;
/**
* 文章分类Service接口
*
* @author libao
* @date 2024-07-25
*/
public interface IXysCategoryService
{
/**
* 查询文章分类
*
* @param id 文章分类主键
* @return 文章分类
*/
public XysCategory selectXysCategoryById(Long id);
/**
* 查询文章分类列表
*
* @param xysCategory 文章分类
* @return 文章分类集合
*/
public List<XysCategory> selectXysCategoryList(XysCategory xysCategory);
/**
* 新增文章分类
*
* @param xysCategory 文章分类
* @return 结果
*/
public int insertXysCategory(XysCategory xysCategory);
/**
* 修改文章分类
*
* @param xysCategory 文章分类
* @return 结果
*/
public int updateXysCategory(XysCategory xysCategory);
/**
* 批量删除文章分类
*
* @param ids 需要删除的文章分类主键集合
* @return 结果
*/
public int deleteXysCategoryByIds(Long[] ids);
/**
* 删除文章分类信息
*
* @param id 文章分类主键
* @return 结果
*/
public int deleteXysCategoryById(Long id);
}

View File

@ -44,6 +44,11 @@ public class XysArticleServiceImpl implements IXysArticleService
return xysArticleMapper.selectXysArticleList(xysArticle); return xysArticleMapper.selectXysArticleList(xysArticle);
} }
@Override
public List<XysArticle> selectHomeArticleList(XysArticle xysArticle) {
return xysArticleMapper.selectHomeArticleList(xysArticle);
}
/** /**
* 新增文章管理 * 新增文章管理
* *

View File

@ -0,0 +1,96 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.XysCategoryMapper;
import com.ruoyi.system.domain.XysCategory;
import com.ruoyi.system.service.IXysCategoryService;
/**
* 文章分类Service业务层处理
*
* @author libao
* @date 2024-07-25
*/
@Service
public class XysCategoryServiceImpl implements IXysCategoryService
{
@Autowired
private XysCategoryMapper xysCategoryMapper;
/**
* 查询文章分类
*
* @param id 文章分类主键
* @return 文章分类
*/
@Override
public XysCategory selectXysCategoryById(Long id)
{
return xysCategoryMapper.selectXysCategoryById(id);
}
/**
* 查询文章分类列表
*
* @param xysCategory 文章分类
* @return 文章分类
*/
@Override
public List<XysCategory> selectXysCategoryList(XysCategory xysCategory)
{
return xysCategoryMapper.selectXysCategoryList(xysCategory);
}
/**
* 新增文章分类
*
* @param xysCategory 文章分类
* @return 结果
*/
@Override
public int insertXysCategory(XysCategory xysCategory)
{
xysCategory.setCreateTime(DateUtils.getNowDate());
return xysCategoryMapper.insertXysCategory(xysCategory);
}
/**
* 修改文章分类
*
* @param xysCategory 文章分类
* @return 结果
*/
@Override
public int updateXysCategory(XysCategory xysCategory)
{
xysCategory.setUpdateTime(DateUtils.getNowDate());
return xysCategoryMapper.updateXysCategory(xysCategory);
}
/**
* 批量删除文章分类
*
* @param ids 需要删除的文章分类主键
* @return 结果
*/
@Override
public int deleteXysCategoryByIds(Long[] ids)
{
return xysCategoryMapper.deleteXysCategoryByIds(ids);
}
/**
* 删除文章分类信息
*
* @param id 文章分类主键
* @return 结果
*/
@Override
public int deleteXysCategoryById(Long id)
{
return xysCategoryMapper.deleteXysCategoryById(id);
}
}

View File

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" /> <result property="id" column="id" />
<result property="title" column="title" /> <result property="title" column="title" />
<result property="coverImg" column="cover_img" /> <result property="coverImg" column="cover_img" />
<result property="description" column="description" />
<result property="content" column="content" /> <result property="content" column="content" />
<result property="articleCat" column="article_cat" /> <result property="articleCat" column="article_cat" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
@ -19,15 +20,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectXysArticleVo"> <sql id="selectXysArticleVo">
select id, title, cover_img, content, article_cat, create_time, create_by, update_time, update_by, remark, del_flag from xys_article select id, title, cover_img, description,content, article_cat, create_time, create_by, update_time, update_by, remark, del_flag from xys_article
</sql> </sql>
<select id="selectHomeArticleList" parameterType="XysArticle" resultMap="XysArticleResult">
select id,title,description,create_time from xys_article
<where>
1=1 and article_cat = 7
<if test="title != null and title != ''"> and title = #{title}</if>
<if test="articleCat != null "> and article_cat = #{articleCat}</if>
</where>
order by create_time desc
limit 3
</select>
<select id="selectXysArticleList" parameterType="XysArticle" resultMap="XysArticleResult"> <select id="selectXysArticleList" parameterType="XysArticle" resultMap="XysArticleResult">
<include refid="selectXysArticleVo"/> <include refid="selectXysArticleVo"/>
<where> <where>
<if test="title != null and title != ''"> and title = #{title}</if> <if test="title != null and title != ''"> and title = #{title}</if>
<if test="articleCat != null "> and article_cat = #{articleCat}</if> <if test="articleCat != null "> and article_cat = #{articleCat}</if>
</where> </where>
order by create_time desc
</select> </select>
<select id="selectXysArticleById" parameterType="Long" resultMap="XysArticleResult"> <select id="selectXysArticleById" parameterType="Long" resultMap="XysArticleResult">
@ -41,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="title != null">title,</if> <if test="title != null">title,</if>
<if test="coverImg != null">cover_img,</if> <if test="coverImg != null">cover_img,</if>
<if test="content != null">content,</if> <if test="content != null">content,</if>
<if test="description != null">description,</if>
<if test="articleCat != null">article_cat,</if> <if test="articleCat != null">article_cat,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
@ -53,6 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="title != null">#{title},</if> <if test="title != null">#{title},</if>
<if test="coverImg != null">#{coverImg},</if> <if test="coverImg != null">#{coverImg},</if>
<if test="content != null">#{content},</if> <if test="content != null">#{content},</if>
<if test="description != null">#{description},</if>
<if test="articleCat != null">#{articleCat},</if> <if test="articleCat != null">#{articleCat},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
@ -69,6 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="title != null">title = #{title},</if> <if test="title != null">title = #{title},</if>
<if test="coverImg != null">cover_img = #{coverImg},</if> <if test="coverImg != null">cover_img = #{coverImg},</if>
<if test="content != null">content = #{content},</if> <if test="content != null">content = #{content},</if>
<if test="description != null">description = #{description},</if>
<if test="articleCat != null">article_cat = #{articleCat},</if> <if test="articleCat != null">article_cat = #{articleCat},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>

View File

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.XysCategoryMapper">
<resultMap type="XysCategory" id="XysCategoryResult">
<result property="id" column="id" />
<result property="parentId" column="parent_id" />
<result property="title" column="title" />
<result property="coverImg" column="cover_img" />
<result property="description" column="description" />
<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="remark" column="remark" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectXysCategoryVo">
select id, parent_id, title, cover_img, description, create_time, create_by, update_time, update_by, remark, del_flag from xys_category
</sql>
<select id="selectXysCategoryList" parameterType="XysCategory" resultMap="XysCategoryResult">
<include refid="selectXysCategoryVo"/>
<where>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="title != null and title != ''"> and title = #{title}</if>
<if test="coverImg != null and coverImg != ''"> and cover_img = #{coverImg}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
</where>
</select>
<select id="selectXysCategoryById" parameterType="Long" resultMap="XysCategoryResult">
<include refid="selectXysCategoryVo"/>
where id = #{id}
</select>
<insert id="insertXysCategory" parameterType="XysCategory">
insert into xys_category
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="parentId != null">parent_id,</if>
<if test="title != null">title,</if>
<if test="coverImg != null">cover_img,</if>
<if test="description != null">description,</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="remark != null">remark,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="parentId != null">#{parentId},</if>
<if test="title != null">#{title},</if>
<if test="coverImg != null">#{coverImg},</if>
<if test="description != null">#{description},</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="remark != null">#{remark},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateXysCategory" parameterType="XysCategory">
update xys_category
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="title != null">title = #{title},</if>
<if test="coverImg != null">cover_img = #{coverImg},</if>
<if test="description != null">description = #{description},</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="remark != null">remark = #{remark},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteXysCategoryById" parameterType="Long">
delete from xys_category where id = #{id}
</delete>
<delete id="deleteXysCategoryByIds" parameterType="String">
delete from xys_category where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询文章分类列表
export function listCategory(query) {
return request({
url: '/system/category/list',
method: 'get',
params: query
})
}
// 查询文章分类详细
export function getCategory(id) {
return request({
url: '/system/category/' + id,
method: 'get'
})
}
// 新增文章分类
export function addCategory(data) {
return request({
url: '/system/category',
method: 'post',
data: data
})
}
// 修改文章分类
export function updateCategory(data) {
return request({
url: '/system/category',
method: 'put',
data: data
})
}
// 删除文章分类
export function delCategory(id) {
return request({
url: '/system/category/' + id,
method: 'delete'
})
}

File diff suppressed because it is too large Load Diff

View File

@ -75,6 +75,7 @@
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="文章管理" align="center" prop="id" /> <el-table-column label="文章管理" align="center" prop="id" />
<el-table-column label="文章标题" align="center" prop="title" /> <el-table-column label="文章标题" align="center" prop="title" />
<el-table-column label="简介" align="center" prop="description" />
<el-table-column label="封面图" align="center" prop="coverImg" width="100"> <el-table-column label="封面图" align="center" prop="coverImg" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<image-preview :src="scope.row.coverImg" :width="50" :height="50"/> <image-preview :src="scope.row.coverImg" :width="50" :height="50"/>
@ -115,7 +116,7 @@
/> />
<!-- 添加或修改文章管理对话框 --> <!-- 添加或修改文章管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="文章标题" prop="title"> <el-form-item label="文章标题" prop="title">
<el-input v-model="form.title" placeholder="请输入文章标题" /> <el-input v-model="form.title" placeholder="请输入文章标题" />
@ -123,6 +124,9 @@
<el-form-item label="封面图" prop="coverImg"> <el-form-item label="封面图" prop="coverImg">
<image-upload v-model="form.coverImg"/> <image-upload v-model="form.coverImg"/>
</el-form-item> </el-form-item>
<el-form-item label="简介" prop="description">
<el-input v-model="form.description" placeholder="请输入文章简介" />
</el-form-item>
<el-form-item label="内容"> <el-form-item label="内容">
<editor v-model="form.content" :min-height="192"/> <editor v-model="form.content" :min-height="192"/>
</el-form-item> </el-form-item>
@ -212,6 +216,7 @@ export default {
id: null, id: null,
title: null, title: null,
coverImg: null, coverImg: null,
description: null,
content: null, content: null,
articleCat: null, articleCat: null,
createTime: null, createTime: null,

View File

@ -0,0 +1,288 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="上级分类" prop="parentId">
<el-input
v-model="queryParams.parentId"
placeholder="请输入上级分类"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="分类名称" prop="title">
<el-input
v-model="queryParams.title"
placeholder="请输入分类名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:category:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:category:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:category:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:category:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="文章分类" align="center" prop="id" />
<el-table-column label="上级分类" align="center" prop="parentId" />
<el-table-column label="分类名称" align="center" prop="title" />
<el-table-column label="封面图" align="center" prop="coverImg" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.coverImg" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="简介" align="center" prop="description" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:category:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:category:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改文章分类对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="上级分类" prop="parentId">
<el-input v-model="form.parentId" placeholder="请输入上级分类" />
</el-form-item>
<el-form-item label="分类名称" prop="title">
<el-input v-model="form.title" placeholder="请输入分类名称" />
</el-form-item>
<el-form-item label="封面图" prop="coverImg">
<image-upload v-model="form.coverImg"/>
</el-form-item>
<el-form-item label="简介" prop="description">
<el-input v-model="form.description" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="" prop="delFlag">
<el-input v-model="form.delFlag" placeholder="请输入" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCategory, getCategory, delCategory, addCategory, updateCategory } from "@/api/system/category";
export default {
name: "Category",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
categoryList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
parentId: null,
title: null,
coverImg: null,
description: null,
},
//
form: {},
//
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询文章分类列表 */
getList() {
this.loading = true;
listCategory(this.queryParams).then(response => {
this.categoryList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
parentId: null,
title: null,
coverImg: null,
description: null,
createTime: null,
createBy: null,
updateTime: null,
updateBy: null,
remark: null,
delFlag: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加文章分类";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getCategory(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改文章分类";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateCategory(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addCategory(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除文章分类编号为"' + ids + '"的数据项?').then(function() {
return delCategory(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/category/export', {
...this.queryParams
}, `category_${new Date().getTime()}.xlsx`)
}
}
};
</script>