<?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="cn.cordys.crm.system.mapper.ExtUserViewConditionMapper">

    <select id="getViewConditions" resultType="cn.cordys.crm.system.domain.UserViewCondition">
        SELECT
            `name`,
            `value`,
            value_type,
            type,
            multiple_value,
            operator,
            children_value
        FROM
            sys_user_view_condition
        where sys_user_view_id = #{viewId}
    </select>

    <delete id="delete">
        DELETE FROM sys_user_view_condition WHERE sys_user_view_id = #{viewId}
    </delete>
    <delete id="deleteByUserIds">
        delete from sys_user_view_condition where sys_user_view_id in (
        select id from sys_user_view where organization_id = #{orgId}
        and user_id in
        <foreach collection="userIds" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        );
    </delete>
</mapper>