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