This commit is contained in:
lee 2024-08-02 14:56:00 +08:00
parent a31a2ff1e7
commit 2fd13b6779
12 changed files with 268 additions and 35 deletions

View File

@ -10,6 +10,8 @@ import com.ruoyi.common.utils.sign.Base64;
import com.ruoyi.system.domain.XysArticle;
import com.ruoyi.system.domain.XysCategory;
import com.ruoyi.system.domain.XysImg;
import com.ruoyi.system.mapper.XysArticleMapper;
import com.ruoyi.system.mapper.XysCategoryMapper;
import com.ruoyi.system.service.IXysArticleService;
import com.ruoyi.system.service.IXysCategoryService;
import com.ruoyi.system.service.IXysImgService;
@ -36,6 +38,10 @@ public class DoorController extends BaseController
private IXysImgService xysImgService;
@Autowired
private IXysCategoryService categoryService;
@Autowired
private XysArticleMapper articleMapper;
@Autowired
private XysCategoryMapper categoryMapper;
/**
@ -90,4 +96,49 @@ public class DoorController extends BaseController
return success(categoryService.selectXysCategoryList(category));
}
/**
* 下一篇
*/
@GetMapping(value = "/getNext")
public AjaxResult getNext(XysArticle xysArticle)
{
return success(articleMapper.getNext(xysArticle));
}
/**
* 上一篇
*/
@GetMapping(value = "/getUp")
public AjaxResult getUp(XysArticle xysArticle)
{
return success(articleMapper.getUp(xysArticle));
}
/**
* 下一篇
*/
@GetMapping(value = "/getNextCat")
public AjaxResult getNextCat(XysCategory xysCategory)
{
return success(categoryMapper.getNextCat(xysCategory));
}
/**
* 上一篇
*/
@GetMapping(value = "/getUpCat")
public AjaxResult getUpCat(XysCategory xysCategory)
{
return success(categoryMapper.getUpCat(xysCategory));
}
/**
*
*/
@GetMapping(value = "/getCategoryById/{id}")
public AjaxResult getCategoryById(@PathVariable("id") Long Id)
{
return success(categoryService.selectXysCategoryById(Id));
}
}

View File

@ -46,6 +46,17 @@ public class XysCategoryController extends BaseController
return getDataTable(list);
}
/**
* 查询文章分类列表
*/
@PreAuthorize("@ss.hasPermi('system:category:list')")
@GetMapping("/catList")
public TableDataInfo catList(XysCategory xysCategory)
{
List<XysCategory> list = xysCategoryService.selectXysCategoryList(xysCategory);
return getDataTable(list);
}
/**
* 导出文章分类列表
*/

View File

@ -26,6 +26,18 @@ public class XysArticle extends BaseEntity
@Excel(name = "封面图")
private String coverImg;
public String getContentImg() {
return contentImg;
}
public void setContentImg(String contentImg) {
this.contentImg = contentImg;
}
/** 封面图 */
@Excel(name = "内容图片")
private String contentImg;
public String getDescription() {
return description;
}
@ -46,9 +58,29 @@ public class XysArticle extends BaseEntity
@Excel(name = "文章所属分类")
private Long articleCat;
public String getCatName() {
return catName;
}
public void setCatName(String catName) {
this.catName = catName;
}
private String catName;
/** $column.columnComment */
private String delFlag;
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
private Integer sort;
public void setId(Long id)
{
this.id = id;

View File

@ -40,6 +40,16 @@ public class XysCategory extends BaseEntity
@Excel(name = "封面图")
private String coverImg;
public String getContentImg() {
return contentImg;
}
public void setContentImg(String contentImg) {
this.contentImg = contentImg;
}
private String contentImg;
/** 简介 */
@Excel(name = "简介")
private String description;
@ -47,6 +57,16 @@ public class XysCategory extends BaseEntity
/** */
private String delFlag;
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
private Integer sort;
public void setId(Long id)
{
this.id = id;

View File

@ -65,4 +65,8 @@ public interface XysArticleMapper
* @return 结果
*/
public int deleteXysArticleByIds(Long[] ids);
XysArticle getNext(XysArticle xysArticle);
XysArticle getUp(XysArticle xysArticle);
}

View File

@ -58,4 +58,8 @@ public interface XysCategoryMapper
* @return 结果
*/
public int deleteXysCategoryByIds(Long[] ids);
XysCategory getNextCat(XysCategory xysCategory);
XysCategory getUpCat(XysCategory xysCategory);
}

View File

