协议相关、文章分类bug修改、文章逻辑完善、前端界面完善

This commit is contained in:
SjS 2025-04-08 20:31:05 +08:00
parent 27b4858aa7
commit 6e34237028
3 changed files with 32 additions and 21 deletions

View File

@ -69,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectDistinct" resultType="com.ruoyi.bst.agreement.domain.AgreementVO"> <select id="selectDistinct" resultType="com.ruoyi.bst.agreement.domain.AgreementVO">
<include refid="selectAgreementVo"/> <include refid="selectAgreementVo"/>
where store_id = #{storeId} and agreement_type = #{agreementType} where bag.store_id = #{storeId} and bag.agreement_type = #{agreementType} and (bag.id != #{id} or #{id} is null)
</select> </select>
<insert id="insertAgreement" parameterType="Agreement" useGeneratedKeys="true" keyProperty="id"> <insert id="insertAgreement" parameterType="Agreement" useGeneratedKeys="true" keyProperty="id">

View File

@ -5,6 +5,8 @@ import java.util.List;
import com.ruoyi.bst.area.service.AreaService; import com.ruoyi.bst.area.service.AreaService;
import com.ruoyi.bst.article.service.ArticleService; import com.ruoyi.bst.article.service.ArticleService;
import com.ruoyi.bst.articleCategory.domain.ArticleCategoryQuery; import com.ruoyi.bst.articleCategory.domain.ArticleCategoryQuery;
import com.ruoyi.bst.articleCategory.domain.ArticleCategoryVO;
import com.ruoyi.bst.articleCategory.domain.enums.ArticleCategoryStatus;
import com.ruoyi.bst.articleCategory.service.ArticleCategoryService; import com.ruoyi.bst.articleCategory.service.ArticleCategoryService;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
@ -17,6 +19,8 @@ import com.ruoyi.bst.article.domain.ArticleVO;
import com.ruoyi.bst.article.domain.ArticleQuery; import com.ruoyi.bst.article.domain.ArticleQuery;
import com.ruoyi.bst.article.service.ArticleService; import com.ruoyi.bst.article.service.ArticleService;
import javax.print.ServiceUI;
/** /**
* 文章Service业务层处理 * 文章Service业务层处理
* *
@ -65,11 +69,11 @@ public class ArticleServiceImpl implements ArticleService
@Override @Override
public int insertArticle(Article article) public int insertArticle(Article article)
{ {
//分类必须存在 ArticleCategoryVO articleCategoryVO = articleCategoryService.selectArticleCategoryById(article.getCategoryId());
if(articleCategoryService.selectArticleCategoryById(article.getCategoryId()) ==null){ ServiceUtil.assertion(articleCategoryVO ==null,"当前分类不存在");
throw new ServiceException("当前分类不存在"); if (articleCategoryVO.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode())){
ServiceUtil.assertion(true,"该分类已被禁用");
} }
article.setCreateTime(DateUtils.getNowDate()); article.setCreateTime(DateUtils.getNowDate());
return articleMapper.insertArticle(article); return articleMapper.insertArticle(article);
} }
@ -83,11 +87,11 @@ public class ArticleServiceImpl implements ArticleService
@Override @Override
public int updateArticle(Article article) public int updateArticle(Article article)
{ {
//分类必须存在 ArticleCategoryVO articleCategoryVO = articleCategoryService.selectArticleCategoryById(article.getCategoryId());
if(articleCategoryService.selectArticleCategoryById(article.getCategoryId()) ==null){ ServiceUtil.assertion(articleCategoryVO ==null,"当前分类不存在");
throw new ServiceException("当前分类不存在"); if (articleCategoryVO.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode())){
ServiceUtil.assertion(true,"该分类已被禁用");
} }
article.setUpdateTime(DateUtils.getNowDate()); article.setUpdateTime(DateUtils.getNowDate());
return articleMapper.updateArticle(article); return articleMapper.updateArticle(article);
} }

View File

@ -115,19 +115,26 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService
ArticleCategoryVO vo = articleCategoryMapper.selectArticleCategoryById(articleCategory.getId()); ArticleCategoryVO vo = articleCategoryMapper.selectArticleCategoryById(articleCategory.getId());
//检查是否仅修改排序或状态字段 //检查是否仅修改排序或状态字段
if (vo != null && vo.getParentId().equals(articleCategory.getParentId())&&vo.getCategoryName().equals(articleCategory.getCategoryName())) { if (vo != null && vo.getParentId().equals(articleCategory.getParentId())&&vo.getCategoryName().equals(articleCategory.getCategoryName())) {
if (vo.getCategoryStatus()!=null) { // 新增状态变更方向判断
if (vo.getParentId() != null) { boolean isEnabling = vo.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode())
ArticleCategoryVO parentVO = articleCategoryMapper.selectArticleCategoryById(vo.getParentId()); && articleCategory.getCategoryStatus().equals(ArticleCategoryStatus.ENABLED.getCode());
ServiceUtil.assertion(parentVO.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode()),"该分类所属分类已禁用,无法启用该分类");
boolean isDisabling = vo.getCategoryStatus().equals(ArticleCategoryStatus.ENABLED.getCode())
&& articleCategory.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode());
// 启用操作校验
if (isEnabling) {
if (articleCategory.getParentId() != null) {
ArticleCategoryVO parentVO = articleCategoryMapper.selectArticleCategoryById(articleCategory.getParentId());
ServiceUtil.assertion(parentVO.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode()),
"该分类所属分类已禁用,无法启用该分类");
} }
// 判断当前分类下是否有启用的分类 }
// 禁用操作校验
else if (isDisabling) {
List<ArticleCategoryVO> childrenCategoryList = articleCategoryMapper.selectChildrenCategory(articleCategory.getId()); List<ArticleCategoryVO> childrenCategoryList = articleCategoryMapper.selectChildrenCategory(articleCategory.getId());
childrenCategoryList.forEach(child -> { boolean hasEnabledChild = childrenCategoryList.stream()
if (Objects.equals(child.getCategoryStatus(), ArticleCategoryStatus.ENABLED.getCode())) { .anyMatch(child -> child.getCategoryStatus().equals(ArticleCategoryStatus.ENABLED.getCode()));
ServiceUtil.assertion(!childrenCategoryList.isEmpty(),"当前分类下有启用的分类,不可禁用"); ServiceUtil.assertion(hasEnabledChild, "当前分类下有启用的分类,不可禁用");
}
});
} }
return articleCategoryMapper.updateArticleCategorySortAndStatusOnly(articleCategory); return articleCategoryMapper.updateArticleCategorySortAndStatusOnly(articleCategory);
} }