🐛 专题/标签上传图片问题修复
This commit is contained in:
parent
72abc56365
commit
2bed7765bc
@ -13,6 +13,7 @@ import com.rymcu.forest.service.TagService;
|
|||||||
import com.rymcu.forest.util.BaiDuAipUtils;
|
import com.rymcu.forest.util.BaiDuAipUtils;
|
||||||
import com.rymcu.forest.util.CacheUtils;
|
import com.rymcu.forest.util.CacheUtils;
|
||||||
import com.rymcu.forest.util.UserUtils;
|
import com.rymcu.forest.util.UserUtils;
|
||||||
|
import com.rymcu.forest.web.api.common.UploadController;
|
||||||
import com.rymcu.forest.web.api.exception.BaseApiException;
|
import com.rymcu.forest.web.api.exception.BaseApiException;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -142,7 +143,12 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
Tag newTag = new Tag();
|
Tag newTag = new Tag();
|
||||||
newTag.setTagTitle(tag.getTagTitle());
|
newTag.setTagTitle(tag.getTagTitle());
|
||||||
newTag.setTagUri(tag.getTagUri());
|
newTag.setTagUri(tag.getTagUri());
|
||||||
|
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.setTagIconPath(tag.getTagIconPath());
|
||||||
|
}
|
||||||
newTag.setTagStatus(tag.getTagStatus());
|
newTag.setTagStatus(tag.getTagStatus());
|
||||||
newTag.setTagDescription(tag.getTagDescription());
|
newTag.setTagDescription(tag.getTagDescription());
|
||||||
newTag.setTagReservation(tag.getTagReservation());
|
newTag.setTagReservation(tag.getTagReservation());
|
||||||
@ -151,6 +157,10 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
result = tagMapper.insertSelective(newTag);
|
result = tagMapper.insertSelective(newTag);
|
||||||
} else {
|
} else {
|
||||||
tag.setUpdatedTime(new Date());
|
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());
|
result = tagMapper.update(tag.getIdTag(), tag.getTagUri(), tag.getTagIconPath(), tag.getTagStatus(), tag.getTagDescription(), tag.getTagReservation());
|
||||||
}
|
}
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
|
@ -10,6 +10,7 @@ import com.rymcu.forest.entity.Tag;
|
|||||||
import com.rymcu.forest.entity.Topic;
|
import com.rymcu.forest.entity.Topic;
|
||||||
import com.rymcu.forest.mapper.TopicMapper;
|
import com.rymcu.forest.mapper.TopicMapper;
|
||||||
import com.rymcu.forest.service.TopicService;
|
import com.rymcu.forest.service.TopicService;
|
||||||
|
import com.rymcu.forest.web.api.common.UploadController;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -64,7 +65,12 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
|||||||
Topic newTopic = new Topic();
|
Topic newTopic = new Topic();
|
||||||
newTopic.setTopicTitle(topic.getTopicTitle());
|
newTopic.setTopicTitle(topic.getTopicTitle());
|
||||||
newTopic.setTopicUri(topic.getTopicUri());
|
newTopic.setTopicUri(topic.getTopicUri());
|
||||||
|
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.setTopicIconPath(topic.getTopicIconPath());
|
||||||
|
}
|
||||||
newTopic.setTopicNva(topic.getTopicNva());
|
newTopic.setTopicNva(topic.getTopicNva());
|
||||||
newTopic.setTopicStatus(topic.getTopicStatus());
|
newTopic.setTopicStatus(topic.getTopicStatus());
|
||||||
newTopic.setTopicSort(topic.getTopicSort());
|
newTopic.setTopicSort(topic.getTopicSort());
|
||||||
@ -74,7 +80,11 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
|||||||
newTopic.setUpdatedTime(topic.getCreatedTime());
|
newTopic.setUpdatedTime(topic.getCreatedTime());
|
||||||
result = topicMapper.insertSelective(newTopic);
|
result = topicMapper.insertSelective(newTopic);
|
||||||
} else {
|
} 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()
|
result = topicMapper.update(topic.getIdTopic(),topic.getTopicTitle(),topic.getTopicUri()
|
||||||
,topic.getTopicIconPath(),topic.getTopicNva(),topic.getTopicStatus()
|
,topic.getTopicIconPath(),topic.getTopicNva(),topic.getTopicStatus()
|
||||||
,topic.getTopicSort(),topic.getTopicDescription(),topic.getTopicDescriptionHtml());
|
,topic.getTopicSort(),topic.getTopicDescription(),topic.getTopicDescriptionHtml());
|
||||||
|
@ -23,24 +23,48 @@
|
|||||||
<result column="tag_title" property="value"></result>
|
<result column="tag_title" property="value"></result>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<insert id="insertTagArticle">
|
<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>
|
||||||
<insert id="insertUserTag">
|
<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>
|
</insert>
|
||||||
<update id="update">
|
<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>
|
</update>
|
||||||
<delete id="deleteUnusedTag">
|
<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>
|
</delete>
|
||||||
<select id="selectCountTagArticleById" resultType="java.lang.Integer">
|
<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>
|
||||||
<select id="selectCountUserTagById" resultType="java.lang.Integer">
|
<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>
|
||||||
<select id="selectTagLabels" resultMap="TagLabelResultMap">
|
<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>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
@ -51,27 +51,50 @@
|
|||||||
<id column="updated_time" property="updatedTime"/>
|
<id column="updated_time" property="updatedTime"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<insert id="insertTopicTag">
|
<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>
|
</insert>
|
||||||
<update id="update">
|
<update id="update">
|
||||||
update forest_topic set topic_title = #{topicTitle},topic_uri = #{topicUri},topic_icon_path = #{topicIconPath}, updated_time = sysdate(),
|
update forest_topic
|
||||||
topic_nva = #{topicNva},topic_status = #{topicStatus},topic_sort = #{topicSort},topic_description = #{topicDescription},topic_description_html = #{topicDescriptionHtml}
|
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}
|
where id = #{idTopic}
|
||||||
</update>
|
</update>
|
||||||
<delete id="deleteTopicTag">
|
<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>
|
</delete>
|
||||||
<select id="selectTopicNav" resultMap="BaseResultMap">
|
<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>
|
||||||
<select id="selectTopicByTopicUri" resultMap="DTOResultMap">
|
<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>
|
||||||
<select id="selectTopicTag" resultMap="TagDTOResultMap">
|
<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>
|
||||||
<select id="selectUnbindTagsById" resultMap="TagResultMap">
|
<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">
|
<if test="tagTitle != '' and tagTitle != null">
|
||||||
and LOCATE(#{tagTitle}, vt.tag_title) > 0
|
and LOCATE(#{tagTitle}, vt.tag_title) > 0
|
||||||
</if>
|
</if>
|
||||||
|
Loading…
Reference in New Issue
Block a user