<?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.xjrsoft.module.room.mapper.RoomRuleMapper">
    <select id="getPage" resultType="com.xjrsoft.module.room.vo.RoomRulePageVo">
        SELECT id,sort_code,NAME,rule,(
            SELECT GROUP_CONCAT(t2.name) FROM room_rule_item t1
            LEFT JOIN base_office_build t2 ON t1.office_build_id = t2.id
            WHERE t1.delete_mark = 0 AND t2.delete_mark = 0 AND t1.room_rule_id = room_rule.id
        ) AS build_names FROM room_rule WHERE delete_mark = 0 ORDER BY sort_code
    </select>

    <select id="getMaxSortCode" resultType="java.lang.Integer">
        SELECT IFNULL(MAX(sort_code),0) FROM room_rule WHERE delete_mark = 0
    </select>
    <select id="getItemMaxSortCode" resultType="java.lang.Integer">
        SELECT IFNULL(MAX(sort_code),0) FROM room_rule_item WHERE delete_mark = 0
    </select>
</mapper>