feat:增加批量移动接口,优化查询接口逻辑
This commit is contained in:
parent
e761efb850
commit
c7793d7c71
|
|
@ -98,8 +98,10 @@ public class AirlineMarkerController extends BaseController {
|
|||
*/
|
||||
@GetMapping("/user-available")
|
||||
@Operation(summary = "获取用户下所有可用标注")
|
||||
public AjaxResult getUserAvailableMarkers() {
|
||||
List<AirlineMarkerDTO> dtoList = iAirlineMarkerGroupInfoService.selectUserAvailableMarkers();
|
||||
public AjaxResult getUserAvailableMarkers(AirlineMarkerVO vo) {
|
||||
AirlineMarkerDTO dto = AirlineMarkerControllerConvert.to(vo);
|
||||
dto.setCreateBy(SecurityUtils.getUserId().toString());
|
||||
List<AirlineMarkerDTO> dtoList = iAirlineMarkerGroupInfoService.selectAllAvailableMarkers(dto);
|
||||
List<AirlineMarkerVO> result = AirlineMarkerControllerConvert.fromList(dtoList);
|
||||
return success(result);
|
||||
}
|
||||
|
|
@ -109,8 +111,10 @@ public class AirlineMarkerController extends BaseController {
|
|||
*/
|
||||
@GetMapping("/all-available")
|
||||
@Operation(summary = "获取全部可用标注")
|
||||
public AjaxResult getAllAvailableMarkers() {
|
||||
List<AirlineMarkerDTO> dtoList = iAirlineMarkerGroupInfoService.selectAllAvailableMarkers();
|
||||
public AjaxResult getAllAvailableMarkers(AirlineMarkerVO vo) {
|
||||
AirlineMarkerDTO dto = AirlineMarkerControllerConvert.to(vo);
|
||||
dto.setStatus(1);
|
||||
List<AirlineMarkerDTO> dtoList = iAirlineMarkerGroupInfoService.selectAllAvailableMarkers(dto);
|
||||
List<AirlineMarkerVO> result = AirlineMarkerControllerConvert.fromList(dtoList);
|
||||
return success(result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,11 @@ public interface IAirlineMarkerDomain {
|
|||
* @return 标注列表
|
||||
*/
|
||||
List<AirlineMarker> selectMarkerListByUserId(AirlineMarker model);
|
||||
|
||||
/**
|
||||
* 查询所有可用标注(关联分组信息表)
|
||||
* @param model 查询条件
|
||||
* @return 标注列表
|
||||
*/
|
||||
List<AirlineMarker> selectAllAvailableMarkers(AirlineMarker model);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,4 +78,10 @@ public class AirlineMarkerDomainImpl implements IAirlineMarkerDomain {
|
|||
AirlineMarkerEntity entity = AirlineMarkerDomainConvert.to(model);
|
||||
return AirlineMarkerDomainConvert.fromList(airlineMarkerMapper.selectMarkerListByUserId(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AirlineMarker> selectAllAvailableMarkers(AirlineMarker model) {
|
||||
AirlineMarkerEntity entity = AirlineMarkerDomainConvert.to(model);
|
||||
return AirlineMarkerDomainConvert.fromList(airlineMarkerMapper.selectAllAvailableMarkers(entity));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,4 +29,11 @@ public interface AirlineMarkerMapper {
|
|||
* @return 标注列表
|
||||
*/
|
||||
List<AirlineMarkerEntity> selectMarkerListByUserId(AirlineMarkerEntity entity);
|
||||
|
||||
/**
|
||||
* 查询所有可用标注(关联分组信息表)
|
||||
* @param entity 查询条件
|
||||
* @return 标注列表
|
||||
*/
|
||||
List<AirlineMarkerEntity> selectAllAvailableMarkers(AirlineMarkerEntity entity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@ public interface IAirlineMarkerGroupInfoService {
|
|||
|
||||
/**
|
||||
* 获取全部可用标注
|
||||
* @param dto 查询条件
|
||||
* @return 标注列表
|
||||
*/
|
||||
List<AirlineMarkerDTO> selectAllAvailableMarkers();
|
||||
List<AirlineMarkerDTO> selectAllAvailableMarkers(AirlineMarkerDTO dto);
|
||||
|
||||
/**
|
||||
* 批量移动标注到指定分组
|
||||
|
|
|
|||
|
|
@ -161,42 +161,24 @@ public class AirlineMarkerGroupInfoServiceImpl implements IAirlineMarkerGroupInf
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<AirlineMarkerDTO> selectAllAvailableMarkers() {
|
||||
// 先获取所有未被删除的标注分组关系
|
||||
AirlineMarkerGroupInfo groupInfo = new AirlineMarkerGroupInfo();
|
||||
// 只查询未被删除的记录(deletedBy 为 null)
|
||||
List<AirlineMarkerGroupInfo> groupInfos = iAirlineMarkerGroupInfoDomain.selectMarkerGroupInfoList(groupInfo);
|
||||
|
||||
if (groupInfos == null || groupInfos.isEmpty()) {
|
||||
return List.of();
|
||||
public List<AirlineMarkerDTO> selectAllAvailableMarkers(AirlineMarkerDTO queryDto) {
|
||||
// 将 DTO 转换为 Model,用于查询条件
|
||||
AirlineMarker model = new AirlineMarker();
|
||||
if (queryDto != null) {
|
||||
model.setCreateBy(queryDto.getCreateBy());
|
||||
model.setMarkerName(queryDto.getMarkerName());
|
||||
model.setMarkerType(queryDto.getMarkerType());
|
||||
}
|
||||
|
||||
// 提取标注ID列表
|
||||
List<Long> markerIds = groupInfos.stream()
|
||||
.map(AirlineMarkerGroupInfo::getMarkerId)
|
||||
.distinct()
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
|
||||
if (markerIds.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
// 根据标注ID列表查询标注详情
|
||||
List<AirlineMarker> markers = iAirlineMarkerDomain.selectMarkerListByIds(markerIds);
|
||||
// 直接通过 XML 关联 SQL 查询所有可用标注
|
||||
List<AirlineMarker> markers = iAirlineMarkerDomain.selectAllAvailableMarkers(model);
|
||||
|
||||
if (markers == null || markers.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
// 过滤出启用的标注
|
||||
List<AirlineMarkerDTO> availableMarkers = new ArrayList<>();
|
||||
for (AirlineMarker airlineMarker : markers) {
|
||||
if (airlineMarker.getStatus() == 1) {
|
||||
availableMarkers.add(AirlineMarkerServiceConvert.from(airlineMarker));
|
||||
}
|
||||
}
|
||||
|
||||
return availableMarkers;
|
||||
// 转换为 DTO 并返回
|
||||
return AirlineMarkerServiceConvert.fromList(markers);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -31,17 +31,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<!-- 更新标注 -->
|
||||
<update id="updateMarker" parameterType="com.ruoyi.airline.mapper.entity.AirlineMarkerEntity">
|
||||
update airline_marker
|
||||
set marker_name = #{markerName},
|
||||
<set>
|
||||
<if test="markerName != null and markerName != ''">
|
||||
marker_name = #{markerName},
|
||||
</if>
|
||||
<if test="markerType != null and markerType != ''">
|
||||
marker_type = #{markerType},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="color != null and color != ''">
|
||||
color = #{color},
|
||||
</if>
|
||||
<if test="icon != null and icon != ''">
|
||||
icon = #{icon},
|
||||
</if>
|
||||
<if test="fontSize != null">
|
||||
font_size = #{fontSize},
|
||||
</if>
|
||||
<if test="coordinates != null">
|
||||
coordinates = #{coordinates},
|
||||
</if>
|
||||
<if test="description != null and description != ''">
|
||||
description = #{description},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by = #{updateBy},
|
||||
</if>
|
||||
update_time = now(),
|
||||
remark = #{remark}
|
||||
<if test="remark != null and remark != ''">
|
||||
remark = #{remark},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
|
@ -117,4 +139,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 查询所有可用标注(关联分组信息表) -->
|
||||
<select id="selectAllAvailableMarkers" parameterType="com.ruoyi.airline.mapper.entity.AirlineMarkerEntity" resultMap="AirlineMarkerResult">
|
||||
select distinct am.id, am.marker_name, am.marker_type, am.status, am.color, am.icon, am.font_size, am.coordinates, am.description, am.create_by, am.create_time, am.update_by, am.update_time, am.remark
|
||||
from airline_marker am
|
||||
inner join airline_marker_group_info amgi on am.id = amgi.marker_id
|
||||
<where>
|
||||
amgi.del_flag = 0
|
||||
and amgi.deleted_by is null
|
||||
and amgi.deleted_time is null
|
||||
<if test="createBy != null and createBy != ''">
|
||||
and am.create_by = #{createBy}
|
||||
</if>
|
||||
<if test="markerName != null and markerName != ''">
|
||||
and am.marker_name like concat('%', #{markerName}, '%')
|
||||
</if>
|
||||
<if test="markerType != null and markerType != ''">
|
||||
and am.marker_type = #{markerType}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue