Compare commits
2 Commits
493c346d9b
...
e390702eed
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e390702eed | ||
![]() |
ab33dc9e84 |
|
@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="query.adId != null and query.adId != ''"> and bad.ad_id = #{query.adId}</if>
|
<if test="query.adId != null and query.adId != ''"> and bad.ad_id = #{query.adId}</if>
|
||||||
<if test="query.type != null and query.type != ''"> and bad.type = #{query.type}</if>
|
<if test="query.type != null and query.type != ''"> and bad.type = #{query.type}</if>
|
||||||
<if test="query.picture != null and query.picture != ''"> and bad.picture = #{query.picture}</if>
|
<if test="query.picture != null and query.picture != ''"> and bad.picture = #{query.picture}</if>
|
||||||
<if test="query.url != null and query.url != ''"> and bad.url = #{query.url}</if>
|
<if test="query.url != null and query.url != ''"> and bad.url like concat('%',#{query.url},'%') </if>
|
||||||
<if test="query.deleted != null "> and bad.deleted = #{query.deleted}</if>
|
<if test="query.deleted != null "> and bad.deleted = #{query.deleted}</if>
|
||||||
<if test="query.urlType != null and query.urlType != ''"> and bad.url_type = #{query.urlType}</if>
|
<if test="query.urlType != null and query.urlType != ''"> and bad.url_type = #{query.urlType}</if>
|
||||||
${query.params.dataScope}
|
${query.params.dataScope}
|
||||||
|
|
|
@ -32,8 +32,16 @@ public class Article extends BaseEntity
|
||||||
@ApiModelProperty("标题")
|
@ApiModelProperty("标题")
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
@Excel(name = "简介")
|
||||||
|
@ApiModelProperty("简介")
|
||||||
|
private String brief;
|
||||||
|
|
||||||
@Excel(name = "内容详情")
|
@Excel(name = "内容详情")
|
||||||
@ApiModelProperty("内容详情")
|
@ApiModelProperty("内容详情")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
@Excel(name = "文章类型")
|
||||||
|
@ApiModelProperty(value = "文章类型")
|
||||||
|
private String code;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
package com.ruoyi.bst.article.domain;
|
package com.ruoyi.bst.article.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class ArticleQuery extends Article{
|
public class ArticleQuery extends Article{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
package com.ruoyi.bst.article.domain;
|
package com.ruoyi.bst.article.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ArticleVO extends Article {
|
public class ArticleVO extends Article {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "分类名称")
|
||||||
|
private String articleCategoryName;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public interface ArticleMapper
|
||||||
*/
|
*/
|
||||||
public int deleteArticleByIds(Long[] ids);
|
public int deleteArticleByIds(Long[] ids);
|
||||||
|
|
||||||
public ArticleVO selectChildrenById(Long id);
|
public List<ArticleVO> selectChildrenById(Long id);
|
||||||
|
|
||||||
ArticleVO selectArticleByCode(ArticleCategoryQuery articleCategoryQuery);
|
ArticleVO selectArticleByCode(ArticleCategoryQuery articleCategoryQuery);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<resultMap type="ArticleVO" id="ArticleResult" autoMapping="true">
|
<resultMap type="ArticleVO" id="ArticleResult" autoMapping="true">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="categoryId" column="category_id" />
|
<result property="categoryId" column="category_id" />
|
||||||
<result property="areaId" column="area_id" />
|
|
||||||
<result property="title" column="title" />
|
<result property="title" column="title" />
|
||||||
<result property="content" column="content" />
|
<result property="content" column="content" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
|
@ -16,22 +15,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<sql id="selectArticleVo">
|
<sql id="selectArticleVo">
|
||||||
select
|
select
|
||||||
id,
|
bart.id,
|
||||||
category_id,
|
bart.category_id,
|
||||||
area_id,
|
bart.title,
|
||||||
title,
|
bart.content,
|
||||||
content,
|
bart.create_time,
|
||||||
create_time,
|
bart.brief,
|
||||||
update_time
|
bart.code,
|
||||||
from bst_article
|
bart.update_time,
|
||||||
|
bac.category_name as article_category_name
|
||||||
|
from bst_article bart
|
||||||
|
left join bst_article_category bac on bart.category_id = bac.id
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="searchCondition">
|
<sql id="searchCondition">
|
||||||
<if test="query.id != null "> and id = #{query.id}</if>
|
<if test="query.id != null "> and bart.id = #{query.id}</if>
|
||||||
<if test="query.categoryId != null "> and category_id = #{query.categoryId}</if>
|
<if test="query.categoryId != null "> and bart.category_id = #{query.categoryId}</if>
|
||||||
<if test="query.areaId != null "> and area_id = #{query.areaId}</if>
|
<if test="query.brief != null "> and bart.brief = #{query.brief}</if>
|
||||||
<if test="query.title != null and query.title != ''"> and title = #{query.title}</if>
|
<if test="query.title != null and query.title != ''"> and bart.title like concat ('',#{query.title},'') </if>
|
||||||
<if test="query.content != null and query.content != ''"> and content = #{query.content}</if>
|
<if test="query.content != null and query.content != ''"> and bart.content = #{query.content}</if>
|
||||||
${query.params.dataScope}
|
${query.params.dataScope}
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
@ -44,12 +46,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<select id="selectArticleById" parameterType="Long" resultMap="ArticleResult">
|
<select id="selectArticleById" parameterType="Long" resultMap="ArticleResult">
|
||||||
<include refid="selectArticleVo"/>
|
<include refid="selectArticleVo"/>
|
||||||
where id = #{id}
|
where bart.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectChildrenById" resultType="com.ruoyi.bst.article.domain.ArticleVO">
|
<select id="selectChildrenById" resultType="com.ruoyi.bst.article.domain.ArticleVO">
|
||||||
<include refid="selectArticleVo"/>
|
<include refid="selectArticleVo"/>
|
||||||
where id = #{categoryId}
|
where category_id = #{categoryId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectArticleByCode" resultType="com.ruoyi.bst.article.domain.ArticleVO">
|
<select id="selectArticleByCode" resultType="com.ruoyi.bst.article.domain.ArticleVO">
|
||||||
|
@ -61,17 +63,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
insert into bst_article
|
insert into bst_article
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="categoryId != null">category_id,</if>
|
<if test="categoryId != null">category_id,</if>
|
||||||
<if test="areaId != null">area_id,</if>
|
|
||||||
<if test="title != null and title != ''">title,</if>
|
<if test="title != null and title != ''">title,</if>
|
||||||
<if test="content != null">content,</if>
|
<if test="content != null">content,</if>
|
||||||
|
<if test="brief != null">brief,</if>
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
<if test="updateTime != null">update_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="categoryId != null">#{categoryId},</if>
|
<if test="categoryId != null">#{categoryId},</if>
|
||||||
<if test="areaId != null">#{areaId},</if>
|
|
||||||
<if test="title != null and title != ''">#{title},</if>
|
<if test="title != null and title != ''">#{title},</if>
|
||||||
<if test="content != null">#{content},</if>
|
<if test="content != null">#{content},</if>
|
||||||
|
<if test="brief != null">#{brief},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
</trim>
|
</trim>
|
||||||
|
@ -81,8 +83,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
insert into bst_article
|
insert into bst_article
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
category_id,
|
category_id,
|
||||||
area_id,
|
|
||||||
title,
|
title,
|
||||||
|
brief,
|
||||||
content,
|
content,
|
||||||
create_time,
|
create_time,
|
||||||
update_time,
|
update_time,
|
||||||
|
@ -119,16 +121,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</otherwise>
|
</otherwise>
|
||||||
</choose>
|
</choose>
|
||||||
</foreach>
|
</foreach>
|
||||||
<foreach open="area_id = CASE id" collection="list" item="item" close="END,">
|
|
||||||
<choose>
|
|
||||||
<when test="item.areaId != null ">
|
|
||||||
WHEN #{item.id} THEN #{item.areaId}
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
WHEN #{item.id} THEN `area_id`
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
</foreach>
|
|
||||||
<foreach open="title = CASE id" collection="list" item="item" close="END,">
|
<foreach open="title = CASE id" collection="list" item="item" close="END,">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="item.title != null and item.title != ''">
|
<when test="item.title != null and item.title != ''">
|
||||||
|
@ -177,16 +169,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateArticle" parameterType="Article">
|
<update id="updateArticle" parameterType="Article">
|
||||||
update bst_article
|
update bst_article bart
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<include refid="updateColumns"/>
|
<include refid="updateColumns"/>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{data.id}
|
where bart.id = #{data.id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<sql id="updateColumns">
|
<sql id="updateColumns">
|
||||||
<if test="data.categoryId != null">category_id = #{data.categoryId},</if>
|
<if test="data.categoryId != null">category_id = #{data.categoryId},</if>
|
||||||
<if test="data.areaId != null">area_id = #{data.areaId},</if>
|
|
||||||
<if test="data.title != null and data.title != ''">title = #{data.title},</if>
|
<if test="data.title != null and data.title != ''">title = #{data.title},</if>
|
||||||
<if test="data.content != null">content = #{data.content},</if>
|
<if test="data.content != null">content = #{data.content},</if>
|
||||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||||
|
|
|
@ -62,9 +62,8 @@ public interface ArticleService
|
||||||
*/
|
*/
|
||||||
public int deleteArticleById(Long id);
|
public int deleteArticleById(Long id);
|
||||||
|
|
||||||
ArticleVO selectChildrenByCategoryId(Long id);
|
|
||||||
|
|
||||||
ArticleVO selectArticleByCode(ArticleCategoryQuery articleCategoryQuery);
|
ArticleVO selectArticleByCode(ArticleCategoryQuery articleCategoryQuery);
|
||||||
|
|
||||||
ArticleVO selectArticleByCategoryId(Long id);
|
List<ArticleVO> selectArticleByCategoryId(Long categoryId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,7 @@ public class ArticleServiceImpl implements ArticleService
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ArticleCategoryService articleCategoryService;
|
private ArticleCategoryService articleCategoryService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AreaService areaService;
|
|
||||||
/**
|
/**
|
||||||
* 查询文章
|
* 查询文章
|
||||||
*
|
*
|
||||||
|
@ -71,11 +69,6 @@ public class ArticleServiceImpl implements ArticleService
|
||||||
if(articleCategoryService.selectArticleCategoryById(article.getCategoryId()) ==null){
|
if(articleCategoryService.selectArticleCategoryById(article.getCategoryId()) ==null){
|
||||||
throw new ServiceException("当前分类不存在");
|
throw new ServiceException("当前分类不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
//所属区域必须存在
|
|
||||||
if (areaService.selectAreaById(article.getAreaId()) == null){
|
|
||||||
throw new ServiceException("所属区域不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
article.setCreateTime(DateUtils.getNowDate());
|
article.setCreateTime(DateUtils.getNowDate());
|
||||||
return articleMapper.insertArticle(article);
|
return articleMapper.insertArticle(article);
|
||||||
|
@ -95,11 +88,6 @@ public class ArticleServiceImpl implements ArticleService
|
||||||
throw new ServiceException("当前分类不存在");
|
throw new ServiceException("当前分类不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
//所属区域必须存在
|
|
||||||
if (areaService.selectAreaById(article.getAreaId()) == null){
|
|
||||||
throw new ServiceException("所属区域不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
article.setUpdateTime(DateUtils.getNowDate());
|
article.setUpdateTime(DateUtils.getNowDate());
|
||||||
return articleMapper.updateArticle(article);
|
return articleMapper.updateArticle(article);
|
||||||
}
|
}
|
||||||
|
@ -128,10 +116,6 @@ public class ArticleServiceImpl implements ArticleService
|
||||||
return articleMapper.deleteArticleById(id);
|
return articleMapper.deleteArticleById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArticleVO selectChildrenByCategoryId(Long id) {
|
|
||||||
return articleMapper.selectChildrenById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArticleVO selectArticleByCode(ArticleCategoryQuery articleCategoryQuery) {
|
public ArticleVO selectArticleByCode(ArticleCategoryQuery articleCategoryQuery) {
|
||||||
|
@ -139,7 +123,7 @@ public class ArticleServiceImpl implements ArticleService
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArticleVO selectArticleByCategoryId(Long id) {
|
public List<ArticleVO> selectArticleByCategoryId(Long categoryId) {
|
||||||
return articleMapper.selectChildrenById(id);
|
return articleMapper.selectChildrenById(categoryId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public interface ArticleCategoryMapper
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Long> selectChildren(Long id);
|
List<ArticleCategoryVO> selectChildrenCategory(Long id);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,5 +89,10 @@ public interface ArticleCategoryMapper
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void deleteArticleCategoryByIds(List<Long> childrenIds);
|
public void deleteArticleCategoryByIds(List<Long> childrenIds);
|
||||||
|
|
||||||
|
|
||||||
|
public int updateArticleCategorySortAndStatusOnly(ArticleCategory articleCategory);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="searchCondition">
|
<sql id="searchCondition">
|
||||||
<if test="query.id != null "> and id = #{query.id}</if>
|
<if test="query.id != null "> and bac.id = #{query.id}</if>
|
||||||
<if test="query.categoryName != null and query.categoryName != ''"> and category_name like concat('%', #{query.categoryName}, '%')</if>
|
<if test="query.categoryName != null and query.categoryName != ''"> and bac.category_name like concat('%', #{query.categoryName}, '%')</if>
|
||||||
<if test="query.parentId != null "> and parent_id = #{query.parentId}</if>
|
<if test="query.parentId != null "> and bac.parent_id = #{query.parentId}</if>
|
||||||
<if test="query.categoryStatus != null "> and category_status = #{query.categoryStatus}</if>
|
<if test="query.categoryStatus != null "> and bac.category_status = #{query.categoryStatus}</if>
|
||||||
<if test="query.sort != null "> and sort = #{query.sort}</if>
|
<if test="query.sort != null "> and bac.sort = #{query.sort}</if>
|
||||||
${query.params.dataScope}
|
${query.params.dataScope}
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
@ -53,13 +53,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectChildren" resultType="java.lang.Long">
|
<select id="selectChildrenCategory" resultType="ArticleCategoryVO">
|
||||||
select bac.id from bst_article_category bac
|
<include refid="selectArticleCategoryVo"/>
|
||||||
<where>
|
<where>
|
||||||
bac.parent_id IN
|
bac.parent_id = #{id}
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@ -174,15 +171,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<include refid="updateColumns"/>
|
<include refid="updateColumns"/>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{data.id}
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!--updateArticleCategorySortOnly-->
|
||||||
|
<update id="updateArticleCategorySortAndStatusOnly" parameterType="ArticleCategory">
|
||||||
|
update bst_article_category set
|
||||||
|
<if test="categoryStatus != null">category_status = #{categoryStatus},</if>
|
||||||
|
<if test="sort != null">sort = #{sort}</if>
|
||||||
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<sql id="updateColumns">
|
<sql id="updateColumns">
|
||||||
<if test="data.categoryName != null and data.categoryName != ''">category_name = #{data.categoryName},</if>
|
<if test="categoryName != null and categoryName != ''">category_name = #{data.categoryName},</if>
|
||||||
<if test="data.parentId != null">parent_id = #{data.parentId},</if>
|
<if test="parentId != null">parent_id = #{data.parentId},</if>
|
||||||
<if test="data.categoryStatus != null">category_status = #{data.categoryStatus},</if>
|
<if test="categoryStatus != null">category_status = #{data.categoryStatus},</if>
|
||||||
<if test="data.sort != null">sort = #{data.sort},</if>
|
<if test="sort != null">sort = #{data.sort},</if>
|
||||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
<if test="createTime != null">create_time = #{data.createTime},</if>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<delete id="deleteArticleCategoryById" parameterType="Long">
|
<delete id="deleteArticleCategoryById" parameterType="Long">
|
||||||
|
|
|
@ -47,13 +47,6 @@ public interface ArticleCategoryService
|
||||||
*/
|
*/
|
||||||
public int updateArticleCategory(ArticleCategory articleCategory);
|
public int updateArticleCategory(ArticleCategory articleCategory);
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除文章分类
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的文章分类主键集合
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteArticleCategoryByIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除文章分类信息
|
* 删除文章分类信息
|
||||||
|
|
|
@ -6,7 +6,9 @@ import com.github.pagehelper.PageHelper;
|
||||||
import com.ruoyi.bst.area.domain.AreaQuery;
|
import com.ruoyi.bst.area.domain.AreaQuery;
|
||||||
import com.ruoyi.bst.area.domain.AreaVO;
|
import com.ruoyi.bst.area.domain.AreaVO;
|
||||||
import com.ruoyi.bst.article.domain.ArticleVO;
|
import com.ruoyi.bst.article.domain.ArticleVO;
|
||||||
|
import com.ruoyi.bst.article.mapper.ArticleMapper;
|
||||||
import com.ruoyi.bst.article.service.ArticleService;
|
import com.ruoyi.bst.article.service.ArticleService;
|
||||||
|
import com.ruoyi.bst.articleCategory.domain.enums.ArticleCategoryStatus;
|
||||||
import com.ruoyi.bst.device.utils.DeviceUtil;
|
import com.ruoyi.bst.device.utils.DeviceUtil;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
@ -36,6 +38,8 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ArticleService articleService;
|
private ArticleService articleService;
|
||||||
|
@Autowired
|
||||||
|
private ArticleMapper articleMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询文章分类
|
* 查询文章分类
|
||||||
|
@ -85,10 +89,15 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService
|
||||||
if (flag){
|
if (flag){
|
||||||
ServiceUtil.assertion(true,"不允许插入重复分类");
|
ServiceUtil.assertion(true,"不允许插入重复分类");
|
||||||
}
|
}
|
||||||
//只允许两次分类
|
|
||||||
if(articleCategory.getParentId()!= null) {
|
if(articleCategory.getParentId()!= null) {
|
||||||
Boolean hasParent = hasParent(articleCategory.getParentId());
|
ArticleCategoryVO vo = articleCategoryMapper.selectArticleCategoryById(articleCategory.getParentId());
|
||||||
ServiceUtil.assertion(hasParent,"该分类下不允许再次分类");
|
ServiceUtil.assertion(vo==null,"当前分类不存在");
|
||||||
|
// 只允许两次分类
|
||||||
|
if (vo.getParentId()!=0) {
|
||||||
|
Boolean hasParent = hasParent(articleCategory.getParentId());
|
||||||
|
ServiceUtil.assertion(hasParent,"该分类下不允许再次分类");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
articleCategory.setCreateTime(DateUtils.getNowDate());
|
articleCategory.setCreateTime(DateUtils.getNowDate());
|
||||||
return articleCategoryMapper.insertArticleCategory(articleCategory);
|
return articleCategoryMapper.insertArticleCategory(articleCategory);
|
||||||
|
@ -103,6 +112,25 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService
|
||||||
@Override
|
@Override
|
||||||
public int updateArticleCategory(ArticleCategory articleCategory)
|
public int updateArticleCategory(ArticleCategory articleCategory)
|
||||||
{
|
{
|
||||||
|
ArticleCategoryVO vo = articleCategoryMapper.selectArticleCategoryById(articleCategory.getId());
|
||||||
|
//检查是否仅修改排序或状态字段
|
||||||
|
if (vo != null && vo.getParentId().equals(articleCategory.getParentId())&&vo.getCategoryName().equals(articleCategory.getCategoryName())) {
|
||||||
|
if (vo.getCategoryStatus()!=null) {
|
||||||
|
if (vo.getParentId() != null) {
|
||||||
|
ArticleCategoryVO parentVO = articleCategoryMapper.selectArticleCategoryById(vo.getParentId());
|
||||||
|
ServiceUtil.assertion(parentVO.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode()),"该分类所属分类已禁用,无法启用该分类");
|
||||||
|
|
||||||
|
}
|
||||||
|
// 判断当前分类下是否有启用的分类
|
||||||
|
List<ArticleCategoryVO> childrenCategoryList = articleCategoryMapper.selectChildrenCategory(articleCategory.getId());
|
||||||
|
childrenCategoryList.forEach(child -> {
|
||||||
|
if (Objects.equals(child.getCategoryStatus(), ArticleCategoryStatus.ENABLED.getCode())) {
|
||||||
|
ServiceUtil.assertion(!childrenCategoryList.isEmpty(),"当前分类下有启用的分类,不可禁用");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return articleCategoryMapper.updateArticleCategorySortAndStatusOnly(articleCategory);
|
||||||
|
}
|
||||||
//目标分类不允许子分类重名
|
//目标分类不允许子分类重名
|
||||||
Boolean flag = articleCategoryMapper.checkByNameAndParetId(articleCategory);
|
Boolean flag = articleCategoryMapper.checkByNameAndParetId(articleCategory);
|
||||||
if (flag){
|
if (flag){
|
||||||
|
@ -116,31 +144,18 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService
|
||||||
return articleCategoryMapper.updateArticleCategory(articleCategory);
|
return articleCategoryMapper.updateArticleCategory(articleCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int deleteArticleCategoryByIds(Long[] ids) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean hasParent(Long id){
|
private Boolean hasParent(Long id){
|
||||||
|
if (id == 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Long parentId = selectArticleCategoryById(id).getParentId();
|
Long parentId = selectArticleCategoryById(id).getParentId();
|
||||||
if (parentId != null){
|
if (parentId != null){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 批量删除文章分类
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的文章分类主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
// @Override
|
|
||||||
// @Transactional
|
|
||||||
// public int deleteArticleCategoryByIds(List<Long> ids)
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// return articleCategoryMapper.deleteArticleCategoryByIds(ids);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除文章分类信息
|
* 删除文章分类信息
|
||||||
|
@ -151,14 +166,12 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService
|
||||||
@Override
|
@Override
|
||||||
public int deleteArticleCategoryById(Long categoryId)
|
public int deleteArticleCategoryById(Long categoryId)
|
||||||
{
|
{
|
||||||
List<Long> childrenIds = articleCategoryMapper.selectChildren(categoryId);
|
// 如果当前分类有子分类,先删除子分类
|
||||||
if (childrenIds != null){
|
List<ArticleCategoryVO> childrenCategoryList = articleCategoryMapper.selectChildrenCategory(categoryId);
|
||||||
articleCategoryMapper.deleteArticleCategoryByIds(childrenIds);
|
ServiceUtil.assertion(!childrenCategoryList.isEmpty(),"请先删除当前分类下的子分类");
|
||||||
}
|
// 如果当前分类下有文章,先删除文章
|
||||||
ArticleVO articleVO = articleService.selectArticleByCategoryId(categoryId);
|
List<ArticleVO> articleList = articleService.selectArticleByCategoryId(categoryId);
|
||||||
if (articleVO != null){
|
ServiceUtil.assertion(!articleList.isEmpty(),"当前分类下存在文章,请先删除分类下的文章");
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return articleCategoryMapper.deleteArticleCategoryById(categoryId);
|
return articleCategoryMapper.deleteArticleCategoryById(categoryId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,23 +16,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<sql id="selectComplaintVo">
|
<sql id="selectComplaintVo">
|
||||||
select
|
select
|
||||||
id,
|
bc.id,
|
||||||
user_id,
|
bc.user_id,
|
||||||
create_time,
|
bc.create_time,
|
||||||
content,
|
bc.content,
|
||||||
type,
|
bc.type,
|
||||||
picture,
|
bc.picture,
|
||||||
contact
|
bc.contact,
|
||||||
from bst_complaint
|
su.user_name
|
||||||
|
from bst_complaint bc
|
||||||
|
left join sys_user su
|
||||||
|
on bc.user_id = su.user_id
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="searchCondition">
|
<sql id="searchCondition">
|
||||||
<if test="query.id != null "> and id = #{query.id}</if>
|
<if test="query.id != null "> and bc.id = #{query.id}</if>
|
||||||
<if test="query.userId != null "> and user_id = #{query.userId}</if>
|
<if test="query.userId != null "> and bc.user_id = #{query.userId}</if>
|
||||||
<if test="query.content != null and query.content != ''"> and content = #{query.content}</if>
|
<if test="query.content != null and query.content != ''"> and bc.content = #{query.content}</if>
|
||||||
<if test="query.type != null and query.type != ''"> and type = #{query.type}</if>
|
<if test="query.type != null and query.type != ''"> and bc.type = #{query.type}</if>
|
||||||
<if test="query.picture != null and query.picture != ''"> and picture = #{query.picture}</if>
|
<if test="query.picture != null and query.picture != ''"> and bc.picture = #{query.picture}</if>
|
||||||
<if test="query.contact != null and query.contact != ''"> and contact = #{query.contact}</if>
|
<if test="query.contact != null and query.contact != ''"> and bc.contact like concat('%',#{query.contact},'%') </if>
|
||||||
${query.params.dataScope}
|
${query.params.dataScope}
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class ArticleCategoryController extends BaseController
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(ArticleCategoryQuery articleCategoryQuery)
|
public AjaxResult list(ArticleCategoryQuery articleCategoryQuery)
|
||||||
{
|
{
|
||||||
|
articleCategoryQuery.setScope(true);
|
||||||
List<ArticleCategoryVO> list = articleCategoryService.selectArticleCategoryList(articleCategoryQuery);
|
List<ArticleCategoryVO> list = articleCategoryService.selectArticleCategoryList(articleCategoryQuery);
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class ArticleController extends BaseController
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
startOrderBy();
|
startOrderBy();
|
||||||
|
query.setScope(true);
|
||||||
List<ArticleVO> list = articleService.selectArticleList(query);
|
List<ArticleVO> list = articleService.selectArticleList(query);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user