<?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.ads.business.dao.DocDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ads.business.entity.Doc">
        <id column="id" property="id" />
        <result column="type_id" property="typeId" />
        <result column="name" property="name" />
        <result column="doc_url" property="docUrl" />
        <result column="link_url" property="linkUrl" />
        <result column="status" property="status" />
        <result column="create_user" property="createUser" />
        <result column="create_time" property="createTime" />
        <result column="update_user" property="updateUser" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, type_id, name, doc_url, link_url, status, create_user, create_time, update_user, update_time
    </sql>

    <select id="findPage"
            resultType="com.ads.business.service.model.response.DocListResponse">
        select
        hd.id  AS id,
        hdt.name AS typeName,
        hd.name AS name,
        hd.doc_url AS docUrl,
        hd.link_url AS linkUrl,
        hd.file_size AS fileSize,
        hu.name AS createUser,
        hd.create_time AS createTime,
        hd.status AS status
        from hsay_doc hd
        inner JOIN hsay_doc_type hdt ON hd.type_id = hdt.type_id
        left JOIN hsay_user hu on hu.user_id = hd.create_user
        ${ew.customSqlSegment}
    </select>

    <select id="findList"
            resultType="com.ads.business.service.model.response.DocListResponse">
        select
            hd.id  AS id,
            hdt.name AS typeName,
            hd.name AS name,
            hd.doc_url AS docUrl,
            hd.link_url AS linkUrl,
            hd.file_size AS fileSize,
            hu.name AS createUser,
            hd.create_time AS createTime,
            hd.status AS status
        from hsay_doc hd
                 inner JOIN hsay_doc_type hdt ON hd.type_id = hdt.type_id
                 left JOIN hsay_user hu on hu.user_id = hd.create_user
            ${ew.customSqlSegment}
    </select>
</mapper>
