<?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="jnpf.store.mapper.StoreUserRelationMapper">

    <select id="queryList" resultType="jnpf.model.store.vo.StoreUserRelationVo">
        select
        a.F_Id as id,
        a.F_StoreId as storeId,
        a.F_UserId as userId,
        a.F_OrganizeId as organizeId,
        a.F_PositionId as positionId,
        a.F_RankId as rankId,
        b.F_StoreName as storeName,
        b.F_StoreHeadUserId as storeManagerUserId
        from ftb_store_user_relation a left join ftb_store b on a.F_StoreId=b.F_Id
        where a.F_DeleteMark = 0
        <if test="userIds != null and userIds.size() > 0 ">
            and a.F_UserId in
            <foreach collection="userIds" item="item" open="("  separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>

    <select id="querySimpleStoreUserDto" resultType="jnpf.model.personnels.dto.staff.roster.SimpleStoreUserDto" parameterType="java.util.Set">
        SELECT
	     b.F_StoreId as storeId,b.F_UserId as userId,a.F_StoreName as storeName,
         b.F_OrganizeId as affiliatedOrg,b.F_PositionId as affiliatedPosition,b.F_RankId as affiliatedRank
        FROM
        ftb_store a JOIN ftb_store_user_relation b ON a.F_Id = b.F_StoreId
        WHERE b.F_UserId in
        <foreach collection="userIds" separator="," open="(" close=")" item="userId">
            #{userId}
        </foreach>
        and b.F_DeleteMark = 0 and a.F_DeleteMark = 0
    </select>

</mapper>
