<?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.xunmei.core.resumption.mapper.AppRuleItemMapper">
    <select id="pageQuery" resultType="com.xunmei.core.resumption.vo.appRuleItem.AppRuleItemPageVo">
        select i.*,
        (select count(p.id) from core_resumption_rule_point p where p.item_id=i.id and p.deleted=0
            <if test="itemPageDto.pointName!=null and itemPageDto.pointName!=''">and `name` like concat('%',#{itemPageDto.pointName},'%'))</if>) as pointNums from
        core_resumption_rule_item i
        <where>
            <if test="itemPageDto.ruleId != null and itemPageDto.ruleId !=''">
                and i.rule_id = #{itemPageDto.ruleId}
            </if>
            <if test="itemPageDto.itemName != null and itemPageDto.itemName!=''">
                and i.iname like CONCAT('%',#{itemPageDto.itemName},'%')
            </if>
            <if test="itemPageDto.pointName!=null and itemPageDto.pointName!=''">
                and i.id in (select item_id from core_resumption_rule_point  where rule_id= #{itemPageDto.ruleId} and `name` like concat('%',#{itemPageDto.pointName},'%'))
            </if>
        </where>
    </select>

<!--    <select id="selectDataTypeList" resultType="com.isp.dict.dto.SecBookDtInstDto">-->
<!--        select ID as id, DATA_NAME as name-->
<!--        from sec_book_dt_inst-->
<!--        where DELETE_STATUS = '0'-->
<!--    </select>-->

<!--    <select id="selectCheckAreaList" resultType="com.isp.core.vo.area.AreaListVo">-->
<!--        select id, name, org_type as orgType-->
<!--        from t_area-->
<!--        where deleted = 0-->
<!--    </select>-->



<!--    <select id="checkItemNumRepeat" resultType="java.lang.Integer">-->
<!--        select count(id) from core_resumption_rule_item where rule_id=#{ruleId} and item_num=#{itemNum}-->
<!--        <if test="id != null">-->
<!--            and id != #{id}-->
<!--        </if>-->

<!--    </select>-->

    <select id="checkItemNameRepeat" resultType="java.lang.Integer">
        select count(id) from core_resumption_rule_item where rule_id=#{ruleId} and name=#{itemName}
        <if test="id != null">
            and id != #{id}
        </if>
    </select>
</mapper>
