多级目录管理以及站点管理接口完成,图例管理基本接口
This commit is contained in:
parent
d494eaf218
commit
d562b85179
@ -0,0 +1,110 @@
|
||||
package com.fastbee.data.controller.gis;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.ggroup.domain.GLegend;
|
||||
import com.fastbee.ggroup.service.IGLegendService;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 图例Controller
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ggroup/legend")
|
||||
@Api(tags = "图例")
|
||||
public class GLegendController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IGLegendService gLegendService;
|
||||
|
||||
/**
|
||||
* 查询图例列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ggroup:legend:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询图例列表")
|
||||
public TableDataInfo list(GLegend gLegend)
|
||||
{
|
||||
startPage();
|
||||
List<GLegend> list = gLegendService.selectGLegendList(gLegend);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出图例列表
|
||||
*/
|
||||
@ApiOperation("导出图例列表")
|
||||
@PreAuthorize("@ss.hasPermi('ggroup:legend:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, GLegend gLegend)
|
||||
{
|
||||
List<GLegend> list = gLegendService.selectGLegendList(gLegend);
|
||||
ExcelUtil<GLegend> util = new ExcelUtil<GLegend>(GLegend.class);
|
||||
util.exportExcel(response, list, "图例数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图例详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ggroup:legend:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation("获取图例详细信息")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(gLegendService.selectGLegendById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增图例
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ggroup:legend:add')")
|
||||
@PostMapping
|
||||
@ApiOperation("新增图例")
|
||||
public AjaxResult add(@RequestBody GLegend gLegend)
|
||||
{
|
||||
return toAjax(gLegendService.insertGLegend(gLegend));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改图例
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ggroup:legend:edit')")
|
||||
@PutMapping
|
||||
@ApiOperation("修改图例")
|
||||
public AjaxResult edit(@RequestBody GLegend gLegend)
|
||||
{
|
||||
return toAjax(gLegendService.updateGLegend(gLegend));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除图例
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ggroup:legend:remove')")
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除图例")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(gLegendService.deleteGLegendByIds(ids));
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.fastbee.ggroup.domain.dto.GGroupSiteDto;
|
||||
import com.fastbee.ggroup.domain.dto.GGroupSiteRelateDto;
|
||||
import com.fastbee.ggroup.domain.dto.GSitesEditDto;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -53,6 +54,16 @@ public class GSitesController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 站点关联组
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ggroup:sites:relate')")
|
||||
@PostMapping("/relate")
|
||||
@ApiOperation("站点关联组")
|
||||
public AjaxResult relate(@RequestBody GGroupSiteRelateDto gGroupSiteRelateDto){
|
||||
return toAjax(gSitesService.relateGroup(gGroupSiteRelateDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出站点列表
|
||||
*/
|
||||
|
@ -24,5 +24,6 @@
|
||||
<artifactId>fastbee-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@ -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;
|
||||
|
||||
@ -41,21 +42,22 @@ public class GSitesServiceImpl implements IGSitesService
|
||||
* @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)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,21 +68,23 @@ public class GSitesServiceImpl implements IGSitesService
|
||||
*/
|
||||
@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()));
|
||||
GSites gSites1 = gSitesMapper.selectOne(new LambdaQueryWrapper<GSites>()
|
||||
.select(GSites::getName, GSites::getId)
|
||||
.eq(GSites::getName, gGroupSiteDto.getName().trim()));
|
||||
if (gSites1 != null) {
|
||||
return 1;
|
||||
throw new ServiceException("站点名称已存在!");
|
||||
}
|
||||
//插入站点表
|
||||
int inserted = gSitesMapper.insert(gSites);
|
||||
gGroupSiteDto.setSiteId(gSites.getId());
|
||||
//插入关系表
|
||||
int inserted1 = gSitesMapper.insertGSites(gGroupSiteDto);
|
||||
return inserted == 1 && inserted1 == 1 ? 1 : 0;
|
||||
}
|
||||
@ -92,12 +96,13 @@ public class GSitesServiceImpl implements IGSitesService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateGSites(GSitesEditDto gSitesEditDto)
|
||||
{
|
||||
public int updateGSites(GSitesEditDto gSitesEditDto) {
|
||||
//不能有重复名字的站点
|
||||
GSites gSites1=gSitesMapper.selectOne(new LambdaQueryWrapper<GSites>().eq(GSites::getName,gSitesEditDto.getName()));
|
||||
GSites gSites1 = gSitesMapper.selectOne(new LambdaQueryWrapper<GSites>()
|
||||
.select(GSites::getName, GSites::getId)
|
||||
.eq(GSites::getName, gSitesEditDto.getName().trim()));
|
||||
if (gSites1 != null) {
|
||||
throw new RuntimeException("站点名称已存在!");
|
||||
throw new ServiceException("站点名称已存在!");
|
||||
}
|
||||
GSites sites = new GSites();
|
||||
BeanUtils.copyProperties(gSitesEditDto, sites);
|
||||
@ -111,8 +116,7 @@ public class GSitesServiceImpl implements IGSitesService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGSitesByIds(Long[] ids)
|
||||
{
|
||||
public int deleteGSitesByIds(Long[] ids) {
|
||||
return gSitesMapper.deleteGSitesByIds(ids);
|
||||
}
|
||||
|
||||
@ -124,15 +128,46 @@ public class GSitesServiceImpl implements IGSitesService
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteGSitesById(Long id)
|
||||
{
|
||||
public int deleteGSitesById(Long id) {
|
||||
GSiteGroups gSiteGroups = gSiteGroupsMapper.selectGSiteGroupsById(id);
|
||||
if (gSiteGroups == null) {
|
||||
throw new RuntimeException("站点不存在");
|
||||
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;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
<result property="parentId" column="group_id" />
|
||||
<result property="parentName" column="group_name" />
|
||||
<result property="siteId" column="id" />
|
||||
<result property="siteName" column="name" />
|
||||
<result property="name" column="name" />
|
||||
<result property="icon" column="icon" />
|
||||
<result property="type" column="type" />
|
||||
<result property="space" column="space" />
|
||||
|
@ -4,15 +4,79 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fastbee.ggroup.mapper.GLegendMapper">
|
||||
|
||||
<resultMap type="GLegend" id="GGroupsResult">
|
||||
<resultMap type="GLegend" id="GLegendResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="icon" column="icon" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="icon" column="icon"/>
|
||||
<result property="type" column="type" />
|
||||
<result property="name" column="name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectGLegendVo">
|
||||
select id, icon, create_time, create_by, update_time, update_by, type, name from g_legend
|
||||
</sql>
|
||||
|
||||
<select id="selectGLegendList" parameterType="GLegend" resultMap="GLegendResult">
|
||||
<include refid="selectGLegendVo"/>
|
||||
<where>
|
||||
<if test="icon != null and icon != ''"> and icon = #{icon}</if>
|
||||
<if test="type != null "> and type = #{type}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectGLegendById" parameterType="Long" resultMap="GLegendResult">
|
||||
<include refid="selectGLegendVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertGLegend" parameterType="GLegend" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into g_legend
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="icon != null">icon,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="name != null">name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="icon != null">#{icon},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateGLegend" parameterType="GLegend">
|
||||
update g_legend
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="icon != null">icon = #{icon},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="name != null">name = #{name},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteGLegendById" parameterType="Long">
|
||||
delete from g_legend where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteGLegendByIds" parameterType="String">
|
||||
delete from g_legend where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user