logo设置提交

禁启用范围重复提示优化
master
rong.liu 5 months ago
parent 8efcdef1c9
commit 321db56def
  1. 8
      pom.xml
  2. 79
      src/main/java/com/huoran/iasf/controller/LogoController.java
  3. 38
      src/main/java/com/huoran/iasf/entity/Logo.java
  4. 16
      src/main/java/com/huoran/iasf/mapper/LogoMapper.java
  5. 13
      src/main/java/com/huoran/iasf/service/LogoService.java
  6. 25
      src/main/java/com/huoran/iasf/service/impl/LogoServiceImpl.java
  7. 44
      src/main/java/com/huoran/iasf/service/impl/SysFloatingColumnSchemeServiceImpl.java

@ -282,6 +282,14 @@
<skipTests>true</skipTests> <skipTests>true</skipTests>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins> </plugins>
<resources> <resources>

@ -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<Logo> 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<Integer> ids) {
boolean delState = service.removeByIds(ids);
return delState ? R.success() : R.fail("删除失败");
}
}

@ -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;
}

@ -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<Logo> {
}

@ -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<Logo> {
}

@ -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<LogoMapper, Logo> implements LogoService {
@Autowired
private LogoMapper mapper;
}

@ -352,25 +352,47 @@ public class SysFloatingColumnSchemeServiceImpl extends ServiceImpl<SysFloatingC
return ""; // 无冲突则返回空字符串 return ""; // 无冲突则返回空字符串
} }
// 获取当前方案冲突的范围ID // 获取所有悬浮栏方案的范围ID
List<SysFloatingColumnSchemeScopeOfApplication> conflictingScopes = scopeOfApplicationMapper.selectList(new LambdaQueryWrapper<SysFloatingColumnSchemeScopeOfApplication>().eq(SysFloatingColumnSchemeScopeOfApplication::getFloatingBarSchemeId, schemeId)); List<SysFloatingColumnSchemeScopeOfApplication> allScopes = scopeOfApplicationMapper.selectList(null);
Map<Integer, Set<Integer>> allScopeIdMap = allScopes.stream()
Set<Integer> conflictScopeIds = conflictingScopes.stream().flatMap(scope -> Arrays.stream(scope.getApplicationScopeId().split(","))).map(Integer::parseInt).collect(Collectors.toSet()); .collect(Collectors.groupingBy(
SysFloatingColumnSchemeScopeOfApplication::getFloatingBarSchemeId,
// 查询冲突范围对应的栏目名称 Collectors.flatMapping(scope -> Arrays.stream(scope.getApplicationScopeId().split(",")), Collectors.mapping(Integer::parseInt, Collectors.toSet()))
List<String> conflictingScopeNames = columnMapper.selectList(new LambdaQueryWrapper<SysColumn>().in(SysColumn::getId, conflictScopeIds)).stream().map(SysColumn::getColumnName).collect(Collectors.toList()); ));
// 根据操作类型调整提示信息() // 获取当前方案的范围ID
Set<Integer> currentScopeIds = allScopeIdMap.getOrDefault(schemeId, Collections.emptySet());
// 找出与其他悬浮栏方案重复的范围ID
Set<Integer> duplicateScopeIds = allScopeIdMap.values().stream()
.filter(ids -> !ids.equals(currentScopeIds) && !ids.isEmpty())
.flatMap(Set::stream)
.filter(currentScopeIds::contains)
.collect(Collectors.toSet());
// 查询重复范围对应的栏目名称
List<String> duplicateScopeNames = columnMapper.selectList(new LambdaQueryWrapper<SysColumn>().in(SysColumn::getId, duplicateScopeIds))
.stream()
.map(SysColumn::getColumnName)
.collect(Collectors.toList());
// 构建并返回提示信息
if (!duplicateScopeNames.isEmpty()) {
String scopesJoined = String.join("”, “", duplicateScopeNames);
if (enableAction == 0) { // 启用操作 if (enableAction == 0) { // 启用操作
return "“" + String.join("”, “", conflictingScopeNames) + "”栏目已设置有悬浮栏,请移除后再试。。"; return "栏目:“" + scopesJoined + "”已存在于其他悬浮栏配置中,请处理重复后再尝试启用。";
} else if (enableAction == 1) { // 禁用操作 } else if (enableAction == 1) { // 禁用操作
return "“" + String.join("”, “", conflictingScopeNames) + "”存在悬浮栏配置冲突,请注意操作可能影响这些栏目的现有悬浮栏设置。"; return "注意:禁用操作可能会影响到栏目“" + scopesJoined + "”在其他悬浮栏的配置,请谨慎操作。";
} else { } else {
return "未知的操作类型"; return "未知的操作类型";
} }
} else {
return ""; // 逻辑上这里应该不会到达,因为之前已确认有重叠,但为了完整性保留
}
} }
// 新增方法:统计当前站点下已启用的全局悬浮栏数量 // 新增方法:统计当前站点下已启用的全局悬浮栏数量
public Integer countGlobalEnabled(Integer siteId) { public Integer countGlobalEnabled(Integer siteId) {
return baseMapper.selectCount(new LambdaQueryWrapper<SysFloatingColumnScheme>().eq(SysFloatingColumnScheme::getSiteId, siteId).eq(SysFloatingColumnScheme::getIsGlobal, 1).eq(SysFloatingColumnScheme::getIsDisable, false)); return baseMapper.selectCount(new LambdaQueryWrapper<SysFloatingColumnScheme>().eq(SysFloatingColumnScheme::getSiteId, siteId).eq(SysFloatingColumnScheme::getIsGlobal, 1).eq(SysFloatingColumnScheme::getIsDisable, false));

Loading…
Cancel
Save