页脚设置commit

master
rong.liu 6 months ago
parent dffcb909cb
commit f44903e256
  1. 237
      src/main/java/com/huoran/iasf/controller/SysFooterSetupController.java
  2. 75
      src/main/java/com/huoran/iasf/entity/SysFooterSetup.java
  3. 38
      src/main/java/com/huoran/iasf/entity/SysFooterSetupScopeOfApplication.java
  4. 23
      src/main/java/com/huoran/iasf/mapper/SysFooterSetupMapper.java
  5. 20
      src/main/java/com/huoran/iasf/mapper/SysFooterSetupScopeOfApplicationMapper.java
  6. 54
      src/main/java/com/huoran/iasf/mapper/xml/SysFooterSetupMapper.xml
  7. 17
      src/main/java/com/huoran/iasf/mapper/xml/SysFooterSetupScopeOfApplicationMapper.xml
  8. 17
      src/main/java/com/huoran/iasf/service/SysFooterSetupScopeOfApplicationService.java
  9. 23
      src/main/java/com/huoran/iasf/service/SysFooterSetupService.java
  10. 28
      src/main/java/com/huoran/iasf/service/impl/SysFooterSetupScopeOfApplicationServiceImpl.java
  11. 202
      src/main/java/com/huoran/iasf/service/impl/SysFooterSetupServiceImpl.java
  12. 62
      src/main/java/com/huoran/iasf/vo/FooterListVO.java
  13. 2
      src/test/java/com/company/project/CodeGenerator.java

