<?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.dayou.mapper.UserTargetMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.dayou.entity.UserTarget">
        <result column="id" property="id" />
        <result column="sale_target" property="saleTarget" />
        <result column="payment_target" property="paymentTarget" />
        <result column="user_id" property="userId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,
        sale_target, payment_target, user_id
    </sql>

    <select id="getList" parameterType="com.dayou.vo.UserTargetVO" resultType="com.dayou.vo.UserTargetVO">
        select ut.id,
               ut.sale_target, ut.payment_target, ut.user_id ,u.name as userName
            from user_target ut left join user u on u.id = ut.user_id
            where u.deleted = 0
        <if test="userTargetVO!=null and userTargetVO.userIds!=null and userTargetVO.userIds.size!=0">
            and ut.user_id in
            <foreach collection="userTargetVO.userIds" open="(" close=")" separator="," item="userId">
                #{userId}
            </foreach>
        </if>
    </select>
</mapper>
