From 2bed7765bc156fe9f09d6b550d0d9785ac4388a2 Mon Sep 17 00:00:00 2001 From: ronger Date: Thu, 13 Jan 2022 22:15:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:bug:=20=E4=B8=93=E9=A2=98/=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../forest/service/impl/TagServiceImpl.java | 12 +++++- .../forest/service/impl/TopicServiceImpl.java | 14 ++++++- src/main/java/mapper/TagMapper.xml | 38 ++++++++++++++---- src/main/java/mapper/TopicMapper.xml | 39 +++++++++++++++---- 4 files changed, 85 insertions(+), 18 deletions(-) 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 54a18ff..62504c8 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java @@ -13,6 +13,7 @@ import com.rymcu.forest.service.TagService; import com.rymcu.forest.util.BaiDuAipUtils; import com.rymcu.forest.util.CacheUtils; import com.rymcu.forest.util.UserUtils; +import com.rymcu.forest.web.api.common.UploadController; import com.rymcu.forest.web.api.exception.BaseApiException; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; @@ -142,7 +143,12 @@ public class TagServiceImpl extends AbstractService implements TagService { Tag newTag = new Tag(); newTag.setTagTitle(tag.getTagTitle()); newTag.setTagUri(tag.getTagUri()); - newTag.setTagIconPath(tag.getTagIconPath()); + if (StringUtils.isNotBlank(tag.getTagIconPath()) && tag.getTagIconPath().contains("base64")) { + String tagIconPath = UploadController.uploadBase64File(tag.getTagIconPath(), 0); + newTag.setTagIconPath(tagIconPath); + } else { + newTag.setTagIconPath(tag.getTagIconPath()); + } newTag.setTagStatus(tag.getTagStatus()); newTag.setTagDescription(tag.getTagDescription()); newTag.setTagReservation(tag.getTagReservation()); @@ -151,6 +157,10 @@ public class TagServiceImpl extends AbstractService implements TagService { result = tagMapper.insertSelective(newTag); } else { tag.setUpdatedTime(new Date()); + if (StringUtils.isNotBlank(tag.getTagIconPath()) && tag.getTagIconPath().contains("base64")) { + String tagIconPath = UploadController.uploadBase64File(tag.getTagIconPath(), 0); + tag.setTagIconPath(tagIconPath); + } result = tagMapper.update(tag.getIdTag(), tag.getTagUri(), tag.getTagIconPath(), tag.getTagStatus(), tag.getTagDescription(), tag.getTagReservation()); } if (result == 0) { 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 9a184d2..4b3d021 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TopicServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TopicServiceImpl.java @@ -10,6 +10,7 @@ import com.rymcu.forest.entity.Tag; import com.rymcu.forest.entity.Topic; import com.rymcu.forest.mapper.TopicMapper; import com.rymcu.forest.service.TopicService; +import com.rymcu.forest.web.api.common.UploadController; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -64,7 +65,12 @@ public class TopicServiceImpl extends AbstractService implements TopicSer Topic newTopic = new Topic(); newTopic.setTopicTitle(topic.getTopicTitle()); newTopic.setTopicUri(topic.getTopicUri()); - newTopic.setTopicIconPath(topic.getTopicIconPath()); + if (StringUtils.isNotBlank(topic.getTopicIconPath()) && topic.getTopicIconPath().contains("base64")) { + String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), 0); + newTopic.setTopicIconPath(topicIconPath); + } else { + newTopic.setTopicIconPath(topic.getTopicIconPath()); + } newTopic.setTopicNva(topic.getTopicNva()); newTopic.setTopicStatus(topic.getTopicStatus()); newTopic.setTopicSort(topic.getTopicSort()); @@ -74,7 +80,11 @@ public class TopicServiceImpl extends AbstractService implements TopicSer newTopic.setUpdatedTime(topic.getCreatedTime()); result = topicMapper.insertSelective(newTopic); } else { - topic.setCreatedTime(new Date()); + if (StringUtils.isNotBlank(topic.getTopicIconPath()) && topic.getTopicIconPath().contains("base64")) { + String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), 0); + topic.setTopicIconPath(topicIconPath); + } + topic.setUpdatedTime(new Date()); result = topicMapper.update(topic.getIdTopic(),topic.getTopicTitle(),topic.getTopicUri() ,topic.getTopicIconPath(),topic.getTopicNva(),topic.getTopicStatus() ,topic.getTopicSort(),topic.getTopicDescription(),topic.getTopicDescriptionHtml()); diff --git a/src/main/java/mapper/TagMapper.xml b/src/main/java/mapper/TagMapper.xml index 63953f1..3a47c4d 100644 --- a/src/main/java/mapper/TagMapper.xml +++ b/src/main/java/mapper/TagMapper.xml @@ -23,24 +23,48 @@ - insert into forest_tag_article (id_tag,id_article,created_time,updated_time) values (#{idTag},#{idArticle},sysdate(),sysdate()) + insert into forest_tag_article (id_tag, id_article, created_time, updated_time) + values (#{idTag}, #{idArticle}, sysdate(), sysdate()) - insert into forest_user_tag (id_tag,id_user,type,created_time,updated_time) values (#{idTag},#{idUser},#{type},sysdate(),sysdate()) + insert into forest_user_tag (id_tag, id_user, type, created_time, updated_time) + values (#{idTag}, #{idUser}, #{type}, sysdate(), sysdate()) - update forest_tag set tag_uri = #{tagUri}, tag_icon_path = #{tagIconPath}, tag_status = #{tagStatus}, tag_description = #{tagDescription}, tag_reservation = #{tagReservation} where id = #{idTag} + update forest_tag + set tag_uri = #{tagUri}, + tag_icon_path = #{tagIconPath}, + tag_status = #{tagStatus}, + tag_description = #{tagDescription}, + tag_reservation = #{tagReservation}, + updated_time = sysdate() + where id = #{idTag} - delete from forest_tag where tag_reservation = 0 and id not in (select * from (select id_tag from forest_tag_article vta left join forest_article va on vta.id_article = va.id where va.id is not null) tmp); + delete + from forest_tag + where tag_reservation = 0 + and id not in (select * + from (select id_tag + from forest_tag_article vta + left join forest_article va on vta.id_article = va.id + where va.id is not null) tmp); \ No newline at end of file diff --git a/src/main/java/mapper/TopicMapper.xml b/src/main/java/mapper/TopicMapper.xml index cd27fc7..3f0d6dc 100644 --- a/src/main/java/mapper/TopicMapper.xml +++ b/src/main/java/mapper/TopicMapper.xml @@ -51,27 +51,50 @@ - insert into forest_topic_tag (id_topic, id_tag, created_time, updated_time) values (#{idTopic}, #{idTag}, sysdate(), sysdate()) + insert into forest_topic_tag (id_topic, id_tag, created_time, updated_time) + values (#{idTopic}, #{idTag}, sysdate(), sysdate()) - update forest_topic set topic_title = #{topicTitle},topic_uri = #{topicUri},topic_icon_path = #{topicIconPath}, updated_time = sysdate(), - topic_nva = #{topicNva},topic_status = #{topicStatus},topic_sort = #{topicSort},topic_description = #{topicDescription},topic_description_html = #{topicDescriptionHtml} + update forest_topic + set topic_title = #{topicTitle}, + topic_uri = #{topicUri}, + topic_icon_path = #{topicIconPath}, + updated_time = sysdate(), + topic_nva = #{topicNva}, + topic_status = #{topicStatus}, + topic_sort = #{topicSort}, + topic_description = #{topicDescription}, + topic_description_html = #{topicDescriptionHtml} where id = #{idTopic} - delete from forest_topic_tag where id_topic = #{idTopic} and id_tag = #{idTag} + delete + from forest_topic_tag + where id_topic = #{idTopic} + and id_tag = #{idTag}