feat:增加标注批量删除接口
This commit is contained in:
parent
8e1550a045
commit
3f87e669d5
|
|
@ -40,23 +40,13 @@ public class AirlineMarkerController extends BaseController {
|
||||||
@Operation(summary = "获取标注列表")
|
@Operation(summary = "获取标注列表")
|
||||||
public TableDataInfo list(AirlineMarkerVO airlineMarkerVO) {
|
public TableDataInfo list(AirlineMarkerVO airlineMarkerVO) {
|
||||||
startPage();
|
startPage();
|
||||||
|
airlineMarkerVO.setCreateBy(SecurityUtils.getUserId().toString());
|
||||||
AirlineMarkerDTO dto = AirlineMarkerControllerConvert.to(airlineMarkerVO);
|
AirlineMarkerDTO dto = AirlineMarkerControllerConvert.to(airlineMarkerVO);
|
||||||
List<AirlineMarkerDTO> list = iAirlineMarkerService.selectMarkerList(dto);
|
List<AirlineMarkerDTO> list = iAirlineMarkerService.selectMarkerList(dto);
|
||||||
List<AirlineMarkerVO> result = AirlineMarkerControllerConvert.fromList(list);
|
List<AirlineMarkerVO> result = AirlineMarkerControllerConvert.fromList(list);
|
||||||
return getDataTable(result);
|
return getDataTable(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取标注详情
|
|
||||||
*/
|
|
||||||
@GetMapping("/marmerList/{id}")
|
|
||||||
@Operation(summary = "获取标注详情")
|
|
||||||
public AjaxResult getInfo(@PathVariable Long id) {
|
|
||||||
AirlineMarkerDTO dto = iAirlineMarkerService.selectMarkerById(id);
|
|
||||||
AirlineMarkerVO result = AirlineMarkerControllerConvert.from(dto);
|
|
||||||
return success(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增标注
|
* 新增标注
|
||||||
*/
|
*/
|
||||||
|
|
@ -69,17 +59,6 @@ public class AirlineMarkerController extends BaseController {
|
||||||
return toAjax(iAirlineMarkerService.insertMarker(dto));
|
return toAjax(iAirlineMarkerService.insertMarker(dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改标注
|
|
||||||
*/
|
|
||||||
@PutMapping
|
|
||||||
@Operation(summary = "修改标注")
|
|
||||||
public AjaxResult edit(@Validated @RequestBody AirlineMarkerVO marker) {
|
|
||||||
marker.setUpdateBy(SecurityUtils.getUserId().toString());
|
|
||||||
AirlineMarkerDTO dto = AirlineMarkerControllerConvert.to(marker);
|
|
||||||
return toAjax(iAirlineMarkerService.updateMarker(dto));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标注(软删除)
|
* 删除标注(软删除)
|
||||||
*/
|
*/
|
||||||
|
|
@ -93,16 +72,45 @@ public class AirlineMarkerController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按照分组ID查询标注列表
|
* 获取标注详情
|
||||||
*
|
|
||||||
* @param groupId 分组ID
|
|
||||||
* @return 标注列表
|
|
||||||
*/
|
*/
|
||||||
@GetMapping("/markerList/{groupId}")
|
@GetMapping("/{groupId}")
|
||||||
@Operation(summary = "按照分组ID查询标注列表")
|
@Operation(summary = "按照空域分组查询所有的标准信息")
|
||||||
public AjaxResult selectMarkerListByGroupId(@PathVariable Long groupId) {
|
public AjaxResult getInfo(@PathVariable Long groupId) {
|
||||||
List<AirlineMarkerDTO> dtos = iAirlineMarkerService.selectMarkerListByGroupId(groupId);
|
List<AirlineMarkerDTO> dto = iAirlineMarkerService.selectMarkerById(groupId);
|
||||||
List<AirlineMarkerVO> result = AirlineMarkerControllerConvert.fromList(dtos);
|
List<AirlineMarkerVO> result = AirlineMarkerControllerConvert.fromList(dto);
|
||||||
return success(result);
|
return success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改标注
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
@Operation(summary = "修改标注")
|
||||||
|
public AjaxResult edit(@Validated @RequestBody AirlineMarkerVO marker) {
|
||||||
|
marker.setUpdateBy(SecurityUtils.getUserId().toString());
|
||||||
|
AirlineMarkerDTO dto = AirlineMarkerControllerConvert.to(marker);
|
||||||
|
return toAjax(iAirlineMarkerService.updateMarker(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除标注
|
||||||
|
*
|
||||||
|
* @param markerIds 标注ID列表
|
||||||
|
* @return 删除结果
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/batchDeleteMarker")
|
||||||
|
@Operation(summary = "批量删除标注")
|
||||||
|
public AjaxResult batchDeleteMarker(@RequestBody List<Long> markerIds) {
|
||||||
|
if (markerIds == null || markerIds.isEmpty()) {
|
||||||
|
return error("没有需要删除的标注");
|
||||||
|
}
|
||||||
|
int result = iAirlineMarkerService.batchDeleteMarker(markerIds);
|
||||||
|
if (result > 0) {
|
||||||
|
return success("删除成功,共删除 " + result + " 个标注");
|
||||||
|
}
|
||||||
|
return error("删除失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,11 @@ public interface IAirlineMarkerGroupInfoService {
|
||||||
|
|
||||||
int insertMarkerGroupInfo(AirlineMarkerGroupInfoDTO groupInfo);
|
int insertMarkerGroupInfo(AirlineMarkerGroupInfoDTO groupInfo);
|
||||||
|
|
||||||
int deleteMarkerGroupInfo(Long userId, Long groupId, Long markerId);
|
int deleteMarkerGroupInfo(Long groupId, Long markerId);
|
||||||
|
|
||||||
List<AirlineMarkerGroupInfoDTO> selectMarkerGroupInfoList(AirlineMarkerGroupInfoDTO dto);
|
List<AirlineMarkerGroupInfoDTO> selectMarkerGroupInfoList(AirlineMarkerGroupInfoDTO dto);
|
||||||
|
|
||||||
List<Long> selectMarkerIdsByGroupId(Long groupId);
|
List<Long> selectMarkerIdsByGroupId(Long groupId);
|
||||||
|
|
||||||
|
int deleteByMarkerId(Long markerId);
|
||||||
}
|
}
|
||||||
|
|
@ -19,7 +19,8 @@ public interface IAirlineMarkerService {
|
||||||
|
|
||||||
List<AirlineMarkerDTO> selectMarkerList(AirlineMarkerDTO dto);
|
List<AirlineMarkerDTO> selectMarkerList(AirlineMarkerDTO dto);
|
||||||
|
|
||||||
AirlineMarkerDTO selectMarkerById(Long id);
|
List<AirlineMarkerDTO> selectMarkerById(Long id);
|
||||||
|
|
||||||
List<AirlineMarkerDTO> selectMarkerListByGroupId(Long groupId);
|
|
||||||
|
int batchDeleteMarker(List<Long> markerIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.ruoyi.airline.domain.model.AirlineMarkerGroupInfo;
|
||||||
import com.ruoyi.airline.service.api.IAirlineMarkerGroupInfoService;
|
import com.ruoyi.airline.service.api.IAirlineMarkerGroupInfoService;
|
||||||
import com.ruoyi.airline.service.convert.AirlineMarkerGroupInfoServiceConvert;
|
import com.ruoyi.airline.service.convert.AirlineMarkerGroupInfoServiceConvert;
|
||||||
import com.ruoyi.airline.service.dto.AirlineMarkerGroupInfoDTO;
|
import com.ruoyi.airline.service.dto.AirlineMarkerGroupInfoDTO;
|
||||||
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -32,11 +33,12 @@ public class AirlineMarkerGroupInfoServiceImpl implements IAirlineMarkerGroupInf
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteMarkerGroupInfo(Long userId, Long groupId, Long markerId) {
|
public int deleteMarkerGroupInfo(Long groupId, Long markerId) {
|
||||||
AirlineMarkerGroupInfo model = new AirlineMarkerGroupInfo();
|
AirlineMarkerGroupInfo model = new AirlineMarkerGroupInfo();
|
||||||
model.setGroupId(groupId);
|
model.setGroupId(groupId);
|
||||||
model.setMarkerId(markerId);
|
model.setMarkerId(markerId);
|
||||||
model.setDeletedBy(userId != null ? userId.toString() : "");
|
String userId = SecurityUtils.getUserId().toString();
|
||||||
|
model.setDeletedBy(userId);
|
||||||
return iAirlineMarkerGroupInfoDomain.deleteMarkerGroupInfo(model);
|
return iAirlineMarkerGroupInfoDomain.deleteMarkerGroupInfo(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,4 +52,9 @@ public class AirlineMarkerGroupInfoServiceImpl implements IAirlineMarkerGroupInf
|
||||||
public List<Long> selectMarkerIdsByGroupId(Long groupId) {
|
public List<Long> selectMarkerIdsByGroupId(Long groupId) {
|
||||||
return iAirlineMarkerGroupInfoDomain.selectMarkerIdsByGroupId(groupId);
|
return iAirlineMarkerGroupInfoDomain.selectMarkerIdsByGroupId(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteByMarkerId(Long markerId) {
|
||||||
|
return iAirlineMarkerGroupInfoDomain.deleteByMarkerId(markerId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,95 +53,67 @@ public class AirlineMarkerServiceImpl implements IAirlineMarkerService {
|
||||||
@Override
|
@Override
|
||||||
public int updateMarker(AirlineMarkerDTO dto) {
|
public int updateMarker(AirlineMarkerDTO dto) {
|
||||||
AirlineMarker model = AirlineMarkerServiceConvert.to(dto);
|
AirlineMarker model = AirlineMarkerServiceConvert.to(dto);
|
||||||
int result = iAirlineMarkerDomain.updateMarker(model);
|
return iAirlineMarkerDomain.updateMarker(model);
|
||||||
|
|
||||||
// 处理分组关系
|
|
||||||
if (result > 0 && dto.getGroupId() != null) {
|
|
||||||
// 先删除旧的关系
|
|
||||||
iAirlineMarkerGroupInfoService.deleteMarkerGroupInfo(0L, null, dto.getId());
|
|
||||||
// 再创建新的关系
|
|
||||||
AirlineMarkerGroupInfoDTO groupInfo = new AirlineMarkerGroupInfoDTO();
|
|
||||||
groupInfo.setGroupId(dto.getGroupId());
|
|
||||||
groupInfo.setMarkerId(dto.getId());
|
|
||||||
groupInfo.setCreateBy(dto.getUpdateBy());
|
|
||||||
groupInfo.setUpdateBy(dto.getUpdateBy());
|
|
||||||
iAirlineMarkerGroupInfoService.insertMarkerGroupInfo(groupInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteMarker(AirlineMarkerDTO dto) {
|
public int deleteMarker(AirlineMarkerDTO dto) {
|
||||||
// 获取当前用户 ID
|
AirlineMarker marker = AirlineMarkerServiceConvert.to(dto);
|
||||||
Long currentUserId = SecurityUtils.getUserId();
|
|
||||||
|
|
||||||
// 先删除分组关系
|
// 先删除分组关系
|
||||||
iAirlineMarkerGroupInfoService.deleteMarkerGroupInfo(currentUserId, dto.getGroupId(), dto.getId());
|
iAirlineMarkerGroupInfoService.deleteMarkerGroupInfo(dto.getGroupId(), dto.getId());
|
||||||
|
// 再置失效
|
||||||
// 再删除标注(软删除)
|
return iAirlineMarkerDomain.deleteMarker(marker);
|
||||||
AirlineMarker model = new AirlineMarker();
|
|
||||||
model.setId(dto.getId());
|
|
||||||
model.setUpdateBy(currentUserId.toString());
|
|
||||||
return iAirlineMarkerDomain.deleteMarker(model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AirlineMarkerDTO> selectMarkerList(AirlineMarkerDTO dto) {
|
public List<AirlineMarkerDTO> selectMarkerList(AirlineMarkerDTO dto) {
|
||||||
|
// TODO 需要修改为查所有生效的
|
||||||
AirlineMarkerGroupInfoDTO groupInfoDTO = new AirlineMarkerGroupInfoDTO();
|
|
||||||
groupInfoDTO.setGroupId(dto.getGroupId());
|
|
||||||
List<AirlineMarkerGroupInfoDTO> groupInfos = iAirlineMarkerGroupInfoService.selectMarkerGroupInfoList(groupInfoDTO);
|
|
||||||
|
|
||||||
List<AirlineMarkerDTO> result = new ArrayList<>();
|
|
||||||
AirlineMarker marker = AirlineMarkerServiceConvert.to(dto);
|
AirlineMarker marker = AirlineMarkerServiceConvert.to(dto);
|
||||||
|
List<AirlineMarker> airlineMarker = iAirlineMarkerDomain.selectMarkerList(marker);
|
||||||
|
return AirlineMarkerServiceConvert.fromList(airlineMarker);
|
||||||
|
}
|
||||||
|
|
||||||
// 为每个标注设置分组ID
|
|
||||||
for (AirlineMarkerGroupInfoDTO markerDto : groupInfos) {
|
@Override
|
||||||
// 查询分组关系
|
public List<AirlineMarkerDTO> selectMarkerById(Long groupId) {
|
||||||
marker.setId(markerDto.getId());
|
AirlineMarkerGroupInfoDTO groupInfoDTO = new AirlineMarkerGroupInfoDTO();
|
||||||
AirlineMarker airlineMarker = iAirlineMarkerDomain.selectMarker(marker);
|
groupInfoDTO.setGroupId(groupId);
|
||||||
AirlineMarkerDTO airlineMarkerDTO = AirlineMarkerServiceConvert.from(airlineMarker);
|
List<AirlineMarkerGroupInfoDTO> groupInfos = iAirlineMarkerGroupInfoService.selectMarkerGroupInfoList(groupInfoDTO);
|
||||||
airlineMarkerDTO.setGroupId(groupInfos.get(0).getGroupId());
|
List<AirlineMarkerDTO> result= new ArrayList<>();
|
||||||
result.add(airlineMarkerDTO);
|
for (AirlineMarkerGroupInfoDTO groupInfo : groupInfos) {
|
||||||
|
AirlineMarker model = iAirlineMarkerDomain.selectMarkerById(groupInfo.getMarkerId());
|
||||||
|
AirlineMarkerDTO dto = AirlineMarkerServiceConvert.from(model);
|
||||||
|
dto.setGroupId(groupId);
|
||||||
|
result.add(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AirlineMarkerDTO selectMarkerById(Long id) {
|
|
||||||
AirlineMarker model = iAirlineMarkerDomain.selectMarkerById(id);
|
|
||||||
AirlineMarkerDTO dto = AirlineMarkerServiceConvert.from(model);
|
|
||||||
|
|
||||||
// 查询分组关系
|
|
||||||
AirlineMarkerGroupInfoDTO groupInfoDTO = new AirlineMarkerGroupInfoDTO();
|
|
||||||
groupInfoDTO.setMarkerId(id);
|
|
||||||
List<AirlineMarkerGroupInfoDTO> groupInfos = iAirlineMarkerGroupInfoService.selectMarkerGroupInfoList(groupInfoDTO);
|
|
||||||
if (!groupInfos.isEmpty()) {
|
|
||||||
dto.setGroupId(groupInfos.get(0).getGroupId());
|
|
||||||
}
|
|
||||||
|
|
||||||
return dto;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AirlineMarkerDTO> selectMarkerListByGroupId(Long groupId) {
|
public int batchDeleteMarker(List<Long> markerIds) {
|
||||||
// 通过分组ID查询标注ID列表
|
|
||||||
List<Long> markerIds = iAirlineMarkerGroupInfoService.selectMarkerIdsByGroupId(groupId);
|
|
||||||
|
|
||||||
// 如果没有标注,返回空列表
|
|
||||||
if (markerIds == null || markerIds.isEmpty()) {
|
if (markerIds == null || markerIds.isEmpty()) {
|
||||||
return java.util.Collections.emptyList();
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过标注ID列表查询标注详情
|
int deletedCount = 0;
|
||||||
List<AirlineMarker> markers = iAirlineMarkerDomain.selectMarkerListByIds(markerIds);
|
for (Long markerId : markerIds) {
|
||||||
List<AirlineMarkerDTO> dtos = AirlineMarkerServiceConvert.fromList(markers);
|
|
||||||
|
|
||||||
// 为每个标注设置分组ID
|
// 先删除分组关系
|
||||||
dtos.forEach(dto -> dto.setGroupId(groupId));
|
iAirlineMarkerGroupInfoService.deleteByMarkerId(markerId);
|
||||||
|
|
||||||
return dtos;
|
// 再置失效
|
||||||
|
AirlineMarker marker = new AirlineMarker();
|
||||||
|
marker.setId(markerId);
|
||||||
|
marker.setUpdateBy(SecurityUtils.getUserId().toString());
|
||||||
|
int result = iAirlineMarkerDomain.deleteMarker(marker);
|
||||||
|
if (result > 0) {
|
||||||
|
deletedCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return deletedCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select id, marker_name, marker_type, status, color, icon, font_size, coordinates, description, create_by, create_time, update_by, update_time, remark
|
select id, marker_name, marker_type, status, color, icon, font_size, coordinates, description, create_by, create_time, update_by, update_time, remark
|
||||||
from airline_marker
|
from airline_marker
|
||||||
<where>
|
<where>
|
||||||
|
status = 1
|
||||||
|
<if test="id != null">
|
||||||
|
and id = #{id}
|
||||||
|
</if>
|
||||||
<if test="markerName != null and markerName != ''">
|
<if test="markerName != null and markerName != ''">
|
||||||
and marker_name like concat('%', #{markerName}, '%')
|
and marker_name like concat('%', #{markerName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -86,6 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<foreach item="id" collection="list" open="(" separator="," close=")">
|
<foreach item="id" collection="list" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
and status = 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 根据用户ID查询标注列表 -->
|
<!-- 根据用户ID查询标注列表 -->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue