fix travel location update fail

This commit is contained in:
Timi
2025-12-17 10:21:16 +08:00
parent 42bcfcf70e
commit fe86a84204
3 changed files with 33 additions and 9 deletions

View File

@ -73,9 +73,24 @@ public class TravelLocation extends Entity {
/** true 为需要身份证 */
private Boolean requireIdCard;
/** 必要评分 */
/** true 为需要预约 */
private Boolean requireAppointment;
/** 首次出行时间 */
private Long firstTraveledAt;
/** 上次出行时间 */
private Long lastTraveledAt;
/** 出行次数 */
private Integer travelCount;
/** 评分 */
private Integer score;
/** 重要程度 */
private Integer importance;
@Transient
private Long[] attachmentIds;

View File

@ -64,15 +64,17 @@ public class TravelLocationServiceImplement extends AbstractEntityService<Travel
public void update(TravelLocation travelLocation) {
super.update(travelLocation);
// 删除
if (TimiJava.isNotEmpty(travelLocation.getAttachmentIds())) {
Set<Long> dbAttachSet = attachmentService.listByBizId(Attachment.BizType.JOURNAL_TRAVEL, travelLocation.getId(), MediaAttach.Type.THUMB)
.stream()
.map(Attachment::getId)
.collect(Collectors.toSet());
Set<Long> retainIds = Set.of(TimiJava.firstNotEmpty(travelLocation.getAttachmentIds(), new Long[0]));
Set<Long> retainIds = Set.of(travelLocation.getAttachmentIds());
dbAttachSet.removeAll(retainIds);
for (Long removeId : dbAttachSet) {
attachmentService.deleteMedia(removeId);
}
}
// 新增
for (String tempFileId : TimiJava.firstNotNull(travelLocation.getTempFileIds(), new String[0])) {
TempFileMetaData metadata = tempFileService.metadata(tempFileId);

View File

@ -31,6 +31,13 @@ public class TravelServiceImplement extends AbstractEntityService<Travel, Long>
return mapper;
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void update(Travel travel) {
// 使用 update 以允许设置 travelAt 和 days 为 null
mapper.update(travel);
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void delete(Long id) {