<?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.yeejoin.amos.boot.module.tzs.flc.api.mapper.UnitInfoMapper">


    <select id="getUnitByType" resultType="com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto">
			select
			a.*
			from tz_flc_unit_info a
			where a.is_delete = 0 AND
			(a.unit_status = '1' or  a.is_change = 1)
			AND a.unit_type_code LIKE CONCAT('%', #{typeCode}, '%')
    </select>

	<select id="getAllUnit" resultType="com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto">
			select
			a.*
			from tz_flc_unit_info a
			where a.is_delete = 0
			AND
			(a.unit_status = '1' or  a.is_change = 1)
    </select>


	<select id="getUnitByTypeParams" resultType="com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto">
			select
			a.*,
			CONCAT(a.province, a.city,  a.district ,a.stree,a.community,a.address ) as fullAddress
			from tz_flc_unit_info a
			where a.is_delete = 0 AND
			(a.unit_status = '1' or  a.is_change = 1)
			AND a.unit_type_code LIKE CONCAT('%', #{typeCode}, '%')
		<if test="unitType != null and unitType != ''">
			AND a.unit_type LIKE CONCAT('%', #{unitType}, '%')
		</if>
		<if test="address != null and address != ''">
			AND ( a.province LIKE CONCAT('%', #{address}, '%')
			OR a.city LIKE CONCAT('%', #{address}, '%')
			OR a.district LIKE CONCAT('%', #{address}, '%')
			OR a.stree LIKE CONCAT('%', #{address}, '%')
			OR a.community LIKE CONCAT('%', #{address}, '%')
			OR a.address LIKE CONCAT('%', #{address}, '%')
			)
		</if>
		<if test="orgName != null and orgName != ''">
			AND a.org_name LIKE CONCAT('%', #{orgName}, '%')
		</if>
		<if test="organizationCode != null and organizationCode != ''">
			AND a.organization_code LIKE CONCAT('%', #{organizationCode}, '%')
		</if>
    </select>


</mapper>
