多级目录管理以及站点管理接口完成,图例管理基本接口
This commit is contained in:
@ -1,19 +1,39 @@
|
||||
package com.fastbee.ggroup.domain;
|
||||
|
||||
import com.fastbee.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import com.fastbee.common.annotation.Excel;
|
||||
import com.fastbee.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 组对象 g_groups
|
||||
* 图例对象 g_legend
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-09-27
|
||||
* @date 2024-10-08
|
||||
*/
|
||||
@ApiModel(value = "GLegend",description = "图例 g_Legend")
|
||||
@ApiModel(value = "GLegend",description = "图例 g_legend")
|
||||
@Data
|
||||
public class GLegend extends BaseEntity {
|
||||
private int id;
|
||||
public class GLegend extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键id */
|
||||
private Long id;
|
||||
|
||||
/** 图标 */
|
||||
@Excel(name = "图标")
|
||||
@ApiModelProperty("图标")
|
||||
private String icon;
|
||||
private int type;
|
||||
|
||||
/** 类型 */
|
||||
@Excel(name = "类型")
|
||||
@ApiModelProperty("类型")
|
||||
private Long type;
|
||||
|
||||
/** 图标名称 */
|
||||
@Excel(name = "图标名称")
|
||||
@ApiModelProperty("图标名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.fastbee.ggroup.domain;
|
||||
|
||||
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;
|
||||
@ -17,12 +19,12 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
*/
|
||||
@ApiModel(value = "GSiteGroups",description = "站点组关系 g_site_groups")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class GSiteGroups extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
/** 主键 */
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 站点id */
|
||||
|
@ -20,7 +20,6 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
*/
|
||||
@ApiModel(value = "GSites",description = "站点 g_sites")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class GSites extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -49,4 +48,9 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("空间数据")
|
||||
private String space;
|
||||
|
||||
/** 项目id */
|
||||
@Excel(name = "项目id")
|
||||
@ApiModelProperty("项目id")
|
||||
private Long projectId;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.fastbee.ggroup.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class GGroupSiteRelateDto {
|
||||
private List<Long> siteIds;//站点id列表
|
||||
private Long parentId;//父节点id
|
||||
}
|
@ -1,8 +1,62 @@
|
||||
package com.fastbee.ggroup.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
import com.fastbee.ggroup.domain.GLegend;
|
||||
|
||||
public interface GLegendMapper extends BaseMapper<GLegendMapper> {
|
||||
/**
|
||||
* 图例Mapper接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-08
|
||||
*/
|
||||
public interface GLegendMapper
|
||||
{
|
||||
/**
|
||||
* 查询图例
|
||||
*
|
||||
* @param id 图例主键
|
||||
* @return 图例
|
||||
*/
|
||||
public GLegend selectGLegendById(Long id);
|
||||
|
||||
/**
|
||||
* 查询图例列表
|
||||
*
|
||||
* @param gLegend 图例
|
||||
* @return 图例集合
|
||||
*/
|
||||
public List<GLegend> selectGLegendList(GLegend gLegend);
|
||||
|
||||
/**
|
||||
* 新增图例
|
||||
*
|
||||
* @param gLegend 图例
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGLegend(GLegend gLegend);
|
||||
|
||||
/**
|
||||
* 修改图例
|
||||
*
|
||||
* @param gLegend 图例
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGLegend(GLegend gLegend);
|
||||
|
||||
/**
|
||||
* 删除图例
|
||||
*
|
||||
* @param id 图例主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGLegendById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除图例
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGLegendByIds(Long[] ids);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ public interface GSitesMapper extends BaseMapper<GSites>
|
||||
* @param id 站点主键
|
||||
* @return 站点
|
||||
*/
|
||||
|
||||
public GSites selectGSitesById(Long id);
|
||||
|
||||
/**
|
||||
|
@ -1,4 +0,0 @@
|
||||
package com.fastbee.ggroup.service;
|
||||
|
||||
public interface GLegendServiceImpl {
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.fastbee.ggroup.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.fastbee.ggroup.domain.GLegend;
|
||||
|
||||
/**
|
||||
* 图例Service接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-08
|
||||
*/
|
||||
public interface IGLegendService
|
||||
{
|
||||
/**
|
||||
* 查询图例
|
||||
*
|
||||
* @param id 图例主键
|
||||
* @return 图例
|
||||
*/
|
||||
public GLegend selectGLegendById(Long id);
|
||||
|
||||
/**
|
||||
* 查询图例列表
|
||||
*
|
||||
* @param gLegend 图例
|
||||
* @return 图例集合
|
||||
*/
|
||||
public List<GLegend> selectGLegendList(GLegend gLegend);
|
||||
|
||||
/**
|
||||
* 新增图例
|
||||
*
|
||||
* @param gLegend 图例
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGLegend(GLegend gLegend);
|
||||
|
||||
/**
|
||||
* 修改图例
|
||||
*
|
||||
* @param gLegend 图例
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGLegend(GLegend gLegend);
|
||||
|
||||
/**
|
||||
* 批量删除图例
|
||||
*
|
||||
* @param ids 需要删除的图例主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGLegendByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除图例信息
|
||||
*
|
||||
* @param id 图例主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGLegendById(Long id);
|
||||
}
|
@ -3,6 +3,7 @@ package com.fastbee.ggroup.service;
|
||||
import java.util.List;
|
||||
import com.fastbee.ggroup.domain.GSites;
|
||||
import com.fastbee.ggroup.domain.dto.GGroupSiteDto;
|
||||
import com.fastbee.ggroup.domain.dto.GGroupSiteRelateDto;
|
||||
import com.fastbee.ggroup.domain.dto.GSitesEditDto;
|
||||
|
||||
/**
|
||||
@ -60,4 +61,12 @@ public interface IGSitesService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGSitesById(Long id);
|
||||
|
||||
/**
|
||||
* 站点关联组
|
||||
*
|
||||
* @param gGroupSiteRelateDto
|
||||
* @return
|
||||
*/
|
||||
int relateGroup(GGroupSiteRelateDto gGroupSiteRelateDto);
|
||||
}
|
||||
|
@ -1,5 +1,96 @@
|
||||
package com.fastbee.ggroup.service.impl;
|
||||
|
||||
public class GLegendServiceImpl implements com.fastbee.ggroup.service.GLegendServiceImpl {
|
||||
import java.util.List;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fastbee.ggroup.mapper.GLegendMapper;
|
||||
import com.fastbee.ggroup.domain.GLegend;
|
||||
import com.fastbee.ggroup.service.IGLegendService;
|
||||
|
||||
/**
|
||||
* 图例Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-08
|
||||
*/
|
||||
@Service
|
||||
public class GLegendServiceImpl implements IGLegendService
|
||||
{
|
||||
@Autowired
|
||||
private GLegendMapper gLegendMapper;
|
||||
|
||||
/**
|
||||
* 查询图例
|
||||
*
|
||||
* @param id 图例主键
|
||||
* @return 图例
|
||||
*/
|
||||
@Override
|
||||
public GLegend selectGLegendById(Long id)
|
||||
{
|
||||
return gLegendMapper.selectGLegendById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询图例列表
|
||||
*
|
||||
* @param gLegend 图例
|
||||
* @return 图例
|
||||
*/
|
||||
@Override
|
||||
public List<GLegend> selectGLegendList(GLegend gLegend)
|
||||
{
|
||||
return gLegendMapper.selectGLegendList(gLegend);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增图例
|
||||
*
|
||||
* @param gLegend 图例
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertGLegend(GLegend gLegend)
|
||||
{
|
||||
gLegend.setCreateTime(DateUtils.getNowDate());
|
||||
return gLegendMapper.insertGLegend(gLegend);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改图例
|
||||
*
|
||||
* @param gLegend 图例
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateGLegend(GLegend gLegend)
|
||||
{
|
||||
gLegend.setUpdateTime(DateUtils.getNowDate());
|
||||
return gLegendMapper.updateGLegend(gLegend);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除图例
|
||||
*
|
||||
* @param ids 需要删除的图例主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGLegendByIds(Long[] ids)
|
||||
{
|
||||
return gLegendMapper.deleteGLegendByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除图例信息
|
||||
*
|
||||
* @param id 图例主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGLegendById(Long id)
|
||||
{
|
||||
return gLegendMapper.deleteGLegendById(id);
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,18 @@
|
||||
package com.fastbee.ggroup.service.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.ggroup.domain.GSiteGroups;
|
||||
import com.fastbee.ggroup.domain.dto.GGroupSiteDto;
|
||||
import com.fastbee.ggroup.domain.dto.GGroupSiteRelateDto;
|
||||
import com.fastbee.ggroup.domain.dto.GSitesEditDto;
|
||||
import com.fastbee.ggroup.mapper.GSiteGroupsMapper;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -26,8 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @date 2024-09-29
|
||||
*/
|
||||
@Service
|
||||
public class GSitesServiceImpl implements IGSitesService
|
||||
{
|
||||
public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups> implements IGSitesService {
|
||||
@Autowired
|
||||
private GSitesMapper gSitesMapper;
|
||||
|
||||
@ -36,103 +37,137 @@ public class GSitesServiceImpl implements IGSitesService
|
||||
|
||||
/**
|
||||
* 查询站点
|
||||
*
|
||||
*
|
||||
* @param id 站点主键
|
||||
* @return 站点
|
||||
*/
|
||||
@Override
|
||||
public GSites selectGSitesById(Long id)
|
||||
{
|
||||
public GSites selectGSitesById(Long id) {
|
||||
return gSitesMapper.selectGSitesById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询站点列表
|
||||
*
|
||||
* 查询全部站点列表
|
||||
*
|
||||
* @param gSites 站点
|
||||
* @return 站点
|
||||
*/
|
||||
@Override
|
||||
public List<GSites> selectGSitesList(GSites gSites)
|
||||
{
|
||||
return null;
|
||||
public List<GSites> selectGSitesList(GSites gSites) {
|
||||
return gSitesMapper.selectList(new LambdaQueryWrapper<GSites>()
|
||||
.select(GSites::getId, GSites::getName, GSites::getIcon, GSites::getType)
|
||||
.eq(GSites::getProjectId, 1)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增站点
|
||||
*
|
||||
*
|
||||
* @param gGroupSiteDto 站点
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertGSites(GGroupSiteDto gGroupSiteDto)
|
||||
{
|
||||
//插入关系表
|
||||
public int insertGSites(GGroupSiteDto gGroupSiteDto) {
|
||||
|
||||
GSites gSites = new GSites();
|
||||
gSites.setName(gGroupSiteDto.getName());
|
||||
gSites.setName(gGroupSiteDto.getName().trim());
|
||||
gSites.setType(gGroupSiteDto.getType());
|
||||
gSites.setIcon(gGroupSiteDto.getIcon());
|
||||
//根据名称判断是否存在该站点
|
||||
GSites gSites1=gSitesMapper.selectOne(new LambdaQueryWrapper<GSites>().eq(GSites::getName,gGroupSiteDto.getName()));
|
||||
if(gSites1!=null){
|
||||
return 1;
|
||||
GSites gSites1 = gSitesMapper.selectOne(new LambdaQueryWrapper<GSites>()
|
||||
.select(GSites::getName, GSites::getId)
|
||||
.eq(GSites::getName, gGroupSiteDto.getName().trim()));
|
||||
if (gSites1 != null) {
|
||||
throw new ServiceException("站点名称已存在!");
|
||||
}
|
||||
//插入站点表
|
||||
int inserted = gSitesMapper.insert(gSites);
|
||||
gGroupSiteDto.setSiteId(gSites.getId());
|
||||
//插入关系表
|
||||
int inserted1 = gSitesMapper.insertGSites(gGroupSiteDto);
|
||||
return inserted==1&&inserted1==1?1:0 ;
|
||||
return inserted == 1 && inserted1 == 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改站点
|
||||
*
|
||||
*
|
||||
* @param gSitesEditDto 站点
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateGSites(GSitesEditDto gSitesEditDto)
|
||||
{
|
||||
public int updateGSites(GSitesEditDto gSitesEditDto) {
|
||||
//不能有重复名字的站点
|
||||
GSites gSites1=gSitesMapper.selectOne(new LambdaQueryWrapper<GSites>().eq(GSites::getName,gSitesEditDto.getName()));
|
||||
if(gSites1!=null){
|
||||
throw new RuntimeException("站点名称已存在!");
|
||||
GSites gSites1 = gSitesMapper.selectOne(new LambdaQueryWrapper<GSites>()
|
||||
.select(GSites::getName, GSites::getId)
|
||||
.eq(GSites::getName, gSitesEditDto.getName().trim()));
|
||||
if (gSites1 != null) {
|
||||
throw new ServiceException("站点名称已存在!");
|
||||
}
|
||||
GSites sites = new GSites();
|
||||
BeanUtils.copyProperties(gSitesEditDto,sites);
|
||||
BeanUtils.copyProperties(gSitesEditDto, sites);
|
||||
return gSitesMapper.updateById(sites);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除站点
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的站点主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGSitesByIds(Long[] ids)
|
||||
{
|
||||
public int deleteGSitesByIds(Long[] ids) {
|
||||
return gSitesMapper.deleteGSitesByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除站点信息
|
||||
*
|
||||
*
|
||||
* @param id 站点主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteGSitesById(Long id)
|
||||
{
|
||||
GSiteGroups gSiteGroups =gSiteGroupsMapper.selectGSiteGroupsById(id);
|
||||
if(gSiteGroups==null){
|
||||
throw new RuntimeException("站点不存在");
|
||||
public int deleteGSitesById(Long id) {
|
||||
GSiteGroups gSiteGroups = gSiteGroupsMapper.selectGSiteGroupsById(id);
|
||||
if (gSiteGroups == null) {
|
||||
throw new ServiceException("站点不存在");
|
||||
}
|
||||
int deleted= gSitesMapper.deleteById(gSiteGroups.getId());
|
||||
int deleted = gSitesMapper.deleteById(gSiteGroups.getSiteId());
|
||||
//删除关系
|
||||
int deleted1=gSiteGroupsMapper.deleteById(id);
|
||||
return deleted==1&&deleted1==1?1:0 ;
|
||||
int deleted1 = gSiteGroupsMapper.deleteById(id);
|
||||
return deleted == 1 && deleted1 == 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int relateGroup(GGroupSiteRelateDto gGroupSiteRelateDto) {
|
||||
Long parentId = gGroupSiteRelateDto.getParentId();
|
||||
if (StringUtils.isBlank(parentId.toString())) {
|
||||
throw new ServiceException("请选择分组!");
|
||||
}
|
||||
List<Long> siteIds = gGroupSiteRelateDto.getSiteIds();
|
||||
if (siteIds.isEmpty()) {
|
||||
throw new ServiceException("请选择站点!");
|
||||
}
|
||||
super.saveBatch(siteIds
|
||||
.stream()
|
||||
.map(this::setSiteIdToSiteGroups)
|
||||
.collect(Collectors.toList())
|
||||
.stream()
|
||||
.map(item -> {
|
||||
item.setParentId(parentId);
|
||||
item.setProjectId(1L);
|
||||
return item;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
private GSiteGroups setSiteIdToSiteGroups(Long siteId) {
|
||||
GSiteGroups gSiteGroups = new GSiteGroups();
|
||||
gSiteGroups.setSiteId(siteId);
|
||||
return gSiteGroups;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user