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 为需要身份证 */ /** true 为需要身份证 */
private Boolean requireIdCard; private Boolean requireIdCard;
/** 必要评分 */ /** true 为需要预约 */
private Boolean requireAppointment;
/** 首次出行时间 */
private Long firstTraveledAt;
/** 上次出行时间 */
private Long lastTraveledAt;
/** 出行次数 */
private Integer travelCount;
/** 评分 */
private Integer score; private Integer score;
/** 重要程度 */
private Integer importance;
@Transient @Transient
private Long[] attachmentIds; private Long[] attachmentIds;

View File

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

View File

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