🐛 专题/标签上传图片问题修复

This commit is contained in:
ronger 2022-01-13 22:15:05 +08:00
parent 72abc56365
commit 2bed7765bc
4 changed files with 85 additions and 18 deletions

View File

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

View File

@ -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<Topic> 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<Topic> 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());

View File

@ -23,24 +23,48 @@
<result column="tag_title" property="value"></result>
</resultMap>
<insert id="insertTagArticle">
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>
<insert id="insertUserTag">
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())
</insert>
<update id="update">
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}
</update>
<delete id="deleteUnusedTag">
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);
</delete>
<select id="selectCountTagArticleById" resultType="java.lang.Integer">
select count(*) from forest_tag_article where id_tag = #{idTag} and id_article = #{idArticle}
select count(*)
from forest_tag_article
where id_tag = #{idTag}
and id_article = #{idArticle}
</select>
<select id="selectCountUserTagById" resultType="java.lang.Integer">
select count(*) from forest_user_tag where id_tag = #{idTag} and id_user = #{idUser}
select count(*)
from forest_user_tag
where id_tag = #{idTag}
and id_user = #{idUser}
</select>
<select id="selectTagLabels" resultMap="TagLabelResultMap">
select tag_title from forest_tag where tag_status = 0
select tag_title
from forest_tag
where tag_status = 0
</select>
</mapper>

View File

@ -51,27 +51,50 @@
<id column="updated_time" property="updatedTime"/>
</resultMap>
<insert id="insertTopicTag">
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())
</insert>
<update id="update">
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}
</update>
<delete id="deleteTopicTag">
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}
</delete>
<select id="selectTopicNav" resultMap="BaseResultMap">
select id,topic_title,topic_uri,topic_icon_path from forest_topic where topic_nva = 0 and topic_status = 0 order by topic_sort
select id, topic_title, topic_uri, topic_icon_path
from forest_topic
where topic_nva = 0
and topic_status = 0
order by topic_sort
</select>
<select id="selectTopicByTopicUri" resultMap="DTOResultMap">
select id,topic_title,topic_uri,topic_icon_path,topic_description,topic_tag_count,topic_status from forest_topic where topic_uri = #{topicUri}
select id, topic_title, topic_uri, topic_icon_path, topic_description, topic_tag_count, topic_status
from forest_topic
where topic_uri = #{topicUri}
</select>
<select id="selectTopicTag" resultMap="TagDTOResultMap">
select vt.id,vt.tag_title,vt.tag_uri,vt.tag_description,vt.tag_icon_path from forest_tag vt left join forest_topic_tag vtt on vt.id = vtt.id_tag where vtt.id_topic = #{idTopic} order by vtt.created_time desc
select vt.id, vt.tag_title, vt.tag_uri, vt.tag_description, vt.tag_icon_path
from forest_tag vt
left join forest_topic_tag vtt on vt.id = vtt.id_tag
where vtt.id_topic = #{idTopic}
order by vtt.created_time desc
</select>
<select id="selectUnbindTagsById" resultMap="TagResultMap">
select * from forest_tag vt where not exists(select * from forest_topic_tag vtt where vtt.id_topic = #{idTopic} and vtt.id_tag = vt.id)
select * from forest_tag vt where not exists(select * from forest_topic_tag vtt where vtt.id_topic = #{idTopic}
and vtt.id_tag = vt.id)
<if test="tagTitle != '' and tagTitle != null">
and LOCATE(#{tagTitle}, vt.tag_title) > 0
</if>