代码注释补充,冗余删除,mapper找不到报错解决等

This commit is contained in:
mi9688
2024-10-22 11:06:15 +08:00
parent 655e22579c
commit 135a5e295d
22 changed files with 266 additions and 418 deletions

View File

@ -1,10 +1,10 @@
package com.fastbee.ggroup.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fastbee.ggroup.domain.GGroups;
import com.fastbee.ggroup.domain.vo.GGroupSiteVo;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@ -13,9 +13,9 @@ import java.util.List;
* 组Mapper接口
*
* @author kerwincui
* @date 2024-09-27
* @date 2024-09-27
*/
@Mapper
public interface GGroupsMapper extends MPJBaseMapper<GGroups>
{
/**
@ -24,7 +24,7 @@ public interface GGroupsMapper extends MPJBaseMapper<GGroups>
* @param id 组主键
* @return 组
*/
public GGroups selectGGroupsById(Long id);
GGroups selectGGroupsById(Long id);
/**
* 查询组列表
@ -32,7 +32,7 @@ public interface GGroupsMapper extends MPJBaseMapper<GGroups>
* @param gGroups 组
* @return 组集合
*/
public List<GGroups> selectGGroupsList(GGroups gGroups);
List<GGroups> selectGGroupsList(GGroups gGroups);
@Select({
@ -63,7 +63,7 @@ public interface GGroupsMapper extends MPJBaseMapper<GGroups>
* @param gGroups 组
* @return 结果
*/
public int insertGGroups(GGroups gGroups);
int insertGGroups(GGroups gGroups);
/**
* 修改组
@ -71,7 +71,7 @@ public interface GGroupsMapper extends MPJBaseMapper<GGroups>
* @param gGroups 组
* @return 结果
*/
public int updateGGroups(GGroups gGroups);
int updateGGroups(GGroups gGroups);
/**
* 删除组
@ -79,7 +79,7 @@ public interface GGroupsMapper extends MPJBaseMapper<GGroups>
* @param id 组主键
* @return 结果
*/
public int deleteGGroupsById(Long id);
int deleteGGroupsById(Long id);
/**
* 批量删除组
@ -87,5 +87,5 @@ public interface GGroupsMapper extends MPJBaseMapper<GGroups>
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteGGroupsByIds(Long[] ids);
int deleteGGroupsByIds(Long[] ids);
}

View File

@ -3,13 +3,15 @@ package com.fastbee.ggroup.mapper;
import java.util.List;
import com.fastbee.ggroup.domain.GLegend;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 图例Mapper接口
*
* @author kerwincui
* @date 2024-10-08
* &#064;date 2024-10-08
*/
@Mapper
public interface GLegendMapper extends MPJBaseMapper<GLegend>
{
/**
@ -18,7 +20,7 @@ public interface GLegendMapper extends MPJBaseMapper<GLegend>
* @param id 图例主键
* @return 图例
*/
public GLegend selectGLegendById(Long id);
GLegend selectGLegendById(Long id);
/**
* 查询图例列表
@ -26,7 +28,7 @@ public interface GLegendMapper extends MPJBaseMapper<GLegend>
* @param gLegend 图例
* @return 图例集合
*/
public List<GLegend> selectGLegendList(GLegend gLegend);
List<GLegend> selectGLegendList(GLegend gLegend);
/**
* 新增图例
@ -34,7 +36,7 @@ public interface GLegendMapper extends MPJBaseMapper<GLegend>
* @param gLegend 图例
* @return 结果
*/
public int insertGLegend(GLegend gLegend);
int insertGLegend(GLegend gLegend);
/**
* 修改图例
@ -42,7 +44,7 @@ public interface GLegendMapper extends MPJBaseMapper<GLegend>
* @param gLegend 图例
* @return 结果
*/
public int updateGLegend(GLegend gLegend);
int updateGLegend(GLegend gLegend);
/**
* 删除图例
@ -50,7 +52,7 @@ public interface GLegendMapper extends MPJBaseMapper<GLegend>
* @param id 图例主键
* @return 结果
*/
public int deleteGLegendById(Long id);
int deleteGLegendById(Long id);
/**
* 批量删除图例
@ -58,6 +60,6 @@ public interface GLegendMapper extends MPJBaseMapper<GLegend>
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteGLegendByIds(Long[] ids);
int deleteGLegendByIds(Long[] ids);
}

View File

@ -1,19 +1,19 @@
package com.fastbee.ggroup.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fastbee.ggroup.domain.GSiteGroups;
import com.fastbee.ggroup.domain.dto.GGroupSiteDto;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
/**
* 站点组关系Mapper接口
*
* @author kerwincui
* @date 2024-09-30
* &#064;date 2024-09-30
*/
@Mapper
public interface GSiteGroupsMapper extends MPJBaseMapper<GSiteGroups>
{
@ -23,7 +23,7 @@ public interface GSiteGroupsMapper extends MPJBaseMapper<GSiteGroups>
* @param id 站点组关系主键
* @return 站点组关系
*/
public GSiteGroups selectGSiteGroupsById(Long id);
GSiteGroups selectGSiteGroupsById(Long id);
/**
* 查询站点组关系列表
@ -31,7 +31,7 @@ public interface GSiteGroupsMapper extends MPJBaseMapper<GSiteGroups>
* @param gSiteGroups 站点组关系
* @return 站点组关系集合
*/
public List<GSiteGroups> selectGSiteGroupsList(GSiteGroups gSiteGroups);
List<GSiteGroups> selectGSiteGroupsList(GSiteGroups gSiteGroups);
/**
* 新增站点组关系
@ -41,7 +41,7 @@ public interface GSiteGroupsMapper extends MPJBaseMapper<GSiteGroups>
*/
@Insert("insert into g_site_groups (site_id, parent_id, project_id,order_num) " +
"value (#{siteId},#{parentId},#{projectId},#{orderNum})")
public int insertGSiteGroups(GGroupSiteDto gSiteGroups);
int insertGSiteGroups(GGroupSiteDto gSiteGroups);
/**
* 修改站点组关系
@ -49,7 +49,7 @@ public interface GSiteGroupsMapper extends MPJBaseMapper<GSiteGroups>
* @param gSiteGroups 站点组关系
* @return 结果
*/
public int updateGSiteGroups(GSiteGroups gSiteGroups);
int updateGSiteGroups(GSiteGroups gSiteGroups);
/**
* 删除站点组关系
@ -57,7 +57,7 @@ public interface GSiteGroupsMapper extends MPJBaseMapper<GSiteGroups>
* @param id 站点组关系主键
* @return 结果
*/
public int deleteGSiteGroupsById(Long id);
int deleteGSiteGroupsById(Long id);
/**
* 批量删除站点组关系
@ -65,5 +65,5 @@ public interface GSiteGroupsMapper extends MPJBaseMapper<GSiteGroups>
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteGSiteGroupsByIds(Long[] ids);
int deleteGSiteGroupsByIds(Long[] ids);
}

View File

@ -4,13 +4,15 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fastbee.ggroup.domain.GSiteInfo;
import org.apache.ibatis.annotations.Mapper;
/**
* 站点基础信息Mapper接口
*
* @author kerwincui
* @date 2024-10-10
* &#064;date 2024-10-10
*/
@Mapper
public interface GSiteInfoMapper extends BaseMapper<GSiteInfo>
{
/**
@ -19,7 +21,7 @@ public interface GSiteInfoMapper extends BaseMapper<GSiteInfo>
* @param id 站点基础信息主键
* @return 站点基础信息
*/
public GSiteInfo selectGSiteInfoById(Long id);
GSiteInfo selectGSiteInfoById(Long id);
/**
* 查询站点基础信息列表
@ -27,7 +29,7 @@ public interface GSiteInfoMapper extends BaseMapper<GSiteInfo>
* @param gSiteInfo 站点基础信息
* @return 站点基础信息集合
*/
public List<GSiteInfo> selectGSiteInfoList(GSiteInfo gSiteInfo);
List<GSiteInfo> selectGSiteInfoList(GSiteInfo gSiteInfo);
/**
* 新增站点基础信息
@ -35,7 +37,7 @@ public interface GSiteInfoMapper extends BaseMapper<GSiteInfo>
* @param gSiteInfo 站点基础信息
* @return 结果
*/
public int insertGSiteInfo(GSiteInfo gSiteInfo);
int insertGSiteInfo(GSiteInfo gSiteInfo);
/**
* 修改站点基础信息
@ -43,7 +45,7 @@ public interface GSiteInfoMapper extends BaseMapper<GSiteInfo>
* @param gSiteInfo 站点基础信息
* @return 结果
*/
public int updateGSiteInfo(GSiteInfo gSiteInfo);
int updateGSiteInfo(GSiteInfo gSiteInfo);
/**
* 删除站点基础信息
@ -51,7 +53,7 @@ public interface GSiteInfoMapper extends BaseMapper<GSiteInfo>
* @param id 站点基础信息主键
* @return 结果
*/
public int deleteGSiteInfoById(Long id);
int deleteGSiteInfoById(Long id);
/**
* 批量删除站点基础信息
@ -59,5 +61,5 @@ public interface GSiteInfoMapper extends BaseMapper<GSiteInfo>
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteGSiteInfoByIds(Long[] ids);
int deleteGSiteInfoByIds(Long[] ids);
}

View File

@ -5,15 +5,16 @@ import java.util.List;
import com.fastbee.ggroup.domain.GSites;
import com.fastbee.ggroup.domain.dto.GGroupSiteDto;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 站点Mapper接口
*
* @author kerwincui
* @date 2024-09-29
* &#064;date 2024-09-29
*/
@Mapper
public interface GSitesMapper extends MPJBaseMapper<GSites>
{
/**
@ -23,7 +24,7 @@ public interface GSitesMapper extends MPJBaseMapper<GSites>
* @return 站点
*/
public GSites selectGSitesById(Long id);
GSites selectGSitesById(Long id);
/**
* 查询站点列表
@ -31,7 +32,7 @@ public interface GSitesMapper extends MPJBaseMapper<GSites>
* @param gSites 站点
* @return 站点集合
*/
public List<GSites> selectGSitesList(GSites gSites);
List<GSites> selectGSitesList(GSites gSites);
/**
* 新增站点
@ -39,7 +40,7 @@ public interface GSitesMapper extends MPJBaseMapper<GSites>
* @param gGroupSiteDto 站点
* @return 结果
*/
public int insertGSites(GGroupSiteDto gGroupSiteDto);
int insertGSites(GGroupSiteDto gGroupSiteDto);
/**
* 修改站点
@ -47,7 +48,7 @@ public interface GSitesMapper extends MPJBaseMapper<GSites>
* @param gSites 站点
* @return 结果
*/
public int updateGSites(GSites gSites);
int updateGSites(GSites gSites);
/**
* 删除站点
@ -56,8 +57,7 @@ public interface GSitesMapper extends MPJBaseMapper<GSites>
* @return 结果
*/
// @Delete("delete from g_site_groups where id= #{id}")
public int deleteGSitesById(@Param("id") Long id);
int deleteGSitesById(@Param("id") Long id);
/**
* 批量删除站点
@ -65,5 +65,5 @@ public interface GSitesMapper extends MPJBaseMapper<GSites>
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteGSitesByIds(Long[] ids);
int deleteGSitesByIds(Long[] ids);
}

View File

@ -12,63 +12,43 @@ import java.util.List;
* 组Service接口
*
* @author kerwincui
* @date 2024-09-27
* &#064;date 2024-09-27
*/
public interface IGGroupsService
{
/**
* 查询组
*
* @param id 组主键
* @return 组
* 根据id查询组详情
*/
public GGroups selectGGroupsById(Long id);
GGroups selectGGroupsById(Long id);
/**
* 查询组树状列表
*
* @param gGroups 组
* @return 组集合
* 查询组树状列表(不带叶子节点)
*/
public List<GGroups> selectGGroupsList(GGroups gGroups);
List<GGroups> selectGGroupsList(GGroups gGroups);
/**
* 查询组下面的站点列表
*/
List<GGroupSiteVo> selectGGroupsListSites(GGroups gGroups);
public List<GGroupSiteVo> selectGGroupsListSites(GGroups gGroups);
/**
* 新增组
*
* @param gGroups 组
* @return 结果
*/
public int insertGGroups(GGroups gGroups);
int insertGGroups(GGroups gGroups);
/**
* 修改组
*
* @param gGroups 组
* @return 结果
*/
public int updateGGroups(GGroups gGroups);
int updateGGroups(GGroups gGroups);
/**
* 批量删除组
*
* @param ids 需要删除的组主键集合
* @return 结果
* 删除组
*/
public int deleteGGroupsByIds(Long[] ids);
int deleteGGroupsById(Long id);
/**
* 删除组信息
*
* @param id 组主键
* @return 结果
*/
public int deleteGGroupsById(Long id);
/**
* 查询组和站点(叶子节点)的树状结构
* @param gGroups 组
* @return 列表
* 查询组和站点(叶子节点)的树状结构组下面会有组或者站点
*/
List<?> selectGGroupsAndSitesList(GGroups gGroups);

View File

@ -3,69 +3,45 @@ package com.fastbee.ggroup.service;
import java.util.List;
import com.fastbee.ggroup.domain.GLegend;
import com.fastbee.ggroup.domain.dto.GLegendUpdateDto;
import com.fastbee.ggroup.domain.dto.GLegendDto;
/**
* 图例Service接口
*
* @author kerwincui
* @date 2024-10-08
* &#064;date 2024-10-08
*/
public interface IGLegendService
{
/**
* 查询图例
*
* @param id 图例主键
* @return 图例
*/
public GLegend selectGLegendById(Long id);
GLegend selectGLegendById(Long id);
/**
* 查询/搜索图例列表
*
* @param gLegend 图例
* @return 图例集合
*/
public List<GLegend> selectGLegendList(GLegend gLegend);
List<GLegend> selectGLegendList(GLegend gLegend);
/**
* 新增图例
*
* @param gLegend 图例
* @return 结果
*/
public int insertGLegend(GLegend gLegend);
int insertGLegend(GLegend gLegend);
/**
* 修改图例
*
* @param gLegend 图例
* @return 结果
*/
public int updateGLegend(GLegend gLegend);
int updateGLegend(GLegend gLegend);
/**
* 批量删除图例
*
* @param ids 需要删除的图例主键集合
* @return 结果
*/
public int deleteGLegendByIds(Long[] ids);
int deleteGLegendByIds(Long[] ids);
/**
* 删除图例信息
*
* @param id 图例主键
* @return 结果
*/
public int deleteGLegendById(Long id);
/**
* 获取不同类别图例列表
*/
public List<?> getLegendListByCategory();
List<?> getLegendListByCategory();
}

View File

@ -7,7 +7,7 @@ import com.fastbee.ggroup.domain.GSiteInfo;
* 站点基础信息Service接口
*
* @author kerwincui
* @date 2024-10-10
* &#064;date 2024-10-10
*/
public interface IGSiteInfoService
{
@ -17,7 +17,7 @@ public interface IGSiteInfoService
* @param id 站点基础信息主键
* @return 站点基础信息
*/
public GSiteInfo selectGSiteInfoById(Long id);
GSiteInfo selectGSiteInfoById(Long id);
/**
* 查询站点基础信息列表
@ -25,7 +25,7 @@ public interface IGSiteInfoService
* @param gSiteInfo 站点基础信息
* @return 站点基础信息集合
*/
public List<GSiteInfo> selectGSiteInfoList(GSiteInfo gSiteInfo);
List<GSiteInfo> selectGSiteInfoList(GSiteInfo gSiteInfo);
/**
* 新增站点基础信息
@ -33,7 +33,7 @@ public interface IGSiteInfoService
* @param gSiteInfo 站点基础信息
* @return 结果
*/
public int insertGSiteInfo(GSiteInfo gSiteInfo);
int insertGSiteInfo(GSiteInfo gSiteInfo);
/**
* 修改站点基础信息
@ -41,7 +41,7 @@ public interface IGSiteInfoService
* @param gSiteInfo 站点基础信息
* @return 结果
*/
public int updateGSiteInfo(GSiteInfo gSiteInfo);
int updateGSiteInfo(GSiteInfo gSiteInfo);
/**
* 批量删除站点基础信息
@ -49,13 +49,6 @@ public interface IGSiteInfoService
* @param ids 需要删除的站点基础信息主键集合
* @return 结果
*/
public int deleteGSiteInfoByIds(Long[] ids);
int deleteGSiteInfoByIds(Long[] ids);
/**
* 删除站点基础信息信息
*
* @param id 站点基础信息主键
* @return 结果
*/
public int deleteGSiteInfoById(Long id);
}

View File

@ -11,70 +11,47 @@ import com.fastbee.ggroup.domain.dto.GSitesSelectDto;
* 站点Service接口
*
* @author kerwincui
* @date 2024-09-29
* &#064;date 2024-09-29
*/
public interface IGSitesService
{
/**
* 查询站点
*
* @param id 站点主键
* @return 站点
*/
public GSites selectGSitesById(Long id);
GSites selectGSitesById(Long id);
/**
* 查询站点列表
*
* @param gSites 站点
* @return 站点集合
*/
public List<?> selectGSitesList(GSitesSelectDto gSites);
List<GSites> selectGSitesList(GSitesSelectDto gSites);
/**
* 新增站点
*
* @param gGroupSiteDto 站点
* @return 结果
*/
public int insertGSites(GGroupSiteDto gGroupSiteDto);
int insertGSites(GGroupSiteDto gGroupSiteDto);
/**
* 修改站点
*
* @param gSitesEditDto 站点
* @return 结果
*/
public int updateGSites(GSitesEditDto gSitesEditDto);
int updateGSites(GSitesEditDto gSitesEditDto);
/**
* 批量删除站点
*
* @param ids 需要删除的站点主键集合
* @return 结果
*/
public int deleteGSitesByIds(Long[] ids);
int deleteGSitesByIds(Long[] ids);
/**
* 删除站点信息
*
* @param id 站点主键
* @return 结果
*/
public int deleteGSitesById(Long id);
int deleteGSitesById(Long id);
/**
* 站点关联组
*
* @param gGroupSiteRelateDto
* @return
*/
int relateGroup(GGroupSiteRelateDto gGroupSiteRelateDto);
/**
* 搜索站点列表
* @param gSites
* @return
*/
List<GSites> searchGSitesList(GSites gSites);
}

View File

@ -1,7 +1,6 @@
package com.fastbee.ggroup.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.fastbee.common.exception.ServiceException;
import com.fastbee.common.holder.ProjectHolder;
@ -12,11 +11,9 @@ import com.fastbee.ggroup.domain.GSites;
import com.fastbee.ggroup.domain.vo.GGroupSiteVo;
import com.fastbee.ggroup.mapper.GGroupsMapper;
import com.fastbee.ggroup.mapper.GSiteGroupsMapper;
import com.fastbee.ggroup.mapper.GSitesMapper;
import com.fastbee.ggroup.service.IGGroupsService;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@ -32,17 +29,20 @@ import java.util.stream.Collectors;
@Service
public class GGroupsServiceImpl implements IGGroupsService
{
@Autowired
private GGroupsMapper gGroupsMapper;
private final GGroupsMapper gGroupsMapper;
@Autowired
private GSiteGroupsMapper gSiteGroupsMapper;
private final GSiteGroupsMapper gSiteGroupsMapper;
public GGroupsServiceImpl(GGroupsMapper gGroupsMapper, GSiteGroupsMapper gSiteGroupsMapper) {
this.gGroupsMapper = gGroupsMapper;
this.gSiteGroupsMapper = gSiteGroupsMapper;
}
/**
* 查询组
*
* 根据id查询组详情
*
* @param id 组主键
* @return 组
*/
@ -54,7 +54,7 @@ public class GGroupsServiceImpl implements IGGroupsService
/**
* 查询组树状结构列表
* 查询组树状列表(不带叶子节点)
*
* @param gGroups 组
* @return 组
@ -69,7 +69,7 @@ public class GGroupsServiceImpl implements IGGroupsService
GGroups::getProjectId, ProjectHolder.getProjectInfo().getProjectIdList())
.eq(gGroups.getProjectId()!=null, GGroups::getProjectId, gGroups.getProjectId())
.list();
return buildTree(list);
return buildGroupTree(list);
}
/**
@ -91,19 +91,22 @@ public class GGroupsServiceImpl implements IGGroupsService
return gSiteGroupsMapper.selectJoinList(GGroupSiteVo.class,gSiteGroupsMPJLambdaWrapper);
}
private List<GGroups> buildTree(List<GGroups> groups) {
/**
* 构建组树状列表
*/
private List<GGroups> buildGroupTree(List<GGroups> groups) {
Map<Long, GGroups> map = new HashMap<>();
List<GGroups> roots = new ArrayList<>();
for (GGroups group : groups) {
map.put(group.getId(), group);
}
return getgGroups(groups, map, roots);
return combinationGroupsTree(groups, map, roots);
}
/**
* 组合组树状结构列表
*/
private List<GGroups> getgGroups(List<GGroups> groups, Map<Long, GGroups> map, List<GGroups> roots) {
private List<GGroups> combinationGroupsTree(List<GGroups> groups, Map<Long, GGroups> map, List<GGroups> roots) {
for (GGroups group : groups) {
Long parentId = group.getParentId();
if (parentId == null || !map.containsKey(parentId)) {
@ -119,6 +122,9 @@ public class GGroupsServiceImpl implements IGGroupsService
return roots;
}
/**
* 构建组和站点树状列表
*/
private List<GGroups> buildTreeSite(List<GGroups> groupsList) {
// 构建一个Map用于存储每个组对象:id->组对象
Map<Long, GGroups> map = new HashMap<>();
@ -147,7 +153,7 @@ public class GGroupsServiceImpl implements IGGroupsService
map.put(group.getId(), group);
}
//构建组树状结构
return getgGroups(groupsList, map, roots);
return combinationGroupsTree(groupsList, map, roots);
}
/**
@ -159,17 +165,14 @@ public class GGroupsServiceImpl implements IGGroupsService
@Override
public int insertGGroups(GGroups gGroups)
{
//判断所属项目
//同一个父节点下组名不能重复
GGroups duplicateName=gGroupsMapper.selectOne(new LambdaQueryWrapper<GGroups>()
List<GGroups> duplicateNameList = new LambdaQueryChainWrapper<>(gGroupsMapper)
.select(GGroups::getId)
.eq(GGroups::getName, gGroups.getName().trim())
.eq(GGroups::getParentId, gGroups.getParentId())
);
if(Objects.nonNull(duplicateName)){
throw new ServiceException("组名已存在!");
.list();
if(!duplicateNameList.isEmpty()){
throw new ServiceException("组名重复!");
}
gGroups.setCreateTime(DateUtils.getNowDate());
return gGroupsMapper.insertGGroups(gGroups);
@ -185,29 +188,20 @@ public class GGroupsServiceImpl implements IGGroupsService
public int updateGGroups(GGroups gGroups)
{
//同一个父节点下组名不能重复
GGroups duplicateName=gGroupsMapper.selectOne(new LambdaQueryWrapper<GGroups>()
List<GGroups> duplicateNameList = new LambdaQueryChainWrapper<>(gGroupsMapper)
.select(GGroups::getId)
.eq(GGroups::getName, gGroups.getName().trim())
.eq(GGroups::getParentId, gGroups.getParentId())
.ne(GGroups::getId, gGroups.getId()));
if(Objects.nonNull(duplicateName)){
throw new ServiceException("组名已存在!");
.eq(GGroups::getName, gGroups.getName().trim())
.ne(GGroups::getId, gGroups.getId())
.list();
if(!duplicateNameList.isEmpty()){
throw new ServiceException("组名重复!");
}
gGroups.setUpdateTime(DateUtils.getNowDate());
return gGroupsMapper.updateGGroups(gGroups);
}
/**
* 批量删除组
*
* @param ids 需要删除的组主键
* @return 结果
*/
@Override
public int deleteGGroupsByIds(Long[] ids)
{
return gGroupsMapper.deleteGGroupsByIds(ids);
}
/**
* 删除组信息
@ -229,17 +223,15 @@ public class GGroupsServiceImpl implements IGGroupsService
*/
@Override
public List<?> selectGGroupsAndSitesList(GGroups gGroups) {
List<GGroups> list = new LambdaQueryChainWrapper<>(gGroupsMapper)
.select(GGroups::getId, GGroups::getName, GGroups::getParentId,
GGroups::getIcon,GGroups::getTag,
List<GGroups> groupSiteTreeList = new LambdaQueryChainWrapper<>(gGroupsMapper)
.select(GGroups::getId, GGroups::getName, GGroups::getParentId, GGroups::getIcon,GGroups::getTag,
GGroups::getSpace, GGroups::getSpaceValue, GGroups::getProjectId)
.eq(Objects.nonNull(gGroups.getTag()), GGroups::getTag, gGroups.getTag())
.in(Objects.nonNull(ProjectHolder.getProjectInfo().getProjectIdList()),GGroups::getProjectId, ProjectHolder.getProjectInfo().getProjectIdList())
.in(Objects.nonNull(ProjectHolder.getProjectInfo().getProjectIdList()),GGroups::getProjectId,
ProjectHolder.getProjectInfo().getProjectIdList())
.list();
System.err.println(ProjectHolder.getProjectInfo());
list.forEach(System.err::println);
List<GGroups> gGroupsList = buildTreeSite(list);
//组的树状结构外层数组元素套一层数组
List<GGroups> gGroupsList = buildTreeSite(groupSiteTreeList);
//组的树状结构外层数组元素套一层数组:方便前端数据渲染
return gGroupsList.stream().map(gGroups1 -> {
List<GGroups> list1 = new ArrayList<>();
list1.add(gGroups1);

View File

@ -5,13 +5,11 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.fastbee.common.exception.ServiceException;
import com.fastbee.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fastbee.ggroup.mapper.GLegendMapper;
import com.fastbee.ggroup.domain.GLegend;
@ -27,8 +25,12 @@ import com.fastbee.ggroup.service.IGLegendService;
@Slf4j
public class GLegendServiceImpl implements IGLegendService
{
@Autowired
private GLegendMapper gLegendMapper;
private final GLegendMapper gLegendMapper;
public GLegendServiceImpl(GLegendMapper gLegendMapper) {
this.gLegendMapper = gLegendMapper;
}
/**
@ -40,9 +42,10 @@ public class GLegendServiceImpl implements IGLegendService
@Override
public GLegend selectGLegendById(Long id)
{
return gLegendMapper.selectOne(new LambdaQueryWrapper<GLegend>()
return new LambdaQueryChainWrapper<>(gLegendMapper)
.select(GLegend::getId,GLegend::getIcon,GLegend::getName,GLegend::getCategory)
.eq(GLegend::getId,id));
.eq(GLegend::getId,id)
.one();
}
/**
@ -68,10 +71,12 @@ public class GLegendServiceImpl implements IGLegendService
public int insertGLegend(GLegend gLegend)
{
//图例名称不能重复
if(!new LambdaQueryChainWrapper<>(gLegendMapper)
.select(GLegend::getId,GLegend::getName)
.eq(GLegend::getName,gLegend.getName().trim()).list().isEmpty()){
throw new ServiceException("图例名称已存在!");
List<GLegend> duplicateNameList = new LambdaQueryChainWrapper<>(gLegendMapper)
.select(GLegend::getId, GLegend::getName)
.eq(GLegend::getName, gLegend.getName().trim())
.list();
if(!duplicateNameList.isEmpty()){
throw new ServiceException("图例名称重复!");
}
return gLegendMapper.insertGLegend(gLegend);
}
@ -86,9 +91,11 @@ public class GLegendServiceImpl implements IGLegendService
public int updateGLegend(GLegend gLegend)
{
//图例名称不能重复
if(!new LambdaQueryChainWrapper<>(gLegendMapper)
List<GLegend> duplicateNameList=new LambdaQueryChainWrapper<>(gLegendMapper)
.select(GLegend::getId,GLegend::getName)
.eq(GLegend::getName,gLegend.getName().trim()).ne(GLegend::getId,gLegend.getId()).list().isEmpty()){
.eq(GLegend::getName,gLegend.getName().trim())
.ne(GLegend::getId,gLegend.getId()).list();
if(!duplicateNameList.isEmpty()){
throw new ServiceException("图例名称已存在!");
}
gLegend.setUpdateTime(DateUtils.getNowDate());
@ -106,17 +113,7 @@ public class GLegendServiceImpl implements IGLegendService
return gLegendMapper.deleteGLegendByIds(ids);
}
/**
* 删除图例信息
*
* @param id 图例主键
* @return 结果
*/
@Override
public int deleteGLegendById(Long id)
{
return gLegendMapper.deleteGLegendById(id);
}
/**
* 按照类别返回所有类别下图例列表
@ -127,6 +124,7 @@ public class GLegendServiceImpl implements IGLegendService
return new LambdaQueryChainWrapper<>(gLegendMapper)
.select(GLegend::getId,GLegend::getIcon, GLegend::getName,GLegend::getCategory)
.list().stream()
//按照类别分组
.collect(Collectors.groupingBy(GLegend::getCategory))
.entrySet().stream()
.map(entry -> {

View File

@ -6,9 +6,6 @@ import java.util.Objects;
import com.fastbee.common.exception.ServiceException;
import com.fastbee.common.utils.DateUtils;
import com.fastbee.common.utils.ValidationUtils;
import com.fastbee.ggroup.domain.GSites;
import com.fastbee.ggroup.mapper.GSitesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fastbee.ggroup.mapper.GSiteInfoMapper;
import com.fastbee.ggroup.domain.GSiteInfo;
@ -18,13 +15,17 @@ import com.fastbee.ggroup.service.IGSiteInfoService;
* 站点基础信息Service业务层处理
*
* @author kerwincui
* @date 2024-10-10
* &#064;date 2024-10-10
*/
@Service
public class GSiteInfoServiceImpl implements IGSiteInfoService
{
@Autowired
private GSiteInfoMapper gSiteInfoMapper;
private final GSiteInfoMapper gSiteInfoMapper;
public GSiteInfoServiceImpl(GSiteInfoMapper gSiteInfoMapper) {
this.gSiteInfoMapper = gSiteInfoMapper;
}
/**
@ -102,15 +103,4 @@ public class GSiteInfoServiceImpl implements IGSiteInfoService
return gSiteInfoMapper.deleteGSiteInfoByIds(ids);
}
/**
* 删除站点基础信息信息
*
* @param id 站点基础信息主键
* @return 结果
*/
@Override
public int deleteGSiteInfoById(Long id)
{
return gSiteInfoMapper.deleteGSiteInfoById(id);
}
}

View File

@ -1,9 +1,6 @@
package com.fastbee.ggroup.service.impl;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ -15,7 +12,6 @@ import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fastbee.common.config.RuoYiConfig;
import com.fastbee.common.exception.ServiceException;
import com.fastbee.ggroup.domain.GSiteGroups;
import com.fastbee.ggroup.domain.dto.GGroupSiteDto;
@ -24,10 +20,8 @@ import com.fastbee.ggroup.domain.dto.GSitesEditDto;
import com.fastbee.ggroup.domain.dto.GSitesSelectDto;
import com.fastbee.ggroup.mapper.GSiteGroupsMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fastbee.ggroup.mapper.GSitesMapper;
import com.fastbee.ggroup.domain.GSites;
@ -43,17 +37,17 @@ import org.springframework.transaction.annotation.Transactional;
@Service
@Slf4j
public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups> implements IGSitesService {
@Autowired
private GSitesMapper gSitesMapper;
@Autowired
private GSiteGroupsMapper gSiteGroupsMapper;
private final GSitesMapper gSitesMapper;
private final GSiteGroupsMapper gSiteGroupsMapper;
public GSitesServiceImpl(GSitesMapper gSitesMapper, GSiteGroupsMapper gSiteGroupsMapper) {
this.gSitesMapper = gSitesMapper;
this.gSiteGroupsMapper = gSiteGroupsMapper;
}
/**
* 查询站点
*
* @param id 站点主键
* @return 站点
*/
@Override
public GSites selectGSitesById(Long id) {
@ -61,24 +55,18 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
}
/**
* 查询/搜索全部站点列表
*
* @param gSites 站点
* @return 站点
* 查询全部站点列表
*/
@Override
public List<?> selectGSitesList(GSitesSelectDto gSites) {
return gSitesMapper.selectList(new LambdaQueryWrapper<GSites>()
public List<GSites> selectGSitesList(GSitesSelectDto gSites) {
return new LambdaQueryChainWrapper<>(gSitesMapper)
.select(GSites::getId, GSites::getName, GSites::getIcon, GSites::getType)
.eq(GSites::getProjectId, gSites.getProjectId())
);
.list();
}
/**
* 新增站点
*
* @param gGroupSiteDto 站点
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
@ -99,21 +87,18 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
}
//设置坐标值等信息
getReadJsonFileContent(gSites);
// 插入站点表
//插入站点表
int inserted = gSitesMapper.insert(gSites);
gGroupSiteDto.setSiteId(gSites.getId());
//插入关系表
int inserted1 = gSiteGroupsMapper.insertGSiteGroups(gGroupSiteDto);
return inserted == 1 && inserted1 == 1 ? 1 : 0;
// return 1;
}
/**
* 读取上传的站点图信息并赋值
* @param gSites 站点
*/
private void getReadJsonFileContent(GSites gSites) {
String json;
//TODO 路径优化
//发起http请求获取json数据
String space = gSites.getSpace();
@ -137,9 +122,7 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
throw new ServiceException("json格式不正确");
}
int startIndex = space.indexOf("/profile/upload/");
// System.err.println("路径匹配截取开始下标:"+startIndex);
String relativeUrl = space.substring(startIndex);
// System.err.println("相对路径:"+relativeUrl);
gSites.setSpace(relativeUrl);
gSites.setSpaceValue(jsonData);
@ -148,9 +131,6 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
/**
* 修改站点
*
* @param gSitesEditDto 站点
* @return 结果
*/
@Override
public int updateGSites(GSitesEditDto gSitesEditDto) {
@ -183,9 +163,6 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
}
/**
* 批量删除站点
*
* @param ids 需要删除的站点主键
* @return 结果
*/
@Override
public int deleteGSitesByIds(Long[] ids) {
@ -194,9 +171,6 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
/**
* 删除站点信息
*
* @param id 站点主键
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
@ -221,13 +195,10 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
}
//如果有跟其他组建立关系,只删除跟当前组的关系
return gSiteGroupsMapper.deleteById(id);
}
/**
* 站点关联组
* @param gGroupSiteRelateDto 传输对象
* @return 结果
*/
@Override
public int relateGroup(GGroupSiteRelateDto gGroupSiteRelateDto) {
@ -251,8 +222,6 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
/**
* 搜索站点列表
* @param gSites 站点对象
* @return 结果
*/
@Override
public List<GSites> searchGSitesList(GSites gSites) {