diff --git a/src/main/java/com/huoran/iasf/controller/SysFooterSetupController.java b/src/main/java/com/huoran/iasf/controller/SysFooterSetupController.java
index 3f478e2..f8fab17 100644
--- a/src/main/java/com/huoran/iasf/controller/SysFooterSetupController.java
+++ b/src/main/java/com/huoran/iasf/controller/SysFooterSetupController.java
@@ -10,6 +10,7 @@ import com.huoran.iasf.entity.SysFooterSetup;
import com.huoran.iasf.entity.SysFooterSetupScopeOfApplication;
import com.huoran.iasf.service.SysFooterSetupScopeOfApplicationService;
import com.huoran.iasf.service.SysFooterSetupService;
+import com.huoran.iasf.vo.ConflictCheckResultVO;
import com.huoran.iasf.vo.FooterListVO;
import com.huoran.iasf.vo.SysFloatingColumnSchemeVO;
import com.huoran.iasf.vo.req.SuspensionBarListPagingReq;
@@ -86,12 +87,24 @@ public class SysFooterSetupController {
@ApiOperation(value = "保存或更新页脚配置记录", response = SysFooterSetup.class)
public R saveOrUpdate(@RequestBody @ApiParam(name = "页脚配置对象", value = "包含页脚配置详细信息,若id不存在则新建,否则视为更新", required = true) SysFooterSetup sysFooterSetup) {
+ if (sysFooterSetup.getId() != null && sysFooterSetup.getIsDisable() == 0) {
+ ConflictCheckResultVO conflictCheckResultVO = service.preCheckMultiScopeConflictBeforeUpdate(sysFooterSetup.getSiteId(),
+ sysFooterSetup.getFooterSetupScopeOfApplications(), sysFooterSetup.getId());
+ if (conflictCheckResultVO.isHasConflict()) {
+ return R.fail(conflictCheckResultVO.getMessage());
+ }
+ }
+
// 新增场景下直接进行校验
if (sysFooterSetup.getId() == null) {
if (verifyTheFooterName(sysFooterSetup.getFooterName(), sysFooterSetup.getSiteId())) {
return R.fail("该站点下已存在相同的页脚名称");
}
}
+
+
+
+
// 编辑场景下,只有当名称发生改变时才进行校验,并排除当前记录自身
else if (!sysFooterSetup.getFooterName().equals(service.getById(sysFooterSetup.getId()).getFooterName())) {
if (checkSchemeNameExceptSelf(sysFooterSetup.getFooterName(), sysFooterSetup.getSiteId(), sysFooterSetup.getId())) {
diff --git a/src/main/java/com/huoran/iasf/mapper/SysFooterSetupMapper.java b/src/main/java/com/huoran/iasf/mapper/SysFooterSetupMapper.java
index 03ca4ac..93f83ec 100644
--- a/src/main/java/com/huoran/iasf/mapper/SysFooterSetupMapper.java
+++ b/src/main/java/com/huoran/iasf/mapper/SysFooterSetupMapper.java
@@ -5,10 +5,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huoran.iasf.entity.SysFooterSetup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huoran.iasf.vo.FooterListVO;
+import com.huoran.iasf.vo.SysFloatingColumnSchemeScopeOfApplicationWithSiteIdVO;
import com.huoran.iasf.vo.SysFloatingColumnSchemeVO;
+import com.huoran.iasf.vo.SysPageFooterScopeOfApplicationWithSiteIdVO;
import com.huoran.iasf.vo.req.SuspensionBarListPagingReq;
import org.apache.ibatis.annotations.Param;
+import java.util.List;
+
/**
*
* 页脚配置 Mapper 接口
@@ -20,4 +24,8 @@ import org.apache.ibatis.annotations.Param;
public interface SysFooterSetupMapper extends BaseMapper {
IPage footerList(Page page, @Param("req") SuspensionBarListPagingReq sysFloatingColumnScheme);
+
+ List selectEnabledScopesForMultiConflictCheck(
+ @Param("siteId") Integer siteId,
+ @Param("excludeSchemeIds") List excludeSchemeIds,@Param("floatingBarSchemeId")Integer floatingBarSchemeId);
}
diff --git a/src/main/java/com/huoran/iasf/mapper/xml/SysFooterSetupMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/SysFooterSetupMapper.xml
index 0e41c02..a0a49f9 100644
--- a/src/main/java/com/huoran/iasf/mapper/xml/SysFooterSetupMapper.xml
+++ b/src/main/java/com/huoran/iasf/mapper/xml/SysFooterSetupMapper.xml
@@ -51,4 +51,21 @@
ORDER BY
s.id DESC
+
diff --git a/src/main/java/com/huoran/iasf/service/SysFooterSetupService.java b/src/main/java/com/huoran/iasf/service/SysFooterSetupService.java
index 05d8fa7..944fc88 100644
--- a/src/main/java/com/huoran/iasf/service/SysFooterSetupService.java
+++ b/src/main/java/com/huoran/iasf/service/SysFooterSetupService.java
@@ -1,10 +1,15 @@
package com.huoran.iasf.service;
import com.huoran.iasf.common.utils.R;
+import com.huoran.iasf.entity.SysFloatingColumnSchemeScopeOfApplication;
import com.huoran.iasf.entity.SysFooterSetup;
import com.baomidou.mybatisplus.extension.service.IService;
+import com.huoran.iasf.entity.SysFooterSetupScopeOfApplication;
+import com.huoran.iasf.vo.ConflictCheckResultVO;
import com.huoran.iasf.vo.req.SuspensionBarListPagingReq;
+import java.util.List;
+
/**
*
* 页脚配置 服务类
@@ -20,4 +25,7 @@ public interface SysFooterSetupService extends IService {
R checkEnableOrDisable(Integer id, Integer isDisable);
R showTheFooterAccordingToTheColumn(String columnId);
+
+ ConflictCheckResultVO preCheckMultiScopeConflictBeforeUpdate(
+ Integer siteId, List updatedScopes, Integer floatingBarSchemeId);
}
diff --git a/src/main/java/com/huoran/iasf/service/impl/SysFooterSetupServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysFooterSetupServiceImpl.java
index fbfb0f5..fb1747e 100644
--- a/src/main/java/com/huoran/iasf/service/impl/SysFooterSetupServiceImpl.java
+++ b/src/main/java/com/huoran/iasf/service/impl/SysFooterSetupServiceImpl.java
@@ -8,16 +8,22 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huoran.iasf.common.utils.R;
import com.huoran.iasf.entity.SysColumn;
+import com.huoran.iasf.entity.SysFloatingColumnSchemeScopeOfApplication;
import com.huoran.iasf.entity.SysFooterSetup;
import com.huoran.iasf.entity.SysFooterSetupScopeOfApplication;
import com.huoran.iasf.mapper.SysColumnMapper;
import com.huoran.iasf.mapper.SysFooterSetupMapper;
import com.huoran.iasf.mapper.SysFooterSetupScopeOfApplicationMapper;
import com.huoran.iasf.service.SysFooterSetupService;
+import com.huoran.iasf.vo.ConflictCheckResultVO;
import com.huoran.iasf.vo.FooterListVO;
+import com.huoran.iasf.vo.SysFloatingColumnSchemeScopeOfApplicationWithSiteIdVO;
+import com.huoran.iasf.vo.SysPageFooterScopeOfApplicationWithSiteIdVO;
import com.huoran.iasf.vo.req.SuspensionBarListPagingReq;
+import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
@@ -127,6 +133,80 @@ public class SysFooterSetupServiceImpl extends ServiceImpl updatedScopes, Integer floatingBarSchemeId) {
+ return null;
+ }*/
+
+ @Transactional(readOnly = true)
+ public ConflictCheckResultVO preCheckMultiScopeConflictBeforeUpdate(
+ Integer siteId, List updatedScopes, Integer floatingBarSchemeId) {
+
+ // 1. 收集待更新方案的ID,用于排除这些方案在冲突检测中的干扰
+ List excludeSchemeIds = updatedScopes.stream()
+ .map(SysFooterSetupScopeOfApplication::getApplicationScopeId)
+ .collect(Collectors.toList());
+
+ // 2. 从数据库查询该站点下所有启用的悬浮栏方案,但排除掉当前正在更新的那些方案
+ List enabledScopes =
+ baseMapper.selectEnabledScopesForMultiConflictCheck(siteId, excludeSchemeIds,floatingBarSchemeId);
+
+ // 初始化冲突标记为false,并准备一个StringBuilder用于记录冲突信息
+ boolean hasConflict = false;
+ StringBuilder conflictMessageBuilder = new StringBuilder();
+ Set conflictColumnNames = new HashSet<>(); // 用于存储所有冲突的栏目名称
+
+ // 3. 对比每个待更新的方案与已启用方案,检测应用范围是否有重叠
+ for (SysPageFooterScopeOfApplicationWithSiteIdVO existingScope : enabledScopes) {
+ for (SysFooterSetupScopeOfApplication newScope : updatedScopes) {
+ // 分割应用范围ID为集合,以便逐个比较
+ Set existingScopeIds = Arrays.stream(existingScope.getApplicationScopeId().split(","))
+ .map(String::trim)
+ .filter(id -> !id.isEmpty() && NumberUtils.isCreatable(id))
+ .map(Integer::parseInt)
+ .collect(Collectors.toSet());
+ Set newScopeIds = Arrays.stream(newScope.getApplicationScopeId().split(","))
+ .map(String::trim)
+ .filter(id -> !id.isEmpty() && NumberUtils.isCreatable(id))
+ .map(Integer::parseInt)
+ .collect(Collectors.toSet());
+
+ // 找出重叠的范围ID
+ Set overlapIds = new HashSet<>(existingScopeIds);
+ overlapIds.retainAll(newScopeIds);
+
+ // 避免重复处理相同的冲突范围
+ if (!overlapIds.isEmpty()) {
+ for (Integer overlapId : overlapIds) {
+ String columnName = getColumnNameById(String.valueOf(overlapId)); // 假设这是获取栏目名称的方法
+ conflictColumnNames.add(columnName); // 收集冲突的栏目名称
+ }
+ }
+ }
+ }
+
+ // 构建最终的冲突信息,如果存在冲突
+ if (!conflictColumnNames.isEmpty()) {
+ hasConflict = true;
+ conflictMessageBuilder.append("栏目:");
+ boolean isFirst = true;
+ for (String columnName : conflictColumnNames) {
+ if (!isFirst) {
+ conflictMessageBuilder.append("、"); // 使用中文逗号作为分隔符
+ }
+ conflictMessageBuilder.append(columnName);
+ isFirst = false;
+ }
+ conflictMessageBuilder.append(" 已设置有页脚,请先移除相关设置再尝试启用。\n");
+ }
+ // 4. 根据检测结果创建并返回ConflictCheckResult对象
+ return new ConflictCheckResultVO(hasConflict, conflictMessageBuilder.toString());
+ }
+
+ private String getColumnNameById(String overlapId) {
+ return columnMapper.getColumnNamesById(overlapId);
+ }
+
/**
* 检查当前悬浮栏方案与已启用方案是否有重叠。
diff --git a/src/main/java/com/huoran/iasf/vo/SysPageFooterScopeOfApplicationWithSiteIdVO.java b/src/main/java/com/huoran/iasf/vo/SysPageFooterScopeOfApplicationWithSiteIdVO.java
new file mode 100644
index 0000000..abdbd84
--- /dev/null
+++ b/src/main/java/com/huoran/iasf/vo/SysPageFooterScopeOfApplicationWithSiteIdVO.java
@@ -0,0 +1,12 @@
+package com.huoran.iasf.vo;
+
+import com.huoran.iasf.entity.SysFloatingColumnSchemeScopeOfApplication;
+import com.huoran.iasf.entity.SysFooterSetup;
+import com.huoran.iasf.entity.SysFooterSetupScopeOfApplication;
+import lombok.Data;
+
+@Data
+public class SysPageFooterScopeOfApplicationWithSiteIdVO extends SysFooterSetupScopeOfApplication {
+ private String schemeName; // 悬浮栏方案名称,从关联查询中获取
+ private Integer siteId; // 站点ID,从关联查询中获取
+}