@ -0,0 +1,237 @@
package com.huoran.iasf.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.huoran.iasf.common.utils.R;
import com.huoran.iasf.entity.SysFloatingColumnScheme;
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.FooterListVO;
import com.huoran.iasf.vo.SysFloatingColumnSchemeVO;
import com.huoran.iasf.vo.req.SuspensionBarListPagingReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @描述页脚配置控制类
* @作者: Rong
* @日期: 2024-06-07
*/
@RestController
@RequestMapping("/SysFooterSetupService/SysFooterSetup")
@Api(value = "页脚配置:SysFooterSetupController", tags = "页脚配置:页脚配置")
public class SysFooterSetupController {
@Autowired
public SysFooterSetupService service;
@Autowired
public SysFooterSetupScopeOfApplicationService footerSetupScopeOfApplicationService;
// 根据站点校验方案名称,排除当前ID记录
private boolean checkSchemeNameExceptSelf(String footerName, Integer siteId, Integer id) {
QueryWrapper<SysFooterSetup> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("footer_name", footerName);
queryWrapper.eq("site_id", siteId);
// 添加条件,排除当前ID的记录
if (id != null) {
queryWrapper.ne("id", id);
}
return service.count(queryWrapper) > 0;
}
// 现在仅用于新增场景或编辑时名称变更的校验,不需排除自身ID
private boolean verifyTheFooterName(String footerName, Integer siteId) {
QueryWrapper<SysFooterSetup> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("footer_name", footerName);
queryWrapper.eq("site_id", siteId);
return service.count(queryWrapper) > 0;
}
private void handleFloatingColumnSchemeScopeOfApplications(SysFooterSetup footerSetup) {
if (footerSetup.getFooterSetupScopeOfApplications() != null && !footerSetup.getFooterSetupScopeOfApplications().isEmpty()) {
for (SysFooterSetupScopeOfApplication scope : footerSetup.getFooterSetupScopeOfApplications()) {
scope.setFooterId(footerSetup.getId());
if (footerSetup.getId() == null) {
// 如果页脚方案是新建的,直接保存范围
footerSetupScopeOfApplicationService.save(scope);
} else {
// 如果页脚方案是更新的,根据情况更新或保存范围
footerSetupScopeOfApplicationService.saveOrUpdate(scope);
}
}
}
}
/**
* 保存或更新页脚配置记录
* 如果ID为空则执行保存操作如果ID有值则视为更新操作
*
* @param sysFooterSetup 要保存或更新的页脚配置对象
* @return R 结果对象包含操作状态信息
*/
@PostMapping("/saveOrUpdate")
@ApiOperation(value = "保存或更新页脚配置记录", response = SysFooterSetup.class)
public R saveOrUpdate(@RequestBody @ApiParam(name = "页脚配置对象", value = "包含页脚配置详细信息,若id不存在则新建,否则视为更新", required = true) SysFooterSetup sysFooterSetup) {
// 新增场景下直接进行校验
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())) {
return R.fail("该站点下已存在相同的页脚名称");
}
}
//获取floatingColumnSchemeScopeOfApplications中的范围判断是不是0,如果包含为0
List<SysFooterSetupScopeOfApplication> footerSetupScopeOfApplications = sysFooterSetup.getFooterSetupScopeOfApplications();
for (SysFooterSetupScopeOfApplication scopeOfApplication : footerSetupScopeOfApplications) {
if (scopeOfApplication.getApplicationScopeId().equals("0")) {
sysFooterSetup.setIsGlobal(1);
} else {
sysFooterSetup.setIsGlobal(0);
}
}
// 处理全局页脚逻辑
if (sysFooterSetup.getIsGlobal() == 1) {
// 确保没有其他全局页脚同时启用
long globalCount = service.count(new QueryWrapper<SysFooterSetup>().eq("is_global", true).eq("site_id", sysFooterSetup.getSiteId()).eq("is_disable", 0).ne("id", sysFooterSetup.getId()));
if (globalCount > 0) {
return R.fail("已经有全局页脚启用,请先禁用后再尝试设置");
}
}
boolean result = false;
try {
if (sysFooterSetup.getId() == null) {
// 保存操作
result = service.save(sysFooterSetup);
} else {
// 更新操作
result = service.updateById(sysFooterSetup);
}
} catch (Exception e) {
return R.fail("操作失败");
}
if (!result) {
return R.fail("操作失败");
}
//删除原有范围
footerSetupScopeOfApplicationService.deleteTheRangeBasedOnTheFooterId(sysFooterSetup.getId());
handleFloatingColumnSchemeScopeOfApplications(sysFooterSetup);
return R.success();
}
@PostMapping("/footerList")
@ApiOperation(value = "页脚列表", response = FooterListVO.class)
public R footerList(@RequestBody SuspensionBarListPagingReq sysFloatingColumnScheme) {
return service.footerList(sysFloatingColumnScheme);
}
@PostMapping("/showTheFooterAccordingToTheColumn")
@ApiOperation(value = "根据栏目展示页脚", response = SysFloatingColumnSchemeVO.class)
public R columnDisplayFloatingBar(@ApiParam(name = "columnId", value = "栏目id", required = true) @RequestParam String columnId) {
return service.showTheFooterAccordingToTheColumn(columnId);
}
/**
* * 1.应用全部权限最高只要是启用应用全部的除了一开始没有启用页脚的都弹窗提示当前已启用了的页脚方案将会被取消
* 2.启用了应用全部的后面要启用部分的提示先禁用应用全部的
* 3.部分启用vs部分启用且有重合的提示移除重合的
*/
@PostMapping("/enableOrDisableScheme")
@ApiOperation(value = "启用或禁用", response = SysFooterSetup.class)
public R enableOrDisableScheme(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id, @ApiParam(name = "isDisable", value = "是否禁用(0启用 1禁用)", required = true) @RequestParam Integer isDisable) {
/* return service.enableOrDisableScheme(id, isDisable);*/
//禁启用操作
SysFooterSetup footSetup = service.getById(id);
footSetup.setIsDisable(isDisable);
boolean operation = service.updateById(footSetup);
//增加判断如果当前的应用权限如果为全部,需要将当前站点下其余已经启用的给禁用了
if (footSetup.getIsDisable() == 0 && footSetup.getIsGlobal() == 1) {
UpdateWrapper<SysFooterSetup> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("is_disable", 1);
updateWrapper.eq("is_disable", 0);
updateWrapper.eq("site_id", footSetup.getSiteId());
updateWrapper.ne("id", id);
service.update(updateWrapper);
}
return operation ? R.success() : R.fail("操作失败");
}
@PostMapping("/checkEnableOrDisable")
@ApiOperation(value = "检查“启用”或“禁用”()", response = SysFloatingColumnSchemeVO.class)
public R checkEnableOrDisable(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id, @ApiParam(name = "isDisable", value = "是否禁用(0启用 1禁用)", required = true) @RequestParam Integer isDisable) {
return service.checkEnableOrDisable(id, isDisable);
}
@PostMapping("/findById")
@ApiOperation(value = "查询详情", response = SysFooterSetup.class)
public R findById(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) {
SysFooterSetup sysFooterSetup = service.getById(id);
if (!ObjectUtil.isEmpty(handleFloatingColumnSchemeScopeOfApplications(id))) {
sysFooterSetup.setFooterSetupScopeOfApplications(handleFloatingColumnSchemeScopeOfApplications(id));
}
return R.success(sysFooterSetup);
}
//根据页脚获取范围
private List<SysFooterSetupScopeOfApplication> handleFloatingColumnSchemeScopeOfApplications(Integer footerId) {
LambdaQueryWrapper<SysFooterSetupScopeOfApplication> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysFooterSetupScopeOfApplication::getFooterId, footerId);
return footerSetupScopeOfApplicationService.list(queryWrapper);
}
@PostMapping("/batchDeletion")
@ApiOperation(value = "批量删除页脚数据", response = SysFloatingColumnScheme.class)
public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestParam List<Integer> ids) {
boolean delState = service.removeByIds(ids);
//删除的同时将页脚方案以及页脚应用范围
if (delState) {
for (Integer getFooterId : ids) {
LambdaQueryWrapper<SysFooterSetupScopeOfApplication> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysFooterSetupScopeOfApplication::getFooterId, getFooterId);
footerSetupScopeOfApplicationService.remove(queryWrapper);
}
}
return R.success();
}
}

