diff --git a/pom.xml b/pom.xml index 8f3f0a2..33ca11b 100644 --- a/pom.xml +++ b/pom.xml @@ -282,6 +282,14 @@ true + + org.apache.maven.plugins + maven-compiler-plugin + + 9 + 9 + + diff --git a/src/main/java/com/huoran/iasf/controller/LogoController.java b/src/main/java/com/huoran/iasf/controller/LogoController.java new file mode 100644 index 0000000..d8e0dfc --- /dev/null +++ b/src/main/java/com/huoran/iasf/controller/LogoController.java @@ -0,0 +1,79 @@ +package com.huoran.iasf.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.huoran.iasf.common.utils.R; +import com.huoran.iasf.entity.Logo; +import com.huoran.iasf.service.LogoService; +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; + +/** + * @描述:系统logo设置控制类 + * @作者: Rong + * @日期: 2024-07-01 + */ +@RestController +@RequestMapping("/LogoService/Logo") +@Api(value = "系统logo设置:LogoController", tags = "系统logo设置:系统logo设置") +public class LogoController { + + @Autowired + public LogoService service; + + + /** + * 保存或更新系统logo设置记录 + * 如果ID为空,则执行保存操作;如果ID有值,则视为更新操作。 + * + * @param logo 要保存或更新的系统logo设置对象 + * @return R 结果对象,包含操作状态信息 + */ + @PostMapping("/saveOrUpdate") + @ApiOperation(value = "保存或更新系统logo设置记录", response = Logo.class) + public R saveOrUpdate(@RequestBody @ApiParam(name = "系统logo设置对象", value = "包含系统logo设置详细信息,若id不存在则新建,否则视为更新", required = true) Logo logo) { + + if (logo.getId() == null) { + // 保存操作 + boolean addState = service.save(logo); + return addState ? R.success(logo.getId()) : R.fail("新增失败"); + } else { + // 更新操作 + boolean updateState = service.updateById(logo); + return updateState ? R.success() : R.fail("编辑失败"); + } + } + + + @PostMapping("/findById") + @ApiOperation(value = "查询详情", response = Logo.class) + public R findById(@ApiParam(name = "siteId", value = "主键", required = true) @RequestParam Integer siteId) { + //根据站点id查询站点信息 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("site_id", siteId); + Logo logo = service.getOne(queryWrapper); + return R.success(logo); + } + + + + /*@PostMapping("/update") + @ApiOperation(value = "修改", response = Logo.class) + public R update(@RequestBody @ApiParam(name = "系统logo设置对象", value = "传入json格式", required = true) Logo logo) { + boolean updateState = service.updateById(logo); + return updateState ? R.success() : R.fail("编辑失败"); + }*/ + + + @PostMapping("/batchDeletion") + @ApiOperation(value = "批量删除", response = Logo.class) + public R batchDeletion(@ApiParam(name = "ids", value = "多个主键", required = true) @RequestParam List ids) { + boolean delState = service.removeByIds(ids); + return delState ? R.success() : R.fail("删除失败"); + } +} + diff --git a/src/main/java/com/huoran/iasf/entity/Logo.java b/src/main/java/com/huoran/iasf/entity/Logo.java new file mode 100644 index 0000000..b2497aa --- /dev/null +++ b/src/main/java/com/huoran/iasf/entity/Logo.java @@ -0,0 +1,38 @@ +package com.huoran.iasf.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @描述:系统logo设置 + * @作者: Rong + * @日期: 2024-07-01 + */ +@Data +@ApiModel(value = "系统logo设置") +@TableName("sys_logo") +public class Logo implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + @ApiModelProperty(value = "主键") + private Integer id; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "图标") + private String logoUrl; + + @ApiModelProperty(value = "站点id") + private Integer siteId; + + +} \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/mapper/LogoMapper.java b/src/main/java/com/huoran/iasf/mapper/LogoMapper.java new file mode 100644 index 0000000..7449213 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/LogoMapper.java @@ -0,0 +1,16 @@ +package com.huoran.iasf.mapper; + +import org.apache.ibatis.annotations.Mapper; + +import com.huoran.iasf.entity.Logo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @描述:系统logo设置 Mapper 接口 + * @作者: Rong + * @日期: 2024-07-01 + */ +@Mapper +public interface LogoMapper extends BaseMapper { + + } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/service/LogoService.java b/src/main/java/com/huoran/iasf/service/LogoService.java new file mode 100644 index 0000000..2064dfd --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/LogoService.java @@ -0,0 +1,13 @@ +package com.huoran.iasf.service; + +import com.huoran.iasf.entity.Logo; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * @描述:系统logo设置 service接口 + * @作者: Rong + * @日期: 2024-07-01 + */ +public interface LogoService extends IService { + +} \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/service/impl/LogoServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/LogoServiceImpl.java new file mode 100644 index 0000000..290df09 --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/impl/LogoServiceImpl.java @@ -0,0 +1,25 @@ +package com.huoran.iasf.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.huoran.iasf.entity.Logo; +import com.huoran.iasf.mapper.LogoMapper; +import com.huoran.iasf.service.LogoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @描述:系统logo设置 服务类 + * @作者: Rong + * @日期: 2024-07-01 + */ +@Service +public class LogoServiceImpl extends ServiceImpl implements LogoService { + + @Autowired + private LogoMapper mapper; + + +} + + + diff --git a/src/main/java/com/huoran/iasf/service/impl/SysFloatingColumnSchemeServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysFloatingColumnSchemeServiceImpl.java index 6653fca..9007c81 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysFloatingColumnSchemeServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysFloatingColumnSchemeServiceImpl.java @@ -352,25 +352,47 @@ public class SysFloatingColumnSchemeServiceImpl extends ServiceImpl conflictingScopes = scopeOfApplicationMapper.selectList(new LambdaQueryWrapper().eq(SysFloatingColumnSchemeScopeOfApplication::getFloatingBarSchemeId, schemeId)); - - Set conflictScopeIds = conflictingScopes.stream().flatMap(scope -> Arrays.stream(scope.getApplicationScopeId().split(","))).map(Integer::parseInt).collect(Collectors.toSet()); - - // 查询冲突范围对应的栏目名称 - List conflictingScopeNames = columnMapper.selectList(new LambdaQueryWrapper().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) + "”存在悬浮栏配置冲突,请注意操作可能影响这些栏目的现有悬浮栏设置。"; + // 获取所有悬浮栏方案的范围ID + List allScopes = scopeOfApplicationMapper.selectList(null); + Map> allScopeIdMap = allScopes.stream() + .collect(Collectors.groupingBy( + SysFloatingColumnSchemeScopeOfApplication::getFloatingBarSchemeId, + Collectors.flatMapping(scope -> Arrays.stream(scope.getApplicationScopeId().split(",")), Collectors.mapping(Integer::parseInt, Collectors.toSet())) + )); + + // 获取当前方案的范围ID + Set currentScopeIds = allScopeIdMap.getOrDefault(schemeId, Collections.emptySet()); + + // 找出与其他悬浮栏方案重复的范围ID + Set duplicateScopeIds = allScopeIdMap.values().stream() + .filter(ids -> !ids.equals(currentScopeIds) && !ids.isEmpty()) + .flatMap(Set::stream) + .filter(currentScopeIds::contains) + .collect(Collectors.toSet()); + + // 查询重复范围对应的栏目名称 + List duplicateScopeNames = columnMapper.selectList(new LambdaQueryWrapper().in(SysColumn::getId, duplicateScopeIds)) + .stream() + .map(SysColumn::getColumnName) + .collect(Collectors.toList()); + + // 构建并返回提示信息 + if (!duplicateScopeNames.isEmpty()) { + String scopesJoined = String.join("”, “", duplicateScopeNames); + if (enableAction == 0) { // 启用操作 + return "栏目:“" + scopesJoined + "”已存在于其他悬浮栏配置中,请处理重复后再尝试启用。"; + } else if (enableAction == 1) { // 禁用操作 + return "注意:禁用操作可能会影响到栏目“" + scopesJoined + "”在其他悬浮栏的配置,请谨慎操作。"; + } else { + return "未知的操作类型"; + } } else { - return "未知的操作类型"; + return ""; // 逻辑上这里应该不会到达,因为之前已确认有重叠,但为了完整性保留 } } + // 新增方法:统计当前站点下已启用的全局悬浮栏数量 public Integer countGlobalEnabled(Integer siteId) { return baseMapper.selectCount(new LambdaQueryWrapper().eq(SysFloatingColumnScheme::getSiteId, siteId).eq(SysFloatingColumnScheme::getIsGlobal, 1).eq(SysFloatingColumnScheme::getIsDisable, false));