select * from (SELECT b.id, b.project_id, p.NAME 'project_name', b.NAME, b.type, b.dept_id, d.dept_name, b.floor,b.ground_floor,b.underground_floor, b.useto, b.city, b.area, b.address, b.STATUS, b.del_flag, b.create_by, b.create_time, b.update_by, b.update_time FROM ledger_building b LEFT JOIN sys_dept d ON b.dept_id = d.dept_id LEFT JOIN ledger_project p ON b.project_id = p.id) tt
SELECT
b.id,
b.project_id,
p.NAME 'project_name',
b.NAME,
b.type,
b.dept_id,
d.dept_name,
b.floor,
b.ground_floor,
b.underground_floor,
b.useto,
b.city,
b.area,
b.address,
b.STATUS,
b.del_flag,
b.create_by,
b.create_time,
b.update_by,
b.update_time
FROM
ledger_building b
LEFT JOIN sys_dept d ON b.dept_id = d.dept_id
LEFT JOIN ledger_project p ON b.project_id = p.id
<where>
<iftest="projectName != null "> and tt.project_name like concat('%', #{projectName}, '%') </if>
<iftest="projectId != null "> and tt.project_id = #{projectId} </if>
<iftest="name != null and name != ''"> and tt.name like concat('%', #{name}, '%')</if>
<iftest="type != null and type != ''"> and tt.type = #{type}</if>
<iftest="deptId != null "> and tt.dept_name like concat('%', #{deptName}, '%')</if>
<iftest="floor != null and floor != ''"> and tt.floor = #{floor}</if>
<iftest="useto != null and useto != ''"> and tt.useto = #{useto}</if>
<iftest="city != null and city != ''"> and tt.city = #{city}</if>
<iftest="area != null "> and tt.area = #{area}</if>
<iftest="address != null and address != ''"> and tt.address = #{address}</if>
<iftest="status != null and status != ''"> and tt.status = #{status}</if>
and tt.del_flag = '0'
<iftest="projectName != null "> and p.name like concat('%', #{projectName}, '%') </if>
<iftest="projectId != null "> and b.project_id = #{projectId} </if>
<iftest="name != null and name != ''"> and b.name like concat('%', #{name}, '%')</if>
<iftest="type != null and type != ''"> and b.type = #{type}</if>
<iftest="deptId != null "> and ( d.dept_id = #{deptId} or find_in_set(#{deptId},d.ancestors) )</if>
<iftest="useto != null and useto != ''"> and b.useto like concat('%', #{useto}, '%')</if>
<iftest="city != null and city != ''"> and b.city like concat('%', #{city}, '%')</if>
<iftest="status != null and status != ''"> and b.status = #{status}</if>
and b.del_flag = '0'
</where>
</select>
...
...
@@ -126,11 +147,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"