@ -0,0 +1,75 @@
package com.huoran.iasf.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* <p>
* 页脚配置
* </p>
*
* @author cheney
* @since 2024-06-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "SysFooterSetup对象", description = "页脚配置")
public class SysFooterSetup implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "站点id")
private Integer siteId;
@ApiModelProperty(value = "页脚名称")
private String footerName;
@ApiModelProperty(value = "页脚内容")
private String footerContent;
@ApiModelProperty(value = "状态(0默认草稿箱 1为已发布)")
private Integer status;
@ApiModelProperty(value = "悬浮栏样式id(关联样式表id)")
private Integer floatingBarStyle;
@ApiModelProperty(value = "是否禁用(默认1不启用,0启用 1禁用)")
private Integer isDisable;
@ApiModelProperty(value = "创建人id")
private Integer founderId;
@ApiModelProperty(value = "编辑人id")
private Integer editorId;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
@ApiModelProperty(value = "是否为全局(0否,1是)")
private Integer isGlobal;
@ApiModelProperty(value = "应用范围")
@TableField(exist = false)
private List<SysFooterSetupScopeOfApplication> footerSetupScopeOfApplications;
}

@ -0,0 +1,38 @@
package com.huoran.iasf.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* <p>
* 页脚应用范围
* </p>
*
* @author cheney
* @since 2024-06-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "SysFooterSetupScopeOfApplication对象", description = "页脚应用范围")
public class SysFooterSetupScopeOfApplication implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "页脚主键")
private Integer footerId;
@ApiModelProperty(value = "应用范围id(为0表示网站全局,其余为栏目表主键)")
private String applicationScopeId;
}

@ -0,0 +1,23 @@
package com.huoran.iasf.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.SysFloatingColumnSchemeVO;
import com.huoran.iasf.vo.req.SuspensionBarListPagingReq;
import org.apache.ibatis.annotations.Param;
/**
* <p>
* 页脚配置 Mapper 接口
* </p>
*
* @author cheney
* @since 2024-06-07
*/
public interface SysFooterSetupMapper extends BaseMapper<SysFooterSetup> {
IPage<FooterListVO> footerList(Page<FooterListVO> page, @Param("req") SuspensionBarListPagingReq sysFloatingColumnScheme);
}

@ -0,0 +1,20 @@
package com.huoran.iasf.mapper;
import com.huoran.iasf.entity.SysFooterSetupScopeOfApplication;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 页脚应用范围 Mapper 接口
* </p>
*
* @author cheney
* @since 2024-06-07
*/
public interface SysFooterSetupScopeOfApplicationMapper extends BaseMapper<SysFooterSetupScopeOfApplication> {
List<Integer> checkBoundByColumnId(@Param("columnId") String columnId);
}

@ -0,0 +1,54 @@
<?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.SysFooterSetupMapper">
<select id="footerList" resultType="com.huoran.iasf.vo.FooterListVO">
SELECT
s.id AS footerId,
s.*,
u.username AS editorSName,
GROUP_CONCAT(
DISTINCT
CASE
WHEN scsa.application_scope_id = '0' THEN
'应用至全部' ELSE (
SELECT
GROUP_CONCAT( column_name SEPARATOR ', ' )
FROM
sys_column
WHERE
FIND_IN_SET( id, REPLACE ( scsa.application_scope_id, ',', ',' ) ) > 0
)
END
ORDER BY
scsa.application_scope_id ASC SEPARATOR ', '
) AS scopeOfApplication,
CASE
WHEN floating_bar_style = 1 THEN
'常规样式'
WHEN floating_bar_style = 2 THEN
'含网站导航'
WHEN floating_bar_style = 3 THEN
'英文字母'
END AS templateName
FROM
sys_footer_setup s
INNER JOIN sys_user u ON u.id = s.editor_id
LEFT JOIN sys_footer_setup_scope_of_application scsa ON s.id = scsa.footer_id
WHERE
1 =1
<if test="req.siteId != null">
AND s.site_id = #{req.siteId}
</if>
<if test="req.search != null and req.search != ''">
AND s.scheme_name LIKE CONCAT('%', #{req.search}, '%')
</if>
GROUP BY
s.id
ORDER BY
s.id DESC
</select>
</mapper>

@ -0,0 +1,17 @@
<?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.SysFooterSetupScopeOfApplicationMapper">
<select id="checkBoundByColumnId" resultType="java.lang.Integer">
SELECT
footer_id
FROM
sys_footer_setup_scope_of_application
WHERE
FIND_IN_SET(
application_scope_id,
#{columnId} )
GROUP BY
footer_id
</select>
</mapper>

@ -0,0 +1,17 @@
package com.huoran.iasf.service;
import com.huoran.iasf.entity.SysFooterSetupScopeOfApplication;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 页脚应用范围 服务类
* </p>
*
* @author cheney
* @since 2024-06-07
*/
public interface SysFooterSetupScopeOfApplicationService extends IService<SysFooterSetupScopeOfApplication> {
void deleteTheRangeBasedOnTheFooterId(Integer id);
}

@ -0,0 +1,23 @@
package com.huoran.iasf.service;
import com.huoran.iasf.common.utils.R;
import com.huoran.iasf.entity.SysFooterSetup;
import com.baomidou.mybatisplus.extension.service.IService;
import com.huoran.iasf.vo.req.SuspensionBarListPagingReq;
/**
* <p>
* 页脚配置 服务类
* </p>
*
* @author cheney
* @since 2024-06-07
*/
public interface SysFooterSetupService extends IService<SysFooterSetup> {
R footerList(SuspensionBarListPagingReq sysFloatingColumnScheme);
R checkEnableOrDisable(Integer id, Integer isDisable);
R showTheFooterAccordingToTheColumn(String columnId);
}

@ -0,0 +1,28 @@
package com.huoran.iasf.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huoran.iasf.entity.SysFloatingColumnSchemeScopeOfApplication;
import com.huoran.iasf.entity.SysFooterSetupScopeOfApplication;
import com.huoran.iasf.mapper.SysFooterSetupScopeOfApplicationMapper;
import com.huoran.iasf.service.SysFooterSetupScopeOfApplicationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 页脚应用范围 服务实现类
* </p>
*
* @author cheney
* @since 2024-06-07
*/
@Service
public class SysFooterSetupScopeOfApplicationServiceImpl extends ServiceImpl<SysFooterSetupScopeOfApplicationMapper, SysFooterSetupScopeOfApplication> implements SysFooterSetupScopeOfApplicationService {
@Override
public void deleteTheRangeBasedOnTheFooterId(Integer id) {
QueryWrapper<SysFooterSetupScopeOfApplication> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("footer_id", id);
this.remove(queryWrapper);
}
}

@ -0,0 +1,202 @@
package com.huoran.iasf.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.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.FooterListVO;
import com.huoran.iasf.vo.req.SuspensionBarListPagingReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 页脚配置 服务实现类
* </p>
*
* @author cheney
* @since 2024-06-07
*/
@Service
public class SysFooterSetupServiceImpl extends ServiceImpl<SysFooterSetupMapper, SysFooterSetup> implements SysFooterSetupService {
@Resource
private SysFooterSetupScopeOfApplicationMapper scopeOfApplicationMapper;
@Autowired
public SysColumnMapper columnMapper;
@Override
public R footerList(SuspensionBarListPagingReq sysFloatingColumnScheme) {
Page<FooterListVO> page = new Page<FooterListVO>(sysFloatingColumnScheme.getPageNum(), sysFloatingColumnScheme.getPageSize());
IPage<FooterListVO> pageList = baseMapper.footerList(page, sysFloatingColumnScheme);
return R.success(pageList);
}
@Override
public R checkEnableOrDisable(Integer id, Integer enable) {
SysFooterSetup scheme = baseMapper.selectById(id);
if (scheme == null) {
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("当前站点已存在启用的悬浮栏方案,启用新方案将会覆盖原有设置,请确认是否继续?");
}
} else { // 非全局悬浮栏启用逻辑
// 检查是否存在启用的全局悬浮栏
if (existsEnabledGlobal(siteId)) {
return R.fail("当前已启用全局悬浮栏,无法直接启用部分应用的悬浮栏,请先禁用全局悬浮栏!");
}
// 检查与其它部分应用悬浮栏的冲突
if (hasOverlapWithOtherEnabled(id, siteId)) {
return R.fail(generateConflictMessage(id, siteId, enable));
}
}
} else if (enable == 1) { // 禁用操作逻辑
// 禁用操作直接允许,无需特殊检查
} else {
return R.fail("无效的操作类型");
}
// 如果没有冲突,直接返回成功提示
return R.success("操作可执行");
}
@Override
public R showTheFooterAccordingToTheColumn(String columnId) {
// 获取栏目信息,提前返回错误信息如果栏目不存在
SysColumn column = columnMapper.selectById(columnId);
if (column == null) {
return R.fail("未找到该栏目");
}
LambdaQueryWrapper<SysFooterSetup> queryWrapper = new LambdaQueryWrapper<SysFooterSetup>()
.eq(SysFooterSetup::getSiteId, column.getSiteId())
.eq(SysFooterSetup::getIsDisable, 0)
.eq(SysFooterSetup::getStatus, 1);
// 查询当前站点下已启用且已发布的悬浮栏方案
List<SysFooterSetup> floatingColumnSchemeList = baseMapper.selectList(queryWrapper);
// 检查是否存在全局启用的悬浮栏方案,存在则直接返回
Optional<SysFooterSetup> globalSetupOptional = floatingColumnSchemeList.stream()
.filter(setup -> setup.getIsGlobal() == 1)
.findFirst();
if (globalSetupOptional.isPresent()) {
return R.success(globalSetupOptional.get());
}
// 如果没有全局方案,检查当前栏目绑定的悬浮栏方案
List<Integer> boundSetupIds = scopeOfApplicationMapper.checkBoundByColumnId(columnId);
if (!boundSetupIds.isEmpty()) {
// 根据绑定的ID列表查询启用的悬浮栏方案
List<SysFooterSetup> setupsForColumn = baseMapper.selectList(
new LambdaQueryWrapper<SysFooterSetup>()
.in(SysFooterSetup::getId, boundSetupIds)
.eq(SysFooterSetup::getIsDisable, 0)
);
return R.success(setupsForColumn);
}
return R.success(Collections.emptyList());
}
/**
* 检查当前悬浮栏方案与已启用方案是否有重叠
*
* @param id 悬浮栏方案ID
* @return 是否有重叠
*/
private boolean hasOverlapWithOtherEnabled(Integer id, Integer siteId) {
// 获取当前要检查的方案的应用范围
List<SysFooterSetupScopeOfApplication> currentScopes = scopeOfApplicationMapper.selectList(new LambdaQueryWrapper<SysFooterSetupScopeOfApplication>().eq(SysFooterSetupScopeOfApplication::getFooterId, id));
if (currentScopes.isEmpty()) {
return false; // 当前方案无应用范围,自然无重叠
}
Set<Integer> currentScopeIds = currentScopes.stream().flatMap(scope -> Arrays.stream(scope.getApplicationScopeId().split(","))).map(Integer::parseInt).collect(Collectors.toSet());
// 构造查询条件,确保比较的方案属于同一个站点
String sqlInCondition = "SELECT id FROM sys_footer_setup WHERE is_disable = 0 AND site_id = " + siteId;
// 查询所有启用且ID不等于当前id且属于相同站点的悬浮栏方案的应用范围
List<SysFooterSetupScopeOfApplication> enabledScopes = scopeOfApplicationMapper.selectList(new LambdaQueryWrapper<SysFooterSetupScopeOfApplication>().ne(SysFooterSetupScopeOfApplication::getFooterId, id).inSql(SysFooterSetupScopeOfApplication::getFooterId, sqlInCondition));
// 检查是否有重叠
for (SysFooterSetupScopeOfApplication enabledScope : enabledScopes) {
Set<Integer> enabledScopeIds = Arrays.stream(enabledScope.getApplicationScopeId().split(",")).map(Integer::parseInt).collect(Collectors.toSet());
if (!Collections.disjoint(currentScopeIds, enabledScopeIds)) {
return true; // 存在重叠
}
}
return false; // 无重叠
}
/**
* 生成冲突提示信息展示冲突的栏目名称
*
* @param id 悬浮栏方案ID
* @return 冲突提示信息
*/
private String generateConflictMessage(Integer id, Integer siteId, Integer enableAction) {
// 调用 hasOverlapWithOtherEnabled 确认是否有重叠
if (!hasOverlapWithOtherEnabled(id, siteId)) {
return ""; // 无冲突则返回空字符串
}
// 获取当前方案冲突的范围ID
List<SysFooterSetupScopeOfApplication> conflictingScopes = scopeOfApplicationMapper.selectList(new LambdaQueryWrapper<SysFooterSetupScopeOfApplication>().eq(SysFooterSetupScopeOfApplication::getFooterId, id));
Set<Integer> conflictScopeIds = conflictingScopes.stream().flatMap(scope -> Arrays.stream(scope.getApplicationScopeId().split(","))).map(Integer::parseInt).collect(Collectors.toSet());
// 查询冲突范围对应的栏目名称
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) + "”存在悬浮栏配置冲突,请注意操作可能影响这些栏目的现有悬浮栏设置。";
} else {
return "未知的操作类型";
}
}
private boolean existsEnabledGlobal(Integer siteId) {
QueryWrapper<SysFooterSetup> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("is_global", 1);
queryWrapper.eq("is_disable", 0);
queryWrapper.eq("site_id", siteId);
return !baseMapper.selectList(queryWrapper).isEmpty();
}
}

