Compare commits

...

7 Commits

6 changed files with 53 additions and 22 deletions

16
pom.xml
View File

@ -39,6 +39,20 @@
<properties>
<native.classifier>windows-x86_64</native.classifier>
</properties>
<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg</artifactId>
<version>7.1.1-1.5.12</version>
<classifier>${native.classifier}</classifier>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencv</artifactId>
<version>4.11.0-1.5.12</version>
<classifier>${native.classifier}</classifier>
</dependency>
</dependencies>
</profile>
<profile>
<id>prod-linux</id>
@ -227,8 +241,6 @@
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg</artifactId>
<version>7.1.1-1.5.12</version>
<scope>provided</scope>
<classifier>windows-x86_64</classifier>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>

View File

@ -5,6 +5,7 @@ import com.google.gson.reflect.TypeToken;
import com.imyeyu.api.bean.CaptchaFrom;
import com.imyeyu.api.modules.common.bean.ImageType;
import com.imyeyu.api.modules.common.bean.SettingKey;
import com.imyeyu.api.modules.common.bean.TempFileMetaData;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.entity.Setting;
import com.imyeyu.api.modules.common.entity.Task;
@ -432,6 +433,7 @@ public class CommonController {
@RequestMapping("/temp/file/download/{fileId}")
public void tempFileDownload(@PathVariable String fileId, HttpServletResponse resp) {
try {
TempFileMetaData metadata = tempFileService.metadata(fileId);
File file = tempFileService.get(fileId);
if (TimiJava.isEmpty(file) && file.exists()) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
@ -439,7 +441,7 @@ public class CommonController {
}
String mimeType = new Tika().detect(file);
resp.setContentType(mimeType);
resp.setHeader("Content-Disposition", Network.getFileDownloadHeader(file.getName()));
resp.setHeader("Content-Disposition", Network.getFileDownloadHeader(metadata.getOriginalName()));
resp.setHeader("Accept-Ranges", "bytes");
RequestRange range = TimiSpring.requestRange(file.length());

View File

@ -61,7 +61,6 @@ public class Travel extends Entity {
}
/** 交通类型 */
@PageIgnore
private TransportationType transportationType;
/** 标题 */
@ -75,7 +74,6 @@ public class Travel extends Entity {
private Long travelAt;
/** 天数 */
@PageIgnore
private Integer days;
/** 状态 */

View File

@ -27,23 +27,26 @@ public class TravelLocation extends Entity {
*/
public enum Type {
/** 景点 */
ATTRACTION,
/** 美食 */
FOOD,
/** 酒店 */
HOTEL,
/** 餐厅 */
RESTAURANT,
/** 交通站点 */
TRANSPORT,
/** 景点 */
ATTRACTION,
/** 购物 */
SHOPPING,
/** 其他 */
OTHER
/** 玩乐 */
PLAY,
/** 生活 */
LIFE,
}
/** 旅行计划 ID */
@ -73,9 +76,15 @@ public class TravelLocation extends Entity {
/** true 为需要身份证 */
private Boolean requireIdCard;
/** 必要评分 */
/** true 为需要预约 */
private Boolean requireAppointment;
/** 评分 */
private Integer score;
/** 重要程度 */
private Integer importance;
@Transient
private Long[] attachmentIds;

View File

@ -62,16 +62,19 @@ public class TravelLocationServiceImplement extends AbstractEntityService<Travel
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void update(TravelLocation travelLocation) {
super.update(travelLocation);
// 使用 update 以允许设置 score 和 importance 为 null
mapper.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])) {

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) {