twoduty/src/main/resources/mybatis/mapper/articlecontent/article-content-mapper.xml
2021-09-02 16:14:50 +08:00

437 lines
18 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tenlion.twoduty.dao.articlecontent.IArticleContentDao">
<resultMap id="articleContentDTO" type="com.tenlion.twoduty.pojo.dtos.articlecontent.ArticleContentDTO">
<result column="article_content_id" property="articleContentId"/>
<result column="article_type_id" property="articleTypeId"/>
<result column="article_classify_id" property="articleClassifyId"/>
<result column="article_content_title" property="articleContentTitle"/>
<result column="article_content_sub_title" property="articleContentSubTitle"/>
<result column="article_content_source" property="articleContentSource"/>
<result column="article_content_author" property="articleContentAuthor"/>
<result column="article_content_content" property="articleContentContent"/>
<result column="article_content_cover_photos" property="articleContentCoverPhotos"/>
<result column="article_content_is_publish" property="articleContentIsPublish"/>
<result column="article_content_publish_time" property="articleContentPublishTime"/>
<result column="article_content_order_by" property="articleContentOrderBy"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="article_type_classify_id" property="articleTypeClassifyId"/>
<result column="article_type_name" property="articleTypeName"/>
<result column="article_classify_name" property="articleClassifyName"/>
</resultMap>
<resultMap id="articleContentBO" type="com.tenlion.twoduty.pojo.bos.articlecontent.ArticleContentBO">
<result column="article_content_id" property="articleContentId"/>
<result column="article_type_id" property="articleTypeId"/>
<result column="article_classify_id" property="articleClassifyId"/>
<result column="article_content_title" property="articleContentTitle"/>
<result column="article_content_sub_title" property="articleContentSubTitle"/>
<result column="article_content_source" property="articleContentSource"/>
<result column="article_content_author" property="articleContentAuthor"/>
<result column="article_content_content" property="articleContentContent"/>
<result column="article_content_cover_photos" property="articleContentCoverPhotos"/>
<result column="article_content_is_publish" property="articleContentIsPublish"/>
<result column="article_content_publish_time" property="articleContentPublishTime"/>
<result column="article_content_order_by" property="articleContentOrderBy"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<resultMap id="articleContentPO" type="com.tenlion.twoduty.pojo.pos.articlecontent.ArticleContentPO">
<result column="article_content_id" property="articleContentId"/>
<result column="article_type_id" property="articleTypeId"/>
<result column="article_classify_id" property="articleClassifyId"/>
<result column="article_content_title" property="articleContentTitle"/>
<result column="article_content_sub_title" property="articleContentSubTitle"/>
<result column="article_content_source" property="articleContentSource"/>
<result column="article_content_author" property="articleContentAuthor"/>
<result column="article_content_content" property="articleContentContent"/>
<result column="article_content_cover_photos" property="articleContentCoverPhotos"/>
<result column="article_content_is_publish" property="articleContentIsPublish"/>
<result column="article_content_publish_time" property="articleContentPublishTime"/>
<result column="article_content_order_by" property="articleContentOrderBy"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<!-- 新增两个责任文章内容管理 -->
<insert id="save" parameterType="map">
INSERT INTO duty_article_content(
article_content_id,
article_type_id,
article_classify_id,
article_content_title,
article_content_sub_title,
article_content_source,
article_content_author,
article_content_content,
article_content_cover_photos,
article_content_is_publish,
article_content_publish_time,
article_content_order_by,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{articleContentId},
#{articleTypeId},
#{articleClassifyId},
#{articleContentTitle},
#{articleContentSubTitle},
#{articleContentSource},
#{articleContentAuthor},
#{articleContentContent},
#{articleContentCoverPhotos},
#{articleContentIsPublish},
#{articleContentPublishTime},
#{articleContentOrderBy},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除两个责任文章内容管理 -->
<update id="remove" parameterType="map">
UPDATE
duty_article_content
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
article_content_id IN
<foreach collection="articleContentIds" index="index" open="(" separator="," close=")">
#{articleContentIds[${index}]}
</foreach>
</update>
<!-- 删除两个责任文章内容管理(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
duty_article_content
WHERE
article_content_id IN
<foreach collection="articleContentIds" index="index" open="(" separator="," close=")">
#{articleContentIds[${index}]}
</foreach>
</update>
<!-- 修改两个责任文章内容管理 -->
<update id="update" parameterType="map">
UPDATE
duty_article_content
SET
<if test="articleTypeId != null and articleTypeId != ''">
article_type_id = #{articleTypeId},
</if>
<if test="articleClassifyId != null and articleClassifyId != ''">
article_classify_id = #{articleClassifyId},
</if>
<if test="articleContentTitle != null and articleContentTitle != ''">
article_content_title = #{articleContentTitle},
</if>
<if test="articleContentSubTitle != null and articleContentSubTitle != ''">
article_content_sub_title = #{articleContentSubTitle},
</if>
<if test="articleContentSource != null and articleContentSource != ''">
article_content_source = #{articleContentSource},
</if>
<if test="articleContentAuthor != null and articleContentAuthor != ''">
article_content_author = #{articleContentAuthor},
</if>
<if test="articleContentContent != null and articleContentContent != ''">
article_content_content = #{articleContentContent},
</if>
<if test="articleContentCoverPhotos != null and articleContentCoverPhotos != ''">
article_content_cover_photos = #{articleContentCoverPhotos},
</if>
<if test="articleContentIsPublish != null and articleContentIsPublish != ''">
article_content_is_publish = #{articleContentIsPublish},
</if>
<if test="articleContentPublishTime != null and articleContentPublishTime != ''">
article_content_publish_time = #{articleContentPublishTime},
</if>
<if test="articleContentOrderBy != null">
article_content_order_by = #{articleContentOrderBy},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier}
WHERE
article_content_id = #{articleContentId}
</update>
<!-- 两个责任文章内容管理详情 -->
<select id="get" parameterType="map" resultMap="articleContentDTO">
SELECT
t1.article_content_id,
t1.article_type_id,
t1.article_classify_id,
t1.article_content_title,
t1.article_content_sub_title,
t1.article_content_source,
t1.article_content_author,
t1.article_content_content,
t1.article_content_cover_photos,
t1.article_content_is_publish,
t1.article_content_publish_time,
t1.article_content_order_by,
t1.article_content_id,
t2.article_type_classify_id
FROM
duty_article_content t1
LEFT JOIN duty_article_type t2
ON t1.article_type_id = t2.article_type_id
WHERE
t1.is_delete = 0
AND
t1.article_content_id = #{articleContentId}
</select>
<!-- 两个责任文章内容管理详情 -->
<select id="getBO" parameterType="map" resultMap="articleContentBO">
SELECT
t1.article_content_id,
t1.article_type_id,
t1.article_classify_id,
t1.article_content_title,
t1.article_content_sub_title,
t1.article_content_source,
t1.article_content_author,
t1.article_content_content,
t1.article_content_cover_photos,
t1.article_content_is_publish,
t1.article_content_publish_time,
t1.article_content_order_by,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
duty_article_content t1
WHERE
t1.is_delete = 0
<if test="articleContentId != null and articleContentId != ''">
AND
t1.article_content_id = #{articleContentId}
</if>
</select>
<!-- 两个责任文章内容管理详情 -->
<select id="getPO" parameterType="map" resultMap="articleContentPO">
SELECT
t1.article_content_id,
t1.article_type_id,
t1.article_classify_id,
t1.article_content_title,
t1.article_content_sub_title,
t1.article_content_source,
t1.article_content_author,
t1.article_content_content,
t1.article_content_cover_photos,
t1.article_content_is_publish,
t1.article_content_publish_time,
t1.article_content_order_by,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
duty_article_content t1
WHERE
t1.is_delete = 0
<if test="articleContentId != null and articleContentId != ''">
AND
t1.article_content_id = #{articleContentId}
</if>
</select>
<!-- 两个责任文章内容管理列表 -->
<select id="list" parameterType="map" resultMap="articleContentDTO">
SELECT
t1.article_content_id,
t1.article_type_id,
t1.article_classify_id,
t1.article_content_title,
t1.article_content_sub_title,
t1.article_content_source,
t1.article_content_author,
t1.article_content_content,
t1.article_content_cover_photos,
t1.article_content_is_publish,
t1.article_content_publish_time,
t1.article_content_order_by,
t1.gmt_create,
t2.article_type_name,
dd.data_name AS article_classify_name
FROM
duty_article_content t1
LEFT JOIN duty_article_type t2
ON t1.article_type_id = t2.article_type_id
LEFT JOIN data_data dd
ON t1.article_classify_id = dd.data_id
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.article_content_title LIKE CONCAT('%', #{keywords}, '%')
OR
t1.article_content_sub_title LIKE CONCAT('%', #{keywords}, '%')
OR
t1.article_content_source LIKE CONCAT('%', #{keywords}, '%')
OR
t1.article_content_author LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="articleContentIds != null and articleContentIds.size > 0">
AND
t1.article_content_id IN
<foreach collection="articleContentIds" index="index" open="(" separator="," close=")">
#{articleContentIds[${index}]}
</foreach>
</if>
<if test="articleTypeId != null and articleTypeId != ''">
AND
t1.article_type_id = #{articleTypeId}
</if>
<if test="articleClassifyId != null and articleClassifyId != ''">
AND
t1.article_classify_id = #{articleClassifyId}
</if>
<if test="articleContentIsPublish != null">
AND
t1.article_content_is_publish = #{articleContentIsPublish}
</if>
ORDER BY t1.article_content_order_by
</select>
<!-- 两个责任文章内容管理列表 -->
<select id="listBO" parameterType="map" resultMap="articleContentBO">
SELECT
t1.article_content_id,
t1.article_type_id,
t1.article_classify_id,
t1.article_content_title,
t1.article_content_sub_title,
t1.article_content_source,
t1.article_content_author,
t1.article_content_content,
t1.article_content_cover_photos,
t1.article_content_is_publish,
t1.article_content_publish_time,
t1.article_content_order_by,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
duty_article_content t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="articleContentIds != null and articleContentIds.size > 0">
AND
t1.article_content_id IN
<foreach collection="articleContentIds" index="index" open="(" separator="," close=")">
#{articleContentIds[${index}]}
</foreach>
</if>
</select>
<!-- 两个责任文章内容管理列表 -->
<select id="listPO" parameterType="map" resultMap="articleContentPO">
SELECT
t1.article_content_id,
t1.article_type_id,
t1.article_classify_id,
t1.article_content_title,
t1.article_content_sub_title,
t1.article_content_source,
t1.article_content_author,
t1.article_content_content,
t1.article_content_cover_photos,
t1.article_content_is_publish,
t1.article_content_publish_time,
t1.article_content_order_by,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
duty_article_content t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="articleContentIds != null and articleContentIds.size > 0">
AND
t1.article_content_id IN
<foreach collection="articleContentIds" index="index" open="(" separator="," close=")">
#{articleContentIds[${index}]}
</foreach>
</if>
</select>
<!-- 两个责任文章内容管理统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
duty_article_content t1
WHERE
t1.is_delete = 0
<if test="articleTypeId != null and articleTypeId != ''">
AND
t1.article_type_id = #{articleTypeId}
</if>
</select>
</mapper>