fit:航线管理,增加批量移动分组的功能

This commit is contained in:
高大 2026-01-29 17:49:03 +08:00
parent c136e237fb
commit f27bfc33a2
7 changed files with 91 additions and 0 deletions

View File

@ -172,5 +172,26 @@ public class AirlineFileGroupInfoController extends BaseController {
throw new BaseException("移动失败"); throw new BaseException("移动失败");
} }
@PostMapping("/move/{groupId}/{newGroupId}")
@Operation(summary = "批量移动分组详情到新分组")
public AjaxResult batchMove(@RequestBody List<Long> airlines, @PathVariable("groupId") Long groupId, @PathVariable("newGroupId") Long newGroupId) throws BaseException {
if (groupId == null) {
throw new BaseException("原分组ID不能为空");
}
if (newGroupId == null) {
throw new BaseException("新分组ID不能为空");
}
if (CollectionUtils.isEmpty(airlines)) {
throw new BaseException("没有需要移动的航线");
}
Long result = iAirlineFileGroupInfoService.batchMoveGroupInfo(
airlines, groupId, newGroupId
);
if (result > 0) {
return success(result);
}
throw new BaseException("移动失败");
}
} }

View File

@ -50,4 +50,14 @@ public interface IAirlineFileGroupInfoDomain {
* @return 结果 * @return 结果
*/ */
Long deleteGroupInfoBatch(List<Long> airLineIds, Long groupId); Long deleteGroupInfoBatch(List<Long> airLineIds, Long groupId);
/**
* 批量移动分组详情到新分组
*
* @param oldGroupId 原分组ID
* @param newGroupId 新分组ID
* @param airLineIds 航线ID列表
* @return 结果
*/
Long batchMoveGroupInfo(Long oldGroupId, Long newGroupId, List<Long> airLineIds);
} }

View File

@ -63,4 +63,9 @@ public class AirlineFileGroupInfoDomainImpl implements IAirlineFileGroupInfoDoma
public Long deleteGroupInfoBatch(List<Long> airLineIds, Long groupId) { public Long deleteGroupInfoBatch(List<Long> airLineIds, Long groupId) {
return airlineFileGroupInfoMapper.deleteGroupInfoBatch(airLineIds, groupId); return airlineFileGroupInfoMapper.deleteGroupInfoBatch(airLineIds, groupId);
} }
@Override
public Long batchMoveGroupInfo(Long oldGroupId, Long newGroupId, List<Long> airLineIds) {
return airlineFileGroupInfoMapper.batchUpdateGroupId(oldGroupId, newGroupId, airLineIds);
}
} }

View File

@ -45,4 +45,14 @@ public interface AirlineFileGroupInfoMapper {
* @return 影响的行数 * @return 影响的行数
*/ */
Long deleteGroupInfoBatch(List<Long> airLineIds, Long groupId); Long deleteGroupInfoBatch(List<Long> airLineIds, Long groupId);
/**
* 批量更新分组ID将航线文件从一个分组移动到另一个分组
*
* @param oldGroupId 原分组ID
* @param newGroupId 新分组ID
* @param airLineIds 航线文件ID列表
* @return 影响的行数
*/
Long batchUpdateGroupId(Long oldGroupId, Long newGroupId, List<Long> airLineIds);
} }

View File

@ -35,4 +35,14 @@ public interface IAirlineFileGroupInfoService {
* @throws BaseException * @throws BaseException
*/ */
Long deleteGroupInfoBatch(List<Long> airLineIds, Long groupId) throws BaseException; Long deleteGroupInfoBatch(List<Long> airLineIds, Long groupId) throws BaseException;
/**
* 批量移动分组详情到新分组
* @param airLineIds 航线ID列表
* @param groupId 原分组ID
* @param newGroupId 新分组ID
* @return
* @throws BaseException
*/
Long batchMoveGroupInfo(List<Long> airLineIds, Long groupId, Long newGroupId) throws BaseException;
} }

View File

@ -111,4 +111,26 @@ public class AirlineFileServiceGroupInfoImpl implements IAirlineFileGroupInfoSer
// 调用domain层批量删除方法 // 调用domain层批量删除方法
return iAirlineFileGroupInfoDomain.deleteGroupInfoBatch(airLineIds, groupId); return iAirlineFileGroupInfoDomain.deleteGroupInfoBatch(airLineIds, groupId);
} }
@Override
public Long batchMoveGroupInfo(List<Long> airLineIds, Long groupId, Long newGroupId) throws BaseException {
// 检查参数
if (groupId == null || newGroupId == null || airLineIds == null || airLineIds.isEmpty()) {
throw new BaseException("原分组ID、新分组ID和航线ID列表不能为空");
}
// 为每个航线生成新的文件名并更新
for (Long airlineId : airLineIds) {
AirlineFileDTO airlineFile = iAirlineFileService.selectById(airlineId);
if (airlineFile != null) {
String name = airlineFile.getName();
name = iAirlineFileService.getNewFileNameLikeByGroupId(name, newGroupId);
airlineFile.setName(name);
iAirlineFileService.update(airlineFile);
}
}
// 调用domain层批量移动方法
return iAirlineFileGroupInfoDomain.batchMoveGroupInfo(groupId, newGroupId, airLineIds);
}
} }

View File

@ -88,4 +88,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{airlineId} #{airlineId}
</foreach> </foreach>
</update> </update>
<!-- 批量更新分组ID将航线文件从一个分组移动到另一个分组 -->
<update id="batchUpdateGroupId">
update airline_file_group_info
set group_id = #{newGroupId},
update_time = now()
where del_flag = 0
and group_id = #{oldGroupId}
and airline_id in
<foreach item="airlineId" collection="airLineIds" open="(" separator="," close=")">
#{airlineId}
</foreach>
</update>
</mapper> </mapper>