<?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.oa.mapper.SysOaArticleMapper">

    <resultMap type="com.ruoyi.oa.domain.SysOaArticle" id="SysOaArticleResult">
        <result property="articleId" column="article_id"/>
        <result property="categoryId" column="category_id"/>
        <result property="articleTitle" column="article_title"/>
        <result property="subhead" column="subhead"/>
        <result property="source" column="source"/>
        <result property="content" column="content"/>
        <result property="checkNum" column="check_num"/>
        <result property="accessory" column="accessory"/>
        <result property="remark" column="remark"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <!--一对一关联-->
        <association property="category" column="category_id" javaType="SysOaCategory" resultMap="SysOaCategoryResult"/>
    </resultMap>

    <resultMap id="SysOaCategoryResult" type="SysOaCategory">
        <result property="categoryId" column="category_id"/>
        <result property="categoryName" column="category_name"/>
    </resultMap>

    <sql id="selectArticleSql">
        select a.article_id,
               a.category_id,
               a.article_title,
               a.subhead,
               a.source,
               a.content,
               a.check_num,
               a.accessory,
               a.remark,
               a.create_by,
               a.create_time,
               a.update_by,
               a.update_time,
               c.category_id,
               c.category_name
        from sys_oa_article a
                 left join sys_oa_category c on a.category_id = c.category_id
    </sql>

    <select id="selectArticlePageList" resultMap="SysOaArticleResult">
        <include refid="selectArticleSql" />
        ${ew.getCustomSqlSegment}
    </select>

    <select id="selectArticleById" resultMap="SysOaArticleResult">
        <include refid="selectArticleSql" />
        where a.article_id = #{articleId}
    </select>


</mapper>
