huaguoshan-admin/ruoyi-system/target/classes/mapper/system/CmsArticleMapper.xml

255 lines
14 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.ruoyi.system.mapper.CmsArticleMapper">
<resultMap type="CmsArticle" id="CmsArticleResult">
<result property="id" column="id" />
<result property="yhid" column="yhid" />
<result property="articleRegion" column="article_region" />
<result property="author" column="author" />
<result property="publishTime" column="publish_time" />
<result property="title" column="title" />
<result property="keywords" column="keywords" />
<result property="description" column="description" />
<result property="coverImage" column="cover_image" />
<result property="articleModel" column="article_model" />
<result property="copyFlag" column="copy_flag" />
<result property="categoryId" column="category_id" />
<result property="personalCategory" column="personal_category" />
<result property="link" column="link" />
<result property="staticUrl" column="static_url" />
<result property="tags" column="tags" />
<result property="hit" column="hit" />
<result property="replyNum" column="reply_num" />
<result property="upVote" column="up_vote" />
<result property="downVote" column="down_vote" />
<result property="hotFlag" column="hot_flag" />
<result property="newFlag" column="new_flag" />
<result property="commentFlag" column="comment_flag" />
<result property="topFlag" column="top_flag" />
<result property="favourite" column="favourite" />
<result property="missionId" column="mission_id" />
<result property="templateName" column="template_name" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="available" column="available" />
<result property="deleted" column="deleted" />
<result property="extra1" column="extra1" />
<result property="extra2" column="extra2" />
<result property="extra3" column="extra3" />
<result property="sort" column="sort" />
<result property="onclick" column="onclick" />
</resultMap>
<sql id="selectCmsArticleVo">
select id, yhid, article_region, author, publish_time, title, keywords, description, cover_image, article_model, copy_flag, category_id, personal_category, link, static_url, tags, hit, reply_num, up_vote, down_vote, hot_flag, new_flag, comment_flag, top_flag, favourite, mission_id, template_name, create_time, update_time, available, deleted, extra1, extra2, extra3, sort, onclick from cms_article
</sql>
<select id="selectCmsArticleList" parameterType="CmsArticle" resultMap="CmsArticleResult">
<include refid="selectCmsArticleVo"/>
<where>
<if test="yhid != null and yhid != ''"> and yhid = #{yhid}</if>
<if test="articleRegion != null and articleRegion != ''"> and article_region = #{articleRegion}</if>
<if test="author != null and author != ''"> and author = #{author}</if>
<if test="publishTime != null and publishTime != ''"> and publish_time = #{publishTime}</if>
<if test="title != null and title != ''"> and title like (concat('%', #{title}, '%'))</if>
<if test="keywords != null and keywords != ''"> and keywords = #{keywords}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="coverImage != null and coverImage != ''"> and cover_image = #{coverImage}</if>
<if test="articleModel != null and articleModel != ''"> and article_model = #{articleModel}</if>
<if test="copyFlag != null "> and copy_flag = #{copyFlag}</if>
<if test="categoryId != null and categoryId != ''"> and category_id = #{categoryId}</if>
<if test="personalCategory != null and personalCategory != ''"> and personal_category = #{personalCategory}</if>
<if test="link != null and link != ''"> and link = #{link}</if>
<if test="staticUrl != null and staticUrl != ''"> and static_url = #{staticUrl}</if>
<if test="tags != null and tags != ''"> and FIND_IN_SET(#{tag},tags)</if>
<if test="hit != null "> and hit = #{hit}</if>
<if test="replyNum != null "> and reply_num = #{replyNum}</if>
<if test="upVote != null "> and up_vote = #{upVote}</if>
<if test="downVote != null "> and down_vote = #{downVote}</if>
<if test="hotFlag != null "> and hot_flag = #{hotFlag}</if>
<if test="newFlag != null "> and new_flag = #{newFlag}</if>
<if test="commentFlag != null "> and comment_flag = #{commentFlag}</if>
<if test="topFlag != null "> and top_flag = #{topFlag}</if>
<if test="favourite != null "> and favourite = #{favourite}</if>
<if test="missionId != null and missionId != ''"> and mission_id = #{missionId}</if>
<if test="templateName != null and templateName != ''"> and template_name like concat('%', #{templateName}, '%')</if>
<if test="available != null "> and available = #{available}</if>
<if test="deleted != null "> and deleted = #{deleted}</if>
<if test="extra1 != null and extra1 != ''"> and extra1 = #{extra1}</if>
<if test="extra2 != null and extra2 != ''"> and extra2 = #{extra2}</if>
<if test="extra3 != null and extra3 != ''"> and extra3 = #{extra3}</if>
<if test="sort != null "> and sort = #{sort}</if>
<if test="onclick != null "> and onclick = #{onclick}</if>
</where>
order by top_flag desc, publish_time desc
</select>
<select id="selectCmsArticleById" parameterType="Long" resultMap="CmsArticleResult">
<include refid="selectCmsArticleVo"/>
where id = #{id}
</select>
<insert id="insertCmsArticle" parameterType="CmsArticle" useGeneratedKeys="true" keyProperty="id">
insert into cms_article
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="yhid != null">yhid,</if>
<if test="articleRegion != null">article_region,</if>
<if test="author != null">author,</if>
<if test="publishTime != null">publish_time,</if>
<if test="title != null">title,</if>
<if test="keywords != null">keywords,</if>
<if test="description != null">description,</if>
<if test="coverImage != null">cover_image,</if>
<if test="articleModel != null">article_model,</if>
<if test="copyFlag != null">copy_flag,</if>
<if test="categoryId != null">category_id,</if>
<if test="personalCategory != null">personal_category,</if>
<if test="link != null">link,</if>
<if test="staticUrl != null">static_url,</if>
<if test="tags != null">tags,</if>
<if test="hit != null">hit,</if>
<if test="replyNum != null">reply_num,</if>
<if test="upVote != null">up_vote,</if>
<if test="downVote != null">down_vote,</if>
<if test="hotFlag != null">hot_flag,</if>
<if test="newFlag != null">new_flag,</if>
<if test="commentFlag != null">comment_flag,</if>
<if test="topFlag != null">top_flag,</if>
<if test="favourite != null">favourite,</if>
<if test="missionId != null">mission_id,</if>
<if test="templateName != null">template_name,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="available != null">available,</if>
<if test="deleted != null">deleted,</if>
<if test="extra1 != null">extra1,</if>
<if test="extra2 != null">extra2,</if>
<if test="extra3 != null">extra3,</if>
<if test="sort != null">sort,</if>
<if test="onclick != null">onclick,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="yhid != null">#{yhid},</if>
<if test="articleRegion != null">#{articleRegion},</if>
<if test="author != null">#{author},</if>
<if test="publishTime != null">#{publishTime},</if>
<if test="title != null">#{title},</if>
<if test="keywords != null">#{keywords},</if>
<if test="description != null">#{description},</if>
<if test="coverImage != null">#{coverImage},</if>
<if test="articleModel != null">#{articleModel},</if>
<if test="copyFlag != null">#{copyFlag},</if>
<if test="categoryId != null">#{categoryId},</if>
<if test="personalCategory != null">#{personalCategory},</if>
<if test="link != null">#{link},</if>
<if test="staticUrl != null">#{staticUrl},</if>
<if test="tags != null">#{tags},</if>
<if test="hit != null">#{hit},</if>
<if test="replyNum != null">#{replyNum},</if>
<if test="upVote != null">#{upVote},</if>
<if test="downVote != null">#{downVote},</if>
<if test="hotFlag != null">#{hotFlag},</if>
<if test="newFlag != null">#{newFlag},</if>
<if test="commentFlag != null">#{commentFlag},</if>
<if test="topFlag != null">#{topFlag},</if>
<if test="favourite != null">#{favourite},</if>
<if test="missionId != null">#{missionId},</if>
<if test="templateName != null">#{templateName},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="available != null">#{available},</if>
<if test="deleted != null">#{deleted},</if>
<if test="extra1 != null">#{extra1},</if>
<if test="extra2 != null">#{extra2},</if>
<if test="extra3 != null">#{extra3},</if>
<if test="sort != null">#{sort},</if>
<if test="onclick != null">#{onclick},</if>
</trim>
</insert>
<update id="updateCmsArticle" parameterType="CmsArticle">
update cms_article
<trim prefix="SET" suffixOverrides=",">
<if test="yhid != null">yhid = #{yhid},</if>
<if test="articleRegion != null">article_region = #{articleRegion},</if>
<if test="author != null">author = #{author},</if>
<if test="publishTime != null">publish_time = #{publishTime},</if>
<if test="title != null">title = #{title},</if>
<if test="keywords != null">keywords = #{keywords},</if>
<if test="description != null">description = #{description},</if>
<if test="coverImage != null">cover_image = #{coverImage},</if>
<if test="articleModel != null">article_model = #{articleModel},</if>
<if test="copyFlag != null">copy_flag = #{copyFlag},</if>
<if test="categoryId != null">category_id = #{categoryId},</if>
<if test="personalCategory != null">personal_category = #{personalCategory},</if>
<if test="link != null">link = #{link},</if>
<if test="staticUrl != null">static_url = #{staticUrl},</if>
<if test="tags != null">tags = #{tags},</if>
<if test="hit != null">hit = #{hit},</if>
<if test="replyNum != null">reply_num = #{replyNum},</if>
<if test="upVote != null">up_vote = #{upVote},</if>
<if test="downVote != null">down_vote = #{downVote},</if>
<if test="hotFlag != null">hot_flag = #{hotFlag},</if>
<if test="newFlag != null">new_flag = #{newFlag},</if>
<if test="commentFlag != null">comment_flag = #{commentFlag},</if>
<if test="topFlag != null">top_flag = #{topFlag},</if>
<if test="favourite != null">favourite = #{favourite},</if>
<if test="missionId != null">mission_id = #{missionId},</if>
<if test="templateName != null">template_name = #{templateName},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="available != null">available = #{available},</if>
<if test="deleted != null">deleted = #{deleted},</if>
<if test="extra1 != null">extra1 = #{extra1},</if>
<if test="extra2 != null">extra2 = #{extra2},</if>
<if test="extra3 != null">extra3 = #{extra3},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="onclick != null">onclick = #{onclick},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCmsArticleById" parameterType="Long">
delete from cms_article where id = #{id}
</delete>
<delete id="deleteCmsArticleByIds" parameterType="String">
delete from cms_article where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 模糊查询-->
<select id="selectArticlesFuzzySearch" parameterType="CmsArticle" resultMap="CmsArticleResult">
SELECT * FROM cms_article WHERE 1=1
<if test="author != null and author != ''">
AND author LIKE CONCAT('%', #{author}, '%')
</if>
<if test="title != null and title != ''">
AND title LIKE CONCAT('%', #{title}, '%')
</if>
<if test="keywords != null and keywords != ''">
AND keywords LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="description != null and description != ''">
AND description LIKE CONCAT('%', #{description}, '%')
</if>
<if test="articleModel != null and articleModel != ''">
AND articleModel = #{articleModel}
</if>
</select>
<select id="getArticleContent" resultType="java.util.Map" parameterType="java.lang.String">
SELECT content,content_markdown_source FROM cms_article_content
<where>
id=#{article_id}
</where>
</select>
</mapper>