tsurumure 1 hónapja
szülő
commit
4af1707be8

+ 4 - 0
src/main/java/com/backendsys/modules/material/entity/Material.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.gson.annotations.JsonAdapter;
 import jakarta.validation.constraints.NotEmpty;
 import jakarta.validation.constraints.NotNull;
@@ -62,8 +63,11 @@ public class Material {
     @RangeArray(message="是否有版权,范围应是(-1否, 1是)", value = {"-1", "1"}, groups = { Create.class, Update.class })
     private Integer is_copyright;
 
+    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
     @JsonAdapter(LocalDateTimeAdapter.class)
     private LocalDateTime create_time;
+
+    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
     @JsonAdapter(LocalDateTimeAdapter.class)
     private LocalDateTime update_time;
 

+ 5 - 5
src/main/java/com/backendsys/modules/material/service/impl/MaterialServiceImpl.java

@@ -108,11 +108,11 @@ public class MaterialServiceImpl implements MaterialService {
 
         ObjectKeyEntity objectKeyEntity = objectKeyUtil.urlToObjectKey(material.getImage_url());
 
-        // 新需求:高清图也要返回压缩地址
-        if (StrUtil.isNotEmpty(material.getImage_url())) {
-            String image_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 315, null, null, true);
-            material.setImage_url(image_url);
-        }
+//        // 错误做法:原图地址不能加参数,否则缩略图会重复加参数
+//        if (StrUtil.isNotEmpty(material.getImage_url())) {
+//            String image_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 315, null, null, true);
+//            material.setImage_url(image_url);
+//        }
 
         // 生成缩略图,并填充缩略图地址
         if (StrUtil.isNotEmpty(material.getImage_url())) {

+ 1 - 0
src/main/java/com/backendsys/modules/upload/utils/ObjectKey/ObjectKeyUtil.java

@@ -39,6 +39,7 @@ public class ObjectKeyUtil {
     public ObjectKeyEntity urlToObjectKey(String url) {
         String prefix = null;
         Integer target = -1;
+        if (url == null) return null;
         if (url.startsWith(TENCENT_DOMAIN)) {
             prefix = TENCENT_DOMAIN;
             target = 1;