<?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.yifu.cloud.plus.v1.yifu.archives.mapper.TAttaInfoMapper">
      <resultMap id="tAttaInfoMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo">
            <id property="id" column="id"/>
            <result property="attaName" column="atta_name"/>
            <result property="attaSrc" column="atta_src"/>
            <result property="attaSize" column="atta_size"/>
            <result property="attaType" column="atta_type"/>
            <result property="createUser" column="create_user"/>
            <result property="createTime" column="create_time"/>
            <result property="relationType" column="relation_type"/>
            <result property="domainId" column="domain_id"/>
      </resultMap>
      <sql id="Base_Column_List">
                 a.id,
                      a.atta_name,
                      a.atta_src,
                      a.atta_size,
                      a.atta_type,
                      a.create_user,
                      a.create_time,
                      a.relation_type,
                      a.domain_id
      </sql>
      <sql id="tAttaInfo_where">
            <if test="tAttaInfo != null">
                <if test="tAttaInfo.id != null and tAttaInfo.id.trim() != ''">
                    AND a.id = #{tAttaInfo.id}
                </if>
                <if test="tAttaInfo.attaName != null and tAttaInfo.attaName.trim() != ''">
                    AND a.atta_name = #{tAttaInfo.attaName}
                </if>
                <if test="tAttaInfo.attaSrc != null and tAttaInfo.attaSrc.trim() != ''">
                    AND a.atta_src = #{tAttaInfo.attaSrc}
                </if>
                <if test="tAttaInfo.attaSize != null">
                    AND a.atta_size = #{tAttaInfo.attaSize}
                </if>
                <if test="tAttaInfo.attaType != null and tAttaInfo.attaType.trim() != ''">
                    AND a.atta_type = #{tAttaInfo.attaType}
                </if>
                <if test="tAttaInfo.createUser != null and tAttaInfo.createUser.trim() != ''">
                    AND a.create_user = #{tAttaInfo.createUser}
                </if>
                <if test="tAttaInfo.createTime != null">
                    AND a.create_time = #{tAttaInfo.createTime}
                </if>
                <if test="tAttaInfo.relationType != null and tAttaInfo.relationType.trim() != ''">
                    AND a.relation_type = #{tAttaInfo.relationType}
                </if>
                <if test="tAttaInfo.domainId != null and tAttaInfo.domainId.trim() != ''">
                    AND a.domain_id = #{tAttaInfo.domainId}
                </if>
            </if>
      </sql>
    <!--tAttaInfo简单分页查询-->
    <select id="getTAttaInfoPage" resultMap="tAttaInfoMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_atta_info a
        <where>
            1=1
            <include refid="tAttaInfo_where"/>
        </where>
    </select>

    <!--tAttaInfo 获取list-->
    <select id="getTAttaInfoList" resultMap="tAttaInfoMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_atta_info a
        <where>
            1=1
            <include refid="tAttaInfo_where"/>
        </where>
    </select>
    <select id="getKeenAtta" resultMap="tAttaInfoMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_atta_info a
        <where>
            1=1
            <if test="values != null and values.size() > 0">
                and  a.domain_id in
                <foreach collection="values" item="param" index="index" open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
            and a.create_time >= #{dayStart}
            and a.relation_type in ("3","4")
        </where>
    </select>

	<update id="updateDomainId">
		update t_atta_info
		<trim prefix="set" suffixOverrides=",">
			domain_id=#{domainId}
		</trim>
		WHERE
		<if test="ids != null and ids.size() > 0">
			id in
			<foreach collection="ids" item="param" index="index" open="(" close=")" separator=",">
				#{param}
			</foreach>
		</if>
	</update>
</mapper>
