fix:设备分页返回第一张图片
This commit is contained in:
parent
7590c9edc4
commit
281989b011
@ -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";
|
||||
|
||||
}
|
@ -37,4 +37,7 @@ public class AircraftDevicePageVO extends AircraftDevice {
|
||||
@ApiModelProperty(value = "飞行员(负责人)名称")
|
||||
private Long employeesName;
|
||||
|
||||
@ApiModelProperty(value = "设备图片(只返回一张)")
|
||||
private String deviceImg;
|
||||
|
||||
}
|
||||
|
@ -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<AircraftDeviceMapper,
|
||||
if (UserTypeEnum.EMPLOYEES.equals(SecurityUtils.getCurrentUserType())) {
|
||||
dto.setEmployeesId(SecurityUtils.getCurrentUserId());
|
||||
}
|
||||
return baseMapper.page(dto, page);
|
||||
|
||||
IPage<AircraftDevicePageVO> 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
|
||||
|
Loading…
Reference in New Issue
Block a user