@ -8,9 +8,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id"/>
<result property="title" column="title"/>
<result property="coverImg" column="cover_img"/>
<result property="contentImg" column="content_img"/>
<result property="description" column="description"/>
<result property="content" column="content"/>
<result property="articleCat" column="article_cat"/>
<result property="sort" column="sort"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
@ -20,7 +22,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectXysArticleVo">
select id, title, cover_img, description,content, article_cat, create_time, create_by, update_time, update_by, remark, del_flag from xys_article
select id,
title,
cover_img,
content_img,
description,
content,
article_cat,
sort,
create_time,
create_by,
update_time,
update_by,
remark,
del_flag
from xys_article
</sql>
<select id="selectHomeArticleList" parameterType="XysArticle" resultMap="XysArticleResult">
@ -35,12 +51,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectXysArticleList" parameterType="XysArticle" resultMap="XysArticleResult">
<include refid="selectXysArticleVo"/>
select a.*,c.title as catName from xys_article a left join xys_category c on a.article_cat = c.id
<where>
<if test="title != null and title != ''"> and title = #{title}</if>
<if test="articleCat != null "> and article_cat = #{articleCat}</if>
<if test="title != null and title != ''">and a.title = #{title}</if>
<if test="articleCat != null ">and a.article_cat = #{articleCat}</if>
</where>
order by create_time desc
order by sort asc,create_time desc
</select>
<select id="selectXysArticleById" parameterType="Long" resultMap="XysArticleResult">
@ -53,9 +69,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null">title,</if>
<if test="coverImg != null">cover_img,</if>
<if test="contentImg != null">content_img,</if>
<if test="content != null">content,</if>
<if test="description != null">description,</if>
<if test="articleCat != null">article_cat,</if>
<if test="sort != null">sort,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
@ -66,9 +84,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null">#{title},</if>
<if test="coverImg != null">#{coverImg},</if>
<if test="contentImg != null">#{contentImg},</if>
<if test="content != null">#{content},</if>
<if test="description != null">#{description},</if>
<if test="articleCat != null">#{articleCat},</if>
<if test="sort != null">#{sort},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
@ -83,9 +103,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="title != null">title = #{title},</if>
<if test="coverImg != null">cover_img = #{coverImg},</if>
<if test="contentImg != null">content_img = #{contentImg},</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="sort != null">sort = #{sort},</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>
@ -97,7 +119,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteXysArticleById" parameterType="Long">
delete from xys_article where id = #{id}
delete
from xys_article
where id = #{id}
</delete>
<delete id="deleteXysArticleByIds" parameterType="String">
@ -106,4 +130,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="getNext" resultMap="XysArticleResult">
select id,title from xys_article
<where>
<if test="id != null">and id &gt; #{id}</if>
<if test="articleCat != null ">and article_cat = #{articleCat}</if>
</where>
limit 1
</select>
<select id="getUp" resultMap="XysArticleResult">
select id,title from xys_article
<where>
<if test="id != null">and id &lt; #{id}</if>
<if test="articleCat != null ">and article_cat = #{articleCat}</if>
</where>
ORDER BY create_time desc
limit 1
</select>
</mapper>

View File

@ -9,7 +9,9 @@
<result property="parentId" column="parent_id" />
<result property="title" column="title" />
<result property="coverImg" column="cover_img" />
<result property="contentImg" column="content_img" />
<result property="description" column="description" />
<result property="sort" column="sort" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
@ -19,7 +21,8 @@
</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
select id, parent_id, title, cover_img,content_img, description,
sort, create_time, create_by, update_time, update_by, remark, del_flag from xys_category
</sql>
<select id="selectXysCategoryList" parameterType="XysCategory" resultMap="XysCategoryResult">
@ -30,6 +33,7 @@
<if test="coverImg != null and coverImg != ''"> and cover_img = #{coverImg}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
</where>
order by sort asc,create_time desc
</select>
<select id="selectXysCategoryById" parameterType="Long" resultMap="XysCategoryResult">
@ -44,7 +48,9 @@
<if test="parentId != null">parent_id,</if>
<if test="title != null">title,</if>
<if test="coverImg != null">cover_img,</if>
<if test="contentImg != null">content_img,</if>
<if test="description != null">description,</if>
<if test="sort != null">sort,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
@ -57,7 +63,9 @@
<if test="parentId != null">#{parentId},</if>
<if test="title != null">#{title},</if>
<if test="coverImg != null">#{coverImg},</if>
<if test="contentImg != null">#{contentImg},</if>
<if test="description != null">#{description},</if>
<if test="sort != null">#{sort},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
@ -73,7 +81,9 @@
<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="contentImg != null">content_img = #{contentImg},</if>
<if test="description != null">description = #{description},</if>
<if test="sort != null">sort = #{sort},</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>
@ -94,4 +104,25 @@
#{id}
</foreach>
</delete>
<select id="getNextCat" resultMap="XysCategoryResult">
select id,title from xys_category
<where>
<if test="id != null">and id &gt; #{id}</if>
<if test="parentId != null ">and parent_id = #{parentId}</if>
</where>
limit 1
</select>
<select id="getUpCat" resultMap="XysCategoryResult">
select id,title from xys_category
<where>
<if test="id != null">and id &lt; #{id}</if>
<if test="parentId != null ">and parent_id = #{parentId}</if>
</where>
ORDER BY create_time desc
limit 1
</select>
</mapper>

