fix travel location update fail
This commit is contained in:
@ -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;
|
||||
|
||||
|
||||
@ -64,14 +64,16 @@ public class TravelLocationServiceImplement extends AbstractEntityService<Travel
|
||||
public void update(TravelLocation travelLocation) {
|
||||
super.update(travelLocation);
|
||||
// 删除
|
||||
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]));
|
||||
dbAttachSet.removeAll(retainIds);
|
||||
for (Long removeId : dbAttachSet) {
|
||||
attachmentService.deleteMedia(removeId);
|
||||
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(travelLocation.getAttachmentIds());
|
||||
dbAttachSet.removeAll(retainIds);
|
||||
for (Long removeId : dbAttachSet) {
|
||||
attachmentService.deleteMedia(removeId);
|
||||
}
|
||||
}
|
||||
// 新增
|
||||
for (String tempFileId : TimiJava.firstNotNull(travelLocation.getTempFileIds(), new String[0])) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user