diff --git a/src/main/java/com/rymcu/forest/entity/Tag.java b/src/main/java/com/rymcu/forest/entity/Tag.java index a5c8b2d..074ae54 100644 --- a/src/main/java/com/rymcu/forest/entity/Tag.java +++ b/src/main/java/com/rymcu/forest/entity/Tag.java @@ -3,10 +3,7 @@ package com.rymcu.forest.entity; import lombok.Data; -import javax.persistence.Column; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; import java.io.Serializable; import java.util.Date; @@ -75,4 +72,9 @@ public class Tag implements Serializable, Cloneable { * 描述 */ private String tagDescriptionHtml; + /** + * 图标类型 + */ + @Transient + private transient String tagImageType; } diff --git a/src/main/java/com/rymcu/forest/entity/Topic.java b/src/main/java/com/rymcu/forest/entity/Topic.java index ed8168d..83c10cc 100644 --- a/src/main/java/com/rymcu/forest/entity/Topic.java +++ b/src/main/java/com/rymcu/forest/entity/Topic.java @@ -3,10 +3,7 @@ package com.rymcu.forest.entity; import lombok.Data; -import javax.persistence.Column; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; import java.util.Date; /** @@ -71,5 +68,10 @@ public class Topic { * 专题描述 Html */ private String topicDescriptionHtml; + /** + * 专题图片类型 + */ + @Transient + private transient String topicImageType; } diff --git a/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java index d060687..ae872b2 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java @@ -10,6 +10,7 @@ import com.rymcu.forest.dto.ArticleTagDTO; import com.rymcu.forest.dto.LabelModel; import com.rymcu.forest.entity.Article; import com.rymcu.forest.entity.Tag; +import com.rymcu.forest.enumerate.FileDataType; import com.rymcu.forest.enumerate.FilePath; import com.rymcu.forest.mapper.ArticleMapper; import com.rymcu.forest.mapper.TagMapper; @@ -126,7 +127,7 @@ public class TagServiceImpl extends AbstractService implements TagService { throw new BusinessException("标签 '" + tag.getTagTitle() + "' 已存在!"); } } - if (StringUtils.isNotBlank(tag.getTagIconPath()) && tag.getTagIconPath().contains("base64")) { + if (FileDataType.BASE64.equals(tag.getTagImageType())) { String tagIconPath = UploadController.uploadBase64File(tag.getTagIconPath(), FilePath.TAG); tag.setTagIconPath(tagIconPath); } else { @@ -137,7 +138,7 @@ public class TagServiceImpl extends AbstractService implements TagService { result = tagMapper.insertSelective(tag); } else { tag.setUpdatedTime(new Date()); - if (StringUtils.isNotBlank(tag.getTagIconPath()) && tag.getTagIconPath().contains("base64")) { + if (FileDataType.BASE64.equals(tag.getTagImageType())) { String tagIconPath = UploadController.uploadBase64File(tag.getTagIconPath(), FilePath.TAG); tag.setTagIconPath(tagIconPath); } diff --git a/src/main/java/com/rymcu/forest/service/impl/TopicServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/TopicServiceImpl.java index 787d9df..f92dcf0 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TopicServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TopicServiceImpl.java @@ -8,6 +8,7 @@ import com.rymcu.forest.dto.admin.TopicDTO; import com.rymcu.forest.dto.admin.TopicTagDTO; import com.rymcu.forest.entity.Tag; import com.rymcu.forest.entity.Topic; +import com.rymcu.forest.enumerate.FileDataType; import com.rymcu.forest.enumerate.FilePath; import com.rymcu.forest.mapper.TopicMapper; import com.rymcu.forest.service.TopicService; @@ -59,7 +60,7 @@ public class TopicServiceImpl extends AbstractService implements TopicSer throw new BusinessException("专题 '" + topic.getTopicTitle() + "' 已存在!"); } } - if (StringUtils.isNotBlank(topic.getTopicIconPath()) && topic.getTopicIconPath().contains("base64")) { + if (FileDataType.BASE64.equals(topic.getTopicImageType())) { String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), FilePath.TOPIC); topic.setTopicIconPath(topicIconPath); } else { @@ -74,7 +75,7 @@ public class TopicServiceImpl extends AbstractService implements TopicSer topic.setUpdatedTime(topic.getCreatedTime()); result = topicMapper.insertSelective(topic); } else { - if (StringUtils.isNotBlank(topic.getTopicIconPath()) && topic.getTopicIconPath().contains("base64")) { + if (FileDataType.BASE64.equals(topic.getTopicImageType())) { String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), FilePath.TOPIC); topic.setTopicIconPath(topicIconPath); }