View File

@ -9,6 +9,15 @@ export function listCategory(query) {
})
}
// 查询文章分类列表
export function catList(query) {
return request({
url: '/system/category/catList',
method: 'get',
params: query
})
}
// 查询文章分类详细
export function getCategory(id) {
return request({

View File

@ -182,7 +182,7 @@ export default {
//
let length = quill.getSelection().index;
// res.url
quill.insertEmbed(length, "image", process.env.VUE_APP_BASE_API + res.fileName);
quill.insertEmbed(length, "image", res.url);
//
quill.setSelection(length + 1);
} else {

View File

@ -45,12 +45,17 @@
<image-preview :src="scope.row.coverImg" :width="50" :height="50" />
</template>
</el-table-column>
<el-table-column label="内容" align="center" prop="content" />
<el-table-column label="文章所属分类" align="center" prop="articleCat">
<el-table-column label="内容" align="center" prop="content" show-overflow-tooltip>
<template slot-scope="scope">
<dict-tag :options="dict.type.article_cat" :value="scope.row.articleCat" />
<div>{{ scope.row.content }}</div>
</template>
</el-table-column>
<el-table-column label="文章所属分类" align="center" prop="catName">
<!-- <template slot-scope="scope">-->
<!-- <dict-tag :options="dict.type.article_cat" :value="scope.row.articleCat" />-->
<!-- </template>-->
</el-table-column>
<el-table-column label="sort" align="center" prop="sort" />
<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)"
@ -73,6 +78,9 @@
<el-form-item label="封面图" prop="coverImg">
<image-upload v-model="form.coverImg" />
</el-form-item>
<el-form-item label="内容图片" prop="contentImg">
<image-upload v-model="form.contentImg" />
</el-form-item>
<el-form-item label="简介" prop="description">
<el-input v-model="form.description" placeholder="请输入文章简介" />
</el-form-item>
@ -84,6 +92,9 @@
<el-option v-for="item in categoryList" :key="item.id" :label="item.title" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input-number v-model="form.sort" controls-position="right" :min="0" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
@ -98,7 +109,7 @@
<script>
import { listArticle, getArticle, delArticle, addArticle, updateArticle } from "@/api/system/article";
import { listCategory } from "@/api/system/category";
import { catList } from "@/api/system/category";
export default {
name: "Article",
dicts: ['article_cat'],
@ -144,7 +155,7 @@ export default {
methods: {
//
getfenlei() {
listCategory().then(response => {
catList().then(response => {
this.categoryList = response.rows;
});
},
@ -170,9 +181,11 @@ export default {
id: null,
title: null,
coverImg: null,
contentImg: null,
description: null,
content: null,
articleCat: null,
sort:null,
createTime: null,
createBy: null,
updateTime: null,

View File

@ -45,7 +45,12 @@
<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="description" show-overflow-tooltip>
<template slot-scope="scope">
<div>{{ scope.row.description }}</div>
</template>
</el-table-column>
<el-table-column label="排序" align="center" prop="sort" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
@ -74,9 +79,15 @@
<el-form-item label="封面图" prop="coverImg">
<image-upload v-model="form.coverImg" />
</el-form-item>
<el-form-item label="内容图" prop="contentImg">
<image-upload v-model="form.contentImg" />
</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="sort">
<el-input-number v-model="form.sort" controls-position="right" :min="0" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
@ -91,7 +102,7 @@
</template>
<script>
import { listCategory, getCategory, delCategory, addCategory, updateCategory } from "@/api/system/category";
import { listCategory, getCategory, delCategory, addCategory, updateCategory,catList } from "@/api/system/category";
export default {
name: "Category",
@ -142,7 +153,7 @@ export default {
methods: {
//
gettop(){
listCategory().then(response => {
catList().then(response => {
this.options=response.rows
});
},
@ -168,7 +179,9 @@ export default {
parentId: null,
title: null,
coverImg: null,
contentImg: null,
description: null,
sort:null,
createTime: null,
createBy: null,
updateTime: null,
@ -248,4 +261,5 @@ export default {
}
}
};
</script>