@ -0,0 +1,62 @@
package com.huoran.iasf.vo;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* <p>
* 页脚
* </p>
*
* @author cheney
* @since 2024-06-04
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "SysFloatingColumnScheme对象", description = "页脚")
public class FooterListVO {
@ApiModelProperty(value = "页脚主键")
private Integer footerId;
@ApiModelProperty(value = "页脚名称")
private String footerName;
@ApiModelProperty(value = "应用范围")
private String scopeOfApplication;
@ApiModelProperty(value = "悬浮栏样式id(前端自定义1/2/3)")
private Integer floatingBarStyle;
@ApiModelProperty(value = "模板名称")
private String templateName;
@ApiModelProperty(value = "是否禁用(0默认,0启用 1禁用)")
private Integer isDisable;
@ApiModelProperty(value = "编辑人id", hidden = true)
private Integer editorId;
@ApiModelProperty(value = "编辑人名称")
private String editorSName;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
}

@ -61,7 +61,7 @@ public class CodeGenerator {
// 5、策略配置 // 5、策略配置
StrategyConfig strategy = new StrategyConfig(); StrategyConfig strategy = new StrategyConfig();
strategy.setInclude("sys_floating_column_scheme","sys_floating_column_scheme_module","sys_floating_column_scheme_scope_of_application"); strategy.setInclude("sys_footer_setup","sys_footer_setup_scope_of_application");
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
// strategy.setTablePrefix("sys_"); //生成实体时去掉表前缀 // strategy.setTablePrefix("sys_"); //生成实体时去掉表前缀

Loading…
Cancel
Save