接口逻辑补充零碎修改等
This commit is contained in:
@ -65,6 +65,11 @@ public interface IGGroupsService
|
||||
*/
|
||||
public int deleteGGroupsById(Long id);
|
||||
|
||||
/**
|
||||
* 查询组和站点(叶子节点)的树状结构
|
||||
* @param gGroups 组
|
||||
* @return 列表
|
||||
*/
|
||||
List<?> selectGGroupsAndSitesList(GGroups gGroups);
|
||||
|
||||
}
|
||||
|
@ -62,11 +62,12 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
@Override
|
||||
public List<GGroups> selectGGroupsList(GGroups gGroups)
|
||||
{
|
||||
// List<GGroups> gGroupsList = gGroupsMapper.selectGGroupsList(gGroups);
|
||||
List<GGroups> list = new LambdaQueryChainWrapper<>(gGroupsMapper).select(GGroups::getId, GGroups::getName, GGroups::getIcon,
|
||||
GGroups::getTag, GGroups::getParentId, GGroups::getProjectId, GGroups::getProjectName,
|
||||
GGroups::getOrderNum, GGroups::getSpace)
|
||||
.in(GGroups::getProjectId, ProjectHolder.getProjectInfo().getProjectIdList())
|
||||
.in(Objects.nonNull(ProjectHolder.getProjectInfo().getProjectIdList())&&gGroups.getProjectId()==null,
|
||||
GGroups::getProjectId, ProjectHolder.getProjectInfo().getProjectIdList())
|
||||
.eq(gGroups.getProjectId()!=null, GGroups::getProjectId, gGroups.getProjectId())
|
||||
.list();
|
||||
return buildTree(list);
|
||||
}
|
||||
@ -86,7 +87,7 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
.leftJoin(GGroups.class, GGroups::getId, GSiteGroups::getParentId)
|
||||
.leftJoin(GSites.class, GSites::getId, GSiteGroups::getSiteId)
|
||||
.eq(GSiteGroups::getParentId, gGroups.getParentId())
|
||||
.like(StringUtils.isNotBlank(gGroups.getName()), GGroups::getName, gGroups.getName());
|
||||
.like(StringUtils.isNotBlank(gGroups.getSearchValue()), GSites::getName, gGroups.getSearchValue());
|
||||
return gSiteGroupsMapper.selectJoinList(GGroupSiteVo.class,gSiteGroupsMPJLambdaWrapper);
|
||||
}
|
||||
|
||||
@ -217,6 +218,7 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
@Override
|
||||
public int deleteGGroupsById(Long id)
|
||||
{
|
||||
//判断组下面是否有节点
|
||||
return gGroupsMapper.deleteGGroupsById(id);
|
||||
}
|
||||
|
||||
@ -232,7 +234,7 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
GGroups::getIcon,GGroups::getTag,
|
||||
GGroups::getSpace, GGroups::getSpaceValue, GGroups::getProjectId)
|
||||
.eq(Objects.nonNull(gGroups.getTag()), GGroups::getTag, gGroups.getTag())
|
||||
.in(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);
|
||||
|
@ -13,6 +13,7 @@ import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONException;
|
||||
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;
|
||||
@ -200,7 +201,27 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteGSitesById(Long id) {
|
||||
//判断该站点是否跟其他组建立关系,没有跟其他组建立关系则删除关联,并删除该站点
|
||||
List<GSiteGroups> gSiteGroupsList = new LambdaQueryChainWrapper<>(gSiteGroupsMapper)
|
||||
.select(GSiteGroups::getParentId, GSiteGroups::getSiteId)
|
||||
.eq(GSiteGroups::getId, id)
|
||||
.list();
|
||||
List<GSiteGroups> gSiteGroupsList1 = new LambdaQueryChainWrapper<>(gSiteGroupsMapper)
|
||||
.select(GSiteGroups::getParentId, GSiteGroups::getSiteId)
|
||||
.eq(GSiteGroups::getSiteId, gSiteGroupsList.get(0).getSiteId())
|
||||
.ne(GSiteGroups::getParentId, gSiteGroupsList.get(0).getParentId())
|
||||
.list();
|
||||
//没有跟其他组建立关联
|
||||
if (gSiteGroupsList1.isEmpty()){
|
||||
//删除关联
|
||||
int deleteGSiteGroupsById = gSiteGroupsMapper.deleteById(id);
|
||||
//删除站点
|
||||
int deleteSitesById= gSitesMapper.deleteById(gSiteGroupsList.get(0).getSiteId());
|
||||
return deleteSitesById==1&& deleteGSiteGroupsById==1? 1 : 0;
|
||||
}
|
||||
//如果有跟其他组建立关系,只删除跟当前组的关系
|
||||
return gSiteGroupsMapper.deleteById(id);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,6 +233,7 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
public int relateGroup(GGroupSiteRelateDto gGroupSiteRelateDto) {
|
||||
return super.saveBatch(gGroupSiteRelateDto.getSiteIds()
|
||||
.stream()
|
||||
//转成数据库存储对象
|
||||
.map(siteId -> {
|
||||
GSiteGroups gSiteGroups = new GSiteGroups();
|
||||
gSiteGroups.setSiteId(siteId);
|
||||
@ -219,6 +241,7 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
})
|
||||
.collect(Collectors.toList())
|
||||
.stream()
|
||||
//设置项目id,所属组id
|
||||
.peek(item -> {
|
||||
item.setParentId(gGroupSiteRelateDto.getParentId());
|
||||
item.setProjectId(gGroupSiteRelateDto.getProjectId());
|
||||
@ -226,15 +249,19 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
.collect(Collectors.toList()))? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索站点列表
|
||||
* @param gSites 站点对象
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public List<GSites> searchGSitesList(GSites gSites) {
|
||||
return gSitesMapper.selectList(new LambdaQueryWrapper<GSites>()
|
||||
.eq(GSites::getProjectId, gSites.getProjectId())
|
||||
.select(GSites::getId, GSites::getName, GSites::getType, GSites::getIcon)
|
||||
.like(GSites::getName, gSites.getSearchValue()));
|
||||
return new LambdaQueryChainWrapper<>(gSitesMapper)
|
||||
.select(GSites::getId, GSites::getName, GSites::getType, GSites::getIcon)
|
||||
.eq(GSites::getProjectId, gSites.getProjectId())
|
||||
.like(GSites::getName, gSites.getSearchValue())
|
||||
.list();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user