emis-service/emis-biz/src/main/resources/mapper/EmisArticleMapper.xml
2024-08-29 12:55:17 +08:00

187 lines
11 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.xdadan.erp.emis.mapper.EmisArticleMapper">
<resultMap type="EmisArticle" id="EmisArticleResult">
<result property="id" column="id" />
<result property="catId" column="cat_id" />
<result property="title" column="title" />
<result property="content" column="content" />
<result property="author" column="author" />
<result property="authorEmail" column="author_email" />
<result property="keywords" column="keywords" />
<result property="articleType" column="article_type" />
<result property="isOpen" column="is_open" />
<result property="fileUrl" column="file_url" />
<result property="openType" column="open_type" />
<result property="link" column="link" />
<result property="description" column="description" />
<result property="clickCount" column="click_count" />
</resultMap>
<sql id="selectEmisArticleVo">
select id, cat_id, title, content, author, author_email, keywords, article_type, is_open, file_url, open_type, link, description, click_count, tenant_id, del_flag, create_by, create_time, update_by, update_time, remark, create_site, update_site from emis_article
</sql>
<select id="selectEmisArticleList" parameterType="EmisArticle" resultMap="EmisArticleResult">
<include refid="selectEmisArticleVo"/>
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="catId != null "> and cat_id = #{catId}</if>
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
<if test="content != null and content != ''"> and content like concat('%', #{content}, '%')</if>
<if test="author != null and author != ''"> and author like concat('%', #{author}, '%')</if>
<if test="authorEmail != null and authorEmail != ''"> and author_email like concat('%', #{authorEmail}, '%')</if>
<if test="keywords != null and keywords != ''"> and keywords like concat('%', #{keywords}, '%')</if>
<if test="articleType != null "> and article_type = #{articleType}</if>
<if test="isOpen != null "> and is_open = #{isOpen}</if>
<if test="fileUrl != null and fileUrl != ''"> and file_url like concat('%', #{fileUrl}, '%')</if>
<if test="openType != null "> and open_type = #{openType}</if>
<if test="link != null and link != ''"> and link like concat('%', #{link}, '%')</if>
<if test="description != null and description != ''"> and description like concat('%', #{description}, '%')</if>
<if test="clickCount != null "> and click_count = #{clickCount}</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id like concat('%', #{tenantId}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
</where>
order by create_time desc
</select>
<select id="checkUnique" parameterType="EmisArticle" resultType="int">
select count(1) from emis_article
where del_flag='0'
and id = #{id}
and cat_id = #{catId}
and title = #{title}
and content = #{content}
and author = #{author}
and author_email = #{authorEmail}
and keywords = #{keywords}
and article_type = #{articleType}
and is_open = #{isOpen}
and file_url = #{fileUrl}
and open_type = #{openType}
and link = #{link}
and description = #{description}
and click_count = #{clickCount}
and tenant_id = #{tenantId}
and del_flag = #{delFlag}
and create_by = #{createBy}
and create_time = #{createTime}
and update_by = #{updateBy}
and update_time = #{updateTime}
and remark = #{remark}
and create_site = #{createSite}
and update_site = #{updateSite}
limit 1
</select>
<select id="selectEmisArticleById" parameterType="Long" resultMap="EmisArticleResult">
select id, cat_id, title, content, author, author_email, keywords, article_type, is_open, file_url, open_type, link, description, click_count, tenant_id, del_flag, create_by, create_time, update_by, update_time, remark, create_site, update_site
from emis_article a
where a.id = #{id}
</select>
<insert id="insertEmisArticle" parameterType="EmisArticle" useGeneratedKeys="true" keyProperty="id">
insert into emis_article
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="catId != null">cat_id,</if>
<if test="title != null and title != ''">title,</if>
<if test="content != null and content != ''">content,</if>
<if test="author != null and author != ''">author,</if>
<if test="authorEmail != null and authorEmail != ''">author_email,</if>
<if test="keywords != null and keywords != ''">keywords,</if>
<if test="articleType != null">article_type,</if>
<if test="isOpen != null">is_open,</if>
<if test="fileUrl != null and fileUrl != ''">file_url,</if>
<if test="openType != null">open_type,</if>
<if test="link != null and link != ''">link,</if>
<if test="description != null and description != ''">description,</if>
<if test="clickCount != null">click_count,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="catId != null">#{catId},</if>
<if test="title != null and title != ''">#{title},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="author != null and author != ''">#{author},</if>
<if test="authorEmail != null and authorEmail != ''">#{authorEmail},</if>
<if test="keywords != null and keywords != ''">#{keywords},</if>
<if test="articleType != null">#{articleType},</if>
<if test="isOpen != null">#{isOpen},</if>
<if test="fileUrl != null and fileUrl != ''">#{fileUrl},</if>
<if test="openType != null">#{openType},</if>
<if test="link != null and link != ''">#{link},</if>
<if test="description != null and description != ''">#{description},</if>
<if test="clickCount != null">#{clickCount},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</insert>
<update id="updateEmisArticle" parameterType="EmisArticle">
update emis_article
<trim prefix="SET" suffixOverrides=",">
<if test="catId != null">cat_id = #{catId},</if>
<if test="title != null and title != ''">title = #{title},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="author != null and author != ''">author = #{author},</if>
<if test="authorEmail != null and authorEmail != ''">author_email = #{authorEmail},</if>
<if test="keywords != null and keywords != ''">keywords = #{keywords},</if>
<if test="articleType != null">article_type = #{articleType},</if>
<if test="isOpen != null">is_open = #{isOpen},</if>
<if test="fileUrl != null and fileUrl != ''">file_url = #{fileUrl},</if>
<if test="openType != null">open_type = #{openType},</if>
<if test="link != null and link != ''">link = #{link},</if>
<if test="description != null and description != ''">description = #{description},</if>
<if test="clickCount != null">click_count = #{clickCount},</if>
<if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="createSite != null and createSite != ''">create_site = #{createSite},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmisArticleById" parameterType="Long">
delete from emis_article where id = #{id}
</delete>
<delete id="deleteEmisArticleByIds" parameterType="String">
delete from emis_article where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>