From ab33dc9e8459dcb4ddd7599b004bc13b6b64402b Mon Sep 17 00:00:00 2001 From: SjS Date: Fri, 4 Apr 2025 18:22:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=9C=8D=E7=9B=B8=E5=85=B3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/bst/ad/mapper/AdMapper.xml | 2 +- .../com/ruoyi/bst/article/domain/Article.java | 8 +++ .../bst/article/domain/ArticleQuery.java | 5 ++ .../ruoyi/bst/article/domain/ArticleVO.java | 6 ++ .../bst/article/mapper/ArticleMapper.java | 2 +- .../bst/article/mapper/ArticleMapper.xml | 55 +++++++-------- .../bst/article/service/ArticleService.java | 3 +- .../service/impl/ArticleServiceImpl.java | 22 +----- .../mapper/ArticleCategoryMapper.java | 9 ++- .../mapper/ArticleCategoryMapper.xml | 39 ++++++----- .../service/ArticleCategoryService.java | 7 -- .../impl/ArticleCategoryServiceImpl.java | 69 +++++++++++-------- .../bst/complaint/mapper/ComplaintMapper.xml | 31 +++++---- .../web/bst/ArticleCategoryController.java | 1 + .../com/ruoyi/web/bst/ArticleController.java | 1 + 15 files changed, 137 insertions(+), 123 deletions(-) diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/ad/mapper/AdMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/ad/mapper/AdMapper.xml index 2b7e83f..b81b150 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/ad/mapper/AdMapper.xml +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/ad/mapper/AdMapper.xml @@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bad.ad_id = #{query.adId} and bad.type = #{query.type} and bad.picture = #{query.picture} - and bad.url = #{query.url} + and bad.url like concat('%',#{query.url},'%') and bad.deleted = #{query.deleted} and bad.url_type = #{query.urlType} ${query.params.dataScope} diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/Article.java b/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/Article.java index 9d0fd71..e4dbc08 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/Article.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/Article.java @@ -32,8 +32,16 @@ public class Article extends BaseEntity @ApiModelProperty("标题") private String title; + @Excel(name = "简介") + @ApiModelProperty("简介") + private String brief; + @Excel(name = "内容详情") @ApiModelProperty("内容详情") private String content; + @Excel(name = "文章类型") + @ApiModelProperty(value = "文章类型") + private String code; + } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/ArticleQuery.java b/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/ArticleQuery.java index e52ab89..4aa90a6 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/ArticleQuery.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/ArticleQuery.java @@ -1,4 +1,9 @@ package com.ruoyi.bst.article.domain; +import lombok.Data; + +@Data public class ArticleQuery extends Article{ + + } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/ArticleVO.java b/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/ArticleVO.java index 89341cd..ac3771b 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/ArticleVO.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/article/domain/ArticleVO.java @@ -1,7 +1,13 @@ package com.ruoyi.bst.article.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class ArticleVO extends Article { + + @ApiModelProperty(value = "分类名称") + private String articleCategoryName; + + } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/article/mapper/ArticleMapper.java b/ruoyi-service/src/main/java/com/ruoyi/bst/article/mapper/ArticleMapper.java index 05ce669..e324fb0 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/article/mapper/ArticleMapper.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/article/mapper/ArticleMapper.java @@ -73,7 +73,7 @@ public interface ArticleMapper */ public int deleteArticleByIds(Long[] ids); - public ArticleVO selectChildrenById(Long id); + public List selectChildrenById(Long id); ArticleVO selectArticleByCode(ArticleCategoryQuery articleCategoryQuery); } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/article/mapper/ArticleMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/article/mapper/ArticleMapper.xml index eecb602..f97c0ba 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/article/mapper/ArticleMapper.xml +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/article/mapper/ArticleMapper.xml @@ -7,7 +7,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - @@ -16,22 +15,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select - id, - category_id, - area_id, - title, - content, - create_time, - update_time - from bst_article + bart.id, + bart.category_id, + bart.title, + bart.content, + bart.create_time, + bart.brief, + bart.code, + 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 - and id = #{query.id} - and category_id = #{query.categoryId} - and area_id = #{query.areaId} - and title = #{query.title} - and content = #{query.content} + and bart.id = #{query.id} + and bart.category_id = #{query.categoryId} + and bart.brief = #{query.brief} + and bart.title like concat ('',#{query.title},'') + and bart.content = #{query.content} ${query.params.dataScope} @@ -44,12 +46,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - bac.parent_id IN - - #{id} - + bac.parent_id = #{id} @@ -174,15 +171,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - where id = #{data.id} + where id = #{id} + + + + + update bst_article_category set + category_status = #{categoryStatus}, + sort = #{sort} + where id = #{id} - category_name = #{data.categoryName}, - parent_id = #{data.parentId}, - category_status = #{data.categoryStatus}, - sort = #{data.sort}, - create_time = #{data.createTime}, + category_name = #{data.categoryName}, + parent_id = #{data.parentId}, + category_status = #{data.categoryStatus}, + sort = #{data.sort}, + create_time = #{data.createTime}, diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/articleCategory/service/ArticleCategoryService.java b/ruoyi-service/src/main/java/com/ruoyi/bst/articleCategory/service/ArticleCategoryService.java index 3988a11..69512bd 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/articleCategory/service/ArticleCategoryService.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/articleCategory/service/ArticleCategoryService.java @@ -47,13 +47,6 @@ public interface ArticleCategoryService */ public int updateArticleCategory(ArticleCategory articleCategory); - /** - * 批量删除文章分类 - * - * @param ids 需要删除的文章分类主键集合 - * @return 结果 - */ - public int deleteArticleCategoryByIds(Long[] ids); /** * 删除文章分类信息 diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/articleCategory/service/impl/ArticleCategoryServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/bst/articleCategory/service/impl/ArticleCategoryServiceImpl.java index aef61bb..1d00bd3 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/articleCategory/service/impl/ArticleCategoryServiceImpl.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/articleCategory/service/impl/ArticleCategoryServiceImpl.java @@ -6,7 +6,9 @@ import com.github.pagehelper.PageHelper; import com.ruoyi.bst.area.domain.AreaQuery; import com.ruoyi.bst.area.domain.AreaVO; 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.articleCategory.domain.enums.ArticleCategoryStatus; import com.ruoyi.bst.device.utils.DeviceUtil; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; @@ -36,6 +38,8 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService @Autowired private ArticleService articleService; + @Autowired + private ArticleMapper articleMapper; /** * 查询文章分类 @@ -85,10 +89,15 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService if (flag){ ServiceUtil.assertion(true,"不允许插入重复分类"); } - //只允许两次分类 + if(articleCategory.getParentId()!= null) { - Boolean hasParent = hasParent(articleCategory.getParentId()); - ServiceUtil.assertion(hasParent,"该分类下不允许再次分类"); + ArticleCategoryVO vo = articleCategoryMapper.selectArticleCategoryById(articleCategory.getParentId()); + ServiceUtil.assertion(vo==null,"当前分类不存在"); + // 只允许两次分类 + if (vo.getParentId()!=0) { + Boolean hasParent = hasParent(articleCategory.getParentId()); + ServiceUtil.assertion(hasParent,"该分类下不允许再次分类"); + } } articleCategory.setCreateTime(DateUtils.getNowDate()); return articleCategoryMapper.insertArticleCategory(articleCategory); @@ -103,6 +112,25 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService @Override 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 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); if (flag){ @@ -116,31 +144,18 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService return articleCategoryMapper.updateArticleCategory(articleCategory); } - @Override - public int deleteArticleCategoryByIds(Long[] ids) { - return 0; - } private Boolean hasParent(Long id){ + if (id == 0){ + return false; + } Long parentId = selectArticleCategoryById(id).getParentId(); if (parentId != null){ return true; } return false; } - /** - * 批量删除文章分类 - * - * @param ids 需要删除的文章分类主键 - * @return 结果 - */ -// @Override -// @Transactional -// public int deleteArticleCategoryByIds(List ids) -// { -// -// return articleCategoryMapper.deleteArticleCategoryByIds(ids); -// } + /** * 删除文章分类信息 @@ -151,14 +166,12 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService @Override public int deleteArticleCategoryById(Long categoryId) { - List childrenIds = articleCategoryMapper.selectChildren(categoryId); - if (childrenIds != null){ - articleCategoryMapper.deleteArticleCategoryByIds(childrenIds); - } - ArticleVO articleVO = articleService.selectArticleByCategoryId(categoryId); - if (articleVO != null){ - return 0; - } + // 如果当前分类有子分类,先删除子分类 + List childrenCategoryList = articleCategoryMapper.selectChildrenCategory(categoryId); + ServiceUtil.assertion(!childrenCategoryList.isEmpty(),"请先删除当前分类下的子分类"); + // 如果当前分类下有文章,先删除文章 + List articleList = articleService.selectArticleByCategoryId(categoryId); + ServiceUtil.assertion(!articleList.isEmpty(),"当前分类下存在文章,请先删除分类下的文章"); return articleCategoryMapper.deleteArticleCategoryById(categoryId); } } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/complaint/mapper/ComplaintMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/complaint/mapper/ComplaintMapper.xml index 503c315..4a21f59 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/complaint/mapper/ComplaintMapper.xml +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/complaint/mapper/ComplaintMapper.xml @@ -16,23 +16,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select - id, - user_id, - create_time, - content, - type, - picture, - contact - from bst_complaint + bc.id, + bc.user_id, + bc.create_time, + bc.content, + bc.type, + bc.picture, + bc.contact, + su.user_name + from bst_complaint bc + left join sys_user su + on bc.user_id = su.user_id - and id = #{query.id} - and user_id = #{query.userId} - and content = #{query.content} - and type = #{query.type} - and picture = #{query.picture} - and contact = #{query.contact} + and bc.id = #{query.id} + and bc.user_id = #{query.userId} + and bc.content = #{query.content} + and bc.type = #{query.type} + and bc.picture = #{query.picture} + and bc.contact like concat('%',#{query.contact},'%') ${query.params.dataScope} diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/bst/ArticleCategoryController.java b/ruoyi-web/src/main/java/com/ruoyi/web/bst/ArticleCategoryController.java index fec149e..86e27ce 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/bst/ArticleCategoryController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/bst/ArticleCategoryController.java @@ -36,6 +36,7 @@ public class ArticleCategoryController extends BaseController @GetMapping("/list") public AjaxResult list(ArticleCategoryQuery articleCategoryQuery) { + articleCategoryQuery.setScope(true); List list = articleCategoryService.selectArticleCategoryList(articleCategoryQuery); return success(list); } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/bst/ArticleController.java b/ruoyi-web/src/main/java/com/ruoyi/web/bst/ArticleController.java index 389c868..b73f587 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/bst/ArticleController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/bst/ArticleController.java @@ -40,6 +40,7 @@ public class ArticleController extends BaseController { startPage(); startOrderBy(); + query.setScope(true); List list = articleService.selectArticleList(query); return getDataTable(list); }