页脚设置bug修复

master
rong.liu 5 months ago
parent de5a9a7e83
commit 8b5988c329
  1. 4
      src/main/java/com/huoran/iasf/controller/CategoryController.java
  2. 3
      src/main/java/com/huoran/iasf/mapper/SysNavigationIconMapper.java
  3. 9
      src/main/java/com/huoran/iasf/mapper/xml/SysNavigationIconMapper.xml
  4. 4
      src/main/java/com/huoran/iasf/service/SysCategoryService.java
  5. 10
      src/main/java/com/huoran/iasf/service/impl/CategoryServiceImpl.java
  6. 99
      src/main/java/com/huoran/iasf/service/impl/SysFooterSetupServiceImpl.java
  7. 2
      src/main/java/com/huoran/iasf/service/impl/SysNavigationIconServiceImpl.java
  8. 10
      src/main/java/com/huoran/iasf/vo/req/SortOrderReq.java

@ -47,10 +47,10 @@ public class CategoryController {
boolean isDuplicate = false;
if (category.getCategoryId() != null) {
// 更新逻辑,排除当前记录自身
isDuplicate = service.existsOtherByName(category.getName(), category.getCategoryId(), category.getSiteId());
isDuplicate = service.existsOtherByName(category.getName(), category.getCategoryId(), category.getSiteId(),category.getType());
} else {
// 新增逻辑,直接检查名称是否存在
isDuplicate = service.existsByName(category.getName(), category.getSiteId());
isDuplicate = service.existsByName(category.getName(), category.getSiteId(),category.getType());
}
if (isDuplicate) {

@ -17,8 +17,7 @@ import java.util.List;
*/
public interface SysNavigationIconMapper extends BaseMapper<SysNavigationIcon> {
// 更新单个记录的sort_order
@Update("UPDATE sys_navigation_icon SET sort_order = #{sortOrder} WHERE id = #{id}")
void updateSortOrder(@Param("id") Integer id, @Param("sortOrder") Integer sortOrder);
void updateSortOrder(@Param("id") Integer id, @Param("sortOrder") Integer sortOrder,@Param("icon") String icon);
List<SysNavigationIcon> listBySiteIdAndStatus(@Param("siteId") Integer siteId,
@Param("isDisable") Integer disableStatus,

@ -1,6 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.huoran.iasf.mapper.SysNavigationIconMapper">
<update id="updateSortOrder">
UPDATE sys_navigation_icon
SET sort_order = #{sortOrder}
<if test="icon != null and icon != ''">
, icon = #{icon}
</if>
WHERE id = #{id}
</update>
<select id="listBySiteIdAndStatus" resultType="com.huoran.iasf.entity.SysNavigationIcon">
SELECT

@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface SysCategoryService extends IService<Category> {
boolean existsOtherByName(String name, Integer categoryId,Integer siteId);
boolean existsOtherByName(String name, Integer categoryId,Integer siteId, Integer type);
boolean existsByName(String name,Integer siteId);
boolean existsByName(String name,Integer siteId, Integer type);
}

@ -1,10 +1,10 @@
package com.huoran.iasf.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huoran.iasf.entity.Category;
import com.huoran.iasf.mapper.CategoryMapper;
import com.huoran.iasf.service.SysCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
@ -19,10 +19,12 @@ import org.springframework.stereotype.Service;
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements SysCategoryService {
@Override
public boolean existsOtherByName(String name, Integer categoryId,Integer siteId) {
public boolean existsOtherByName(String name, Integer categoryId, Integer siteId, Integer type) {
QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("name", name);
queryWrapper.eq("site_id", siteId);
queryWrapper.eq("type", type);
if (categoryId != null) {
queryWrapper.ne("category_id", categoryId);
}
@ -30,10 +32,12 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
}
@Override
public boolean existsByName(String name,Integer siteId) {
public boolean existsByName(String name, Integer siteId, Integer type) {
QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("name", name);
queryWrapper.eq("site_id", siteId);
queryWrapper.eq("type", type);
if (baseMapper.selectCount(queryWrapper) > 0) {
return true;
}

@ -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<>();

@ -31,7 +31,7 @@ public class SysNavigationIconServiceImpl extends ServiceImpl<SysNavigationIconM
public void batchUpdateSortOrder(List<SortOrderReq> sortOrderRequests) {
for (SortOrderReq request : sortOrderRequests) {
// 根据ID更新每个记录的sort_order字段
baseMapper.updateSortOrder(request.getId(), request.getSortOrder());
baseMapper.updateSortOrder(request.getId(), request.getSortOrder(), request.getIcon());
}
}

@ -1,12 +1,18 @@
package com.huoran.iasf.vo.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
/**
* 接收排序请求的数据结构
*/
public class SortOrderReq {
*/ public class SortOrderReq {
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "排序顺序")
private Integer sortOrder;
@ApiModelProperty(value = "图标")
private String icon;
}

Loading…
Cancel
Save