From 281989b0111e5d3f57353290a86aeebe5e76bea4 Mon Sep 17 00:00:00 2001 From: sugus <1020570875@qq.com> Date: Fri, 8 Aug 2025 10:16:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=AE=BE=E5=A4=87=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=AC=AC=E4=B8=80=E5=BC=A0=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/aircraft/utils/CommonConstant.java | 30 +++++++++++++++++++ .../domain/vo/AircraftDevicePageVO.java | 3 ++ .../impl/AircraftDeviceServiceImpl.java | 20 +++++++++++-- 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 aircraft-common/src/main/java/com/aircraft/utils/CommonConstant.java diff --git a/aircraft-common/src/main/java/com/aircraft/utils/CommonConstant.java b/aircraft-common/src/main/java/com/aircraft/utils/CommonConstant.java new file mode 100644 index 0000000..5b85e41 --- /dev/null +++ b/aircraft-common/src/main/java/com/aircraft/utils/CommonConstant.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019-2025 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aircraft.utils; + +/** + * 常用静态常量 + * + * @author Zheng Jie + * @date 2018-12-26 + */ +public class CommonConstant { + /** + * LIMIT_ONE + */ + public static final String LIMIT_ONE = "LIMIT 1"; + +} diff --git a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/vo/AircraftDevicePageVO.java b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/vo/AircraftDevicePageVO.java index c6cd711..bf0235c 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/vo/AircraftDevicePageVO.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/domain/vo/AircraftDevicePageVO.java @@ -37,4 +37,7 @@ public class AircraftDevicePageVO extends AircraftDevice { @ApiModelProperty(value = "飞行员(负责人)名称") private Long employeesName; + @ApiModelProperty(value = "设备图片(只返回一张)") + private String deviceImg; + } diff --git a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftDeviceServiceImpl.java b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftDeviceServiceImpl.java index 564fa97..cc5f284 100644 --- a/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftDeviceServiceImpl.java +++ b/aircraft-system/src/main/java/com/aircraft/modules/aircraft/service/impl/AircraftDeviceServiceImpl.java @@ -9,6 +9,7 @@ import com.aircraft.modules.aircraft.mapper.AircraftDeviceMapper; import com.aircraft.modules.aircraft.service.AircraftDeviceService; import com.aircraft.modules.system.domain.AttachmentMaterial; import com.aircraft.modules.system.service.IAttachmentMaterialService; +import com.aircraft.utils.CommonConstant; import com.aircraft.utils.SecurityUtils; import com.aircraft.utils.enums.UserTypeEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -48,8 +49,23 @@ public class AircraftDeviceServiceImpl extends ServiceImpl iPage = baseMapper.page(dto, page); + if (null != iPage && CollectionUtils.isNotEmpty(iPage.getRecords())) { + iPage.getRecords().forEach(item -> { + // 获取设备图片(只取第一张) + attachmentMaterialService + .lambdaQuery() + .select(AttachmentMaterial::getFileFullPath) + .eq(AttachmentMaterial::getBusinessType, BUSINESS_TYPE) + .eq(AttachmentMaterial::getBusinessId, item.getId()) + .orderByAsc(AttachmentMaterial::getId) + .last(CommonConstant.LIMIT_ONE) + .oneOpt() + .map(AttachmentMaterial::getFileFullPath) + .ifPresent(item::setDeviceImg); + }); + } + return iPage; } @Override