协议相关、文章分类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 id="selectDistinct" resultType="com.ruoyi.bst.agreement.domain.AgreementVO">
<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>
<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.article.service.ArticleService;
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.common.exception.ServiceException;
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.service.ArticleService;
import javax.print.ServiceUI;
/**
* 文章Service业务层处理
*
@ -65,11 +69,11 @@ public class ArticleServiceImpl implements ArticleService
@Override
public int insertArticle(Article article)
{
//分类必须存在
if(articleCategoryService.selectArticleCategoryById(article.getCategoryId()) ==null){
throw new ServiceException("当前分类不存在");
ArticleCategoryVO articleCategoryVO = articleCategoryService.selectArticleCategoryById(article.getCategoryId());
ServiceUtil.assertion(articleCategoryVO ==null,"当前分类不存在");
if (articleCategoryVO.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode())){
ServiceUtil.assertion(true,"该分类已被禁用");
}
article.setCreateTime(DateUtils.getNowDate());
return articleMapper.insertArticle(article);
}
@ -83,11 +87,11 @@ public class ArticleServiceImpl implements ArticleService
@Override
public int updateArticle(Article article)
{
//分类必须存在
if(articleCategoryService.selectArticleCategoryById(article.getCategoryId()) ==null){
throw new ServiceException("当前分类不存在");
ArticleCategoryVO articleCategoryVO = articleCategoryService.selectArticleCategoryById(article.getCategoryId());
ServiceUtil.assertion(articleCategoryVO ==null,"当前分类不存在");
if (articleCategoryVO.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode())){
ServiceUtil.assertion(true,"该分类已被禁用");
}
article.setUpdateTime(DateUtils.getNowDate());
return articleMapper.updateArticle(article);
}

View File

@ -115,21 +115,28 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService
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()),"该分类所属分类已禁用,无法启用该分类");
// 新增状态变更方向判断
boolean isEnabling = vo.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode())
&& articleCategory.getCategoryStatus().equals(ArticleCategoryStatus.ENABLED.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()),
"该分类所属分类已禁用,无法启用该分类");
}
// 判断当前分类下是否有启用的分类
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);
// 禁用操作校验
else if (isDisabling) {
List<ArticleCategoryVO> childrenCategoryList = articleCategoryMapper.selectChildrenCategory(articleCategory.getId());
boolean hasEnabledChild = childrenCategoryList.stream()
.anyMatch(child -> child.getCategoryStatus().equals(ArticleCategoryStatus.ENABLED.getCode()));
ServiceUtil.assertion(hasEnabledChild, "当前分类下有启用的分类,不可禁用");
}
return articleCategoryMapper.updateArticleCategorySortAndStatusOnly(articleCategory);
}
//目标分类不允许子分类重名
Boolean flag = articleCategoryMapper.checkByNameAndParetId(articleCategory);