|
|
|
@ -7,17 +7,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
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.entity.*; |
|
|
|
|
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; |
|
|
|
@ -52,34 +48,33 @@ public class SysFooterSetupServiceImpl extends ServiceImpl<SysFooterSetupMapper, |
|
|
|
|
return R.success(pageList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R checkEnableOrDisable(Integer id, Integer enable) { |
|
|
|
|
SysFooterSetup scheme = baseMapper.selectById(id); |
|
|
|
|
public R checkEnableOrDisable(Integer footerId, Integer enable) { |
|
|
|
|
SysFooterSetup scheme = baseMapper.selectById(footerId); |
|
|
|
|
if (scheme == null) { |
|
|
|
|
return R.fail("悬浮窗方案不存在"); |
|
|
|
|
return R.fail("页脚方案不存在"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Integer siteId = scheme.getSiteId(); |
|
|
|
|
|
|
|
|
|
// 1. 当前操作为启用时,检查逻辑
|
|
|
|
|
if (enable == 0) { |
|
|
|
|
// 全局悬浮栏启用逻辑
|
|
|
|
|
// 全局页脚启用逻辑
|
|
|
|
|
// 对于启用操作,先检查是否是全局应用
|
|
|
|
|
if (scheme.getIsGlobal() == 1) { |
|
|
|
|
// 检查站点下是否存在任何已启用的悬浮栏方案,不论全局还是部分应用
|
|
|
|
|
// 检查站点下是否存在任何已启用的页脚方案,不论全局还是部分应用
|
|
|
|
|
long enabledCount = baseMapper.selectCount(new LambdaQueryWrapper<SysFooterSetup>().eq(SysFooterSetup::getSiteId, siteId).eq(SysFooterSetup::getIsDisable, 0)); |
|
|
|
|
if (enabledCount > 0) { |
|
|
|
|
// 弹窗提示,表明启用新的全局悬浮栏会覆盖当前已启用的悬浮栏
|
|
|
|
|
return R.warn("当前站点已存在启用的悬浮栏方案,启用新方案将会覆盖原有设置,请确认是否继续?"); |
|
|
|
|
// 弹窗提示,表明启用新的全局页脚会覆盖当前已启用的页脚
|
|
|
|
|
return R.warn("当前站点已存在启用的页脚方案,启用新方案将会覆盖原有设置,请确认是否继续?"); |
|
|
|
|
} |
|
|
|
|
} else { // 非全局悬浮栏启用逻辑
|
|
|
|
|
// 检查是否存在启用的全局悬浮栏
|
|
|
|
|
} else { // 非全局页脚启用逻辑
|
|
|
|
|
// 检查是否存在启用的全局页脚
|
|
|
|
|
if (existsEnabledGlobal(siteId)) { |
|
|
|
|
return R.fail("当前已启用全局悬浮栏,无法直接启用部分应用的悬浮栏,请先禁用全局悬浮栏!"); |
|
|
|
|
return R.fail("当前已启用全局页脚,无法直接启用部分应用的页脚,请先禁用全局页脚!"); |
|
|
|
|
} |
|
|
|
|
// 检查与其它部分应用悬浮栏的冲突
|
|
|
|
|
if (hasOverlapWithOtherEnabled(id, siteId)) { |
|
|
|
|
return R.fail(generateConflictMessage(id, siteId, enable)); |
|
|
|
|
// 检查与其它部分应用页脚的冲突
|
|
|
|
|
if (hasOverlapWithOtherEnabled(footerId, siteId)) { |
|
|
|
|
return R.fail(generateConflictMessage(footerId, siteId, enable)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (enable == 1) { // 禁用操作逻辑
|
|
|
|
@ -105,10 +100,10 @@ public class SysFooterSetupServiceImpl extends ServiceImpl<SysFooterSetupMapper, |
|
|
|
|
.eq(SysFooterSetup::getIsDisable, 0) |
|
|
|
|
.eq(SysFooterSetup::getStatus, 1); |
|
|
|
|
|
|
|
|
|
// 查询当前站点下已启用且已发布的悬浮栏方案
|
|
|
|
|
// 查询当前站点下已启用且已发布的页脚
|
|
|
|
|
List<SysFooterSetup> floatingColumnSchemeList = baseMapper.selectList(queryWrapper); |
|
|
|
|
|
|
|
|
|
// 检查是否存在全局启用的悬浮栏方案
|
|
|
|
|
// 检查是否存在全局启用的页脚
|
|
|
|
|
List<SysFooterSetup> globalSetupList = floatingColumnSchemeList.stream() |
|
|
|
|
.filter(setup -> setup.getIsGlobal() == 1) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
@ -118,10 +113,10 @@ public class SysFooterSetupServiceImpl extends ServiceImpl<SysFooterSetupMapper, |
|
|
|
|
return R.success(globalSetupList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 如果没有全局方案,检查当前栏目绑定的悬浮栏方案
|
|
|
|
|
// 如果没有全局方案,检查当前栏目绑定的页脚
|
|
|
|
|
List<Integer> boundSetupIds = scopeOfApplicationMapper.checkBoundByColumnId(columnId); |
|
|
|
|
if (!boundSetupIds.isEmpty()) { |
|
|
|
|
// 根据绑定的ID列表查询启用的悬浮栏方案
|
|
|
|
|
// 根据绑定的ID列表查询启用的页脚
|
|
|
|
|
List<SysFooterSetup> setupsForColumn = baseMapper.selectList( |
|
|
|
|
new LambdaQueryWrapper<SysFooterSetup>() |
|
|
|
|
.in(SysFooterSetup::getId, boundSetupIds) |
|
|
|
@ -133,10 +128,7 @@ public class SysFooterSetupServiceImpl extends ServiceImpl<SysFooterSetupMapper, |
|
|
|
|
return R.success(Collections.emptyList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* @Override |
|
|
|
|
public ConflictCheckResultVO preCheckMultiScopeConflictBeforeUpdate(Integer siteId, List<SysFooterSetupScopeOfApplication> updatedScopes, Integer floatingBarSchemeId) { |
|
|
|
|
return null; |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(readOnly = true) |
|
|
|
|
public ConflictCheckResultVO preCheckMultiScopeConflictBeforeUpdate( |
|
|
|
@ -147,7 +139,7 @@ public class SysFooterSetupServiceImpl extends ServiceImpl<SysFooterSetupMapper, |
|
|
|
|
.map(SysFooterSetupScopeOfApplication::getApplicationScopeId) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
// 2. 从数据库查询该站点下所有启用的悬浮栏方案,但排除掉当前正在更新的那些方案
|
|
|
|
|
// 2. 从数据库查询该站点下所有启用的页脚,但排除掉当前正在更新的那些方案
|
|
|
|
|
List<SysPageFooterScopeOfApplicationWithSiteIdVO> enabledScopes = |
|
|
|
|
baseMapper.selectEnabledScopesForMultiConflictCheck(siteId, excludeSchemeIds,floatingBarSchemeId); |
|
|
|
|
|
|
|
|
@ -209,9 +201,9 @@ public class SysFooterSetupServiceImpl extends ServiceImpl<SysFooterSetupMapper, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检查当前悬浮栏方案与已启用方案是否有重叠。 |
|
|
|
|
* 检查当前页脚与已启用方案是否有重叠。 |
|
|
|
|
* |
|
|
|
|
* @param id 悬浮栏方案ID |
|
|
|
|
* @param id 页脚ID |
|
|
|
|
* @return 是否有重叠 |
|
|
|
|
*/ |
|
|
|
|
private boolean hasOverlapWithOtherEnabled(Integer id, Integer siteId) { |
|
|
|
@ -227,7 +219,7 @@ public class SysFooterSetupServiceImpl extends ServiceImpl<SysFooterSetupMapper, |
|
|
|
|
// 构造查询条件,确保比较的方案属于同一个站点
|
|
|
|
|
String sqlInCondition = "SELECT id FROM sys_footer_setup WHERE is_disable = 0 AND site_id = " + siteId; |
|
|
|
|
|
|
|
|
|
// 查询所有启用且ID不等于当前id且属于相同站点的悬浮栏方案的应用范围
|
|
|
|
|
// 查询所有启用且ID不等于当前id且属于相同站点的页脚的应用范围
|
|
|
|
|
List<SysFooterSetupScopeOfApplication> enabledScopes = scopeOfApplicationMapper.selectList(new LambdaQueryWrapper<SysFooterSetupScopeOfApplication>().ne(SysFooterSetupScopeOfApplication::getFooterId, id).inSql(SysFooterSetupScopeOfApplication::getFooterId, sqlInCondition)); |
|
|
|
|
|
|
|
|
|
// 检查是否有重叠
|
|
|
|
@ -245,33 +237,54 @@ public class SysFooterSetupServiceImpl extends ServiceImpl<SysFooterSetupMapper, |
|
|
|
|
/** |
|
|
|
|
* 生成冲突提示信息,展示冲突的栏目名称。 |
|
|
|
|
* |
|
|
|
|
* @param id 悬浮栏方案ID |
|
|
|
|
* @param footerId 页脚ID |
|
|
|
|
* @return 冲突提示信息 |
|
|
|
|
*/ |
|
|
|
|
private String generateConflictMessage(Integer id, Integer siteId, Integer enableAction) { |
|
|
|
|
// 调用 hasOverlapWithOtherEnabled 确认是否有重叠
|
|
|
|
|
if (!hasOverlapWithOtherEnabled(id, siteId)) { |
|
|
|
|
return ""; // 无冲突则返回空字符串
|
|
|
|
|
private String generateConflictMessage(Integer footerId, Integer siteId, Integer enableAction) { |
|
|
|
|
// 确认当前页脚方案是否与其他方案存在范围重叠
|
|
|
|
|
if (!hasOverlapWithOtherEnabled(footerId, siteId)) { |
|
|
|
|
return ""; // 若无重叠,直接返回空字符串表示无冲突
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取当前方案冲突的范围ID
|
|
|
|
|
List<SysFooterSetupScopeOfApplication> conflictingScopes = scopeOfApplicationMapper.selectList(new LambdaQueryWrapper<SysFooterSetupScopeOfApplication>().eq(SysFooterSetupScopeOfApplication::getFooterId, id)); |
|
|
|
|
// 获取与当前页脚方案ID相关的冲突范围ID集合
|
|
|
|
|
List<SysFooterSetupScopeOfApplication> conflictingScopes = scopeOfApplicationMapper.selectList(new LambdaQueryWrapper<SysFooterSetupScopeOfApplication>().eq(SysFooterSetupScopeOfApplication::getFooterId, footerId)); |
|
|
|
|
|
|
|
|
|
// 将范围ID字符串转换为整数集合
|
|
|
|
|
Set<Integer> conflictScopeIds = conflictingScopes.stream().flatMap(scope -> Arrays.stream(scope.getApplicationScopeId().split(","))).map(Integer::parseInt).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
|
|
// 查询冲突范围对应的栏目名称
|
|
|
|
|
//查询当前已经启用的页脚方案下的的应用范围跟当前设置的范围有重复的就只提出出来重复的id
|
|
|
|
|
conflictScopeIds.retainAll(checkBoundByColumnId(conflictScopeIds, siteId)); |
|
|
|
|
|
|
|
|
|
// 根据冲突范围ID查询对应的栏目名称
|
|
|
|
|
List<String> conflictingScopeNames = columnMapper.selectList(new LambdaQueryWrapper<SysColumn>().in(SysColumn::getId, conflictScopeIds)).stream().map(SysColumn::getColumnName).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
// 根据操作类型调整提示信息()
|
|
|
|
|
// 根据操作类型生成具体的提示信息
|
|
|
|
|
if (enableAction == 0) { // 启用操作
|
|
|
|
|
return "“" + String.join("”, “", conflictingScopeNames) + "”栏目已设置有悬浮栏,请移除后再试。。"; |
|
|
|
|
} else if (enableAction == 1) { // 禁用操作
|
|
|
|
|
return "“" + String.join("”, “", conflictingScopeNames) + "”存在悬浮栏配置冲突,请注意操作可能影响这些栏目的现有悬浮栏设置。"; |
|
|
|
|
// 拼接冲突范围名称,提醒用户需先解决冲突
|
|
|
|
|
return "栏目:“" + String.join("”, “", conflictingScopeNames) + "”已设置有页脚,请先移除相关设置再尝试启用。"; |
|
|
|
|
} else { |
|
|
|
|
return "未知的操作类型"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Set<Integer> checkBoundByColumnId(Set<Integer> columnIds, Integer siteId) { |
|
|
|
|
// 构造SQL查询条件,用于查找所有启用的页脚方案及其范围
|
|
|
|
|
/*String sqlInCondition = columnIds.stream().map(Object::toString).collect(Collectors.joining(","));*/ // 移除了外部的括号
|
|
|
|
|
|
|
|
|
|
List<SysFooterSetupScopeOfApplication> enabledConflictingScopes = scopeOfApplicationMapper.selectList(new LambdaQueryWrapper<SysFooterSetupScopeOfApplication>() |
|
|
|
|
.inSql(SysFooterSetupScopeOfApplication::getFooterId, |
|
|
|
|
"SELECT id FROM sys_footer_setup WHERE is_disable = 0 AND site_id = " + siteId).in(SysFooterSetupScopeOfApplication::getApplicationScopeId, columnIds)); |
|
|
|
|
|
|
|
|
|
// 转换为范围ID集合
|
|
|
|
|
Set<Integer> duplicateScopeIds = new HashSet<>(); |
|
|
|
|
for (SysFooterSetupScopeOfApplication scope : enabledConflictingScopes) { |
|
|
|
|
duplicateScopeIds.addAll(Arrays.stream(scope.getApplicationScopeId().split(",")).map(Integer::parseInt).collect(Collectors.toSet())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return duplicateScopeIds; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean existsEnabledGlobal(Integer siteId) { |
|
|
|
|
|
|
|
|
|
QueryWrapper<SysFooterSetup> queryWrapper = new QueryWrapper<>(); |
|
|
|
|