331 lines
11 KiB
XML
331 lines
11 KiB
XML
<?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.cm.population.dao.rentalhousing.IRentalHousingDao">
|
|
|
|
<resultMap id="rentalHousingDTO" type="com.cm.population.pojo.dtos.rentalhousing.RentalHousingDTO">
|
|
<id column="rental_housing_id" property="rentalHousingId"/>
|
|
<result column="lessee_name" property="lesseeName"/>
|
|
<result column="longitude" property="longitude"/>
|
|
<result column="latitude" property="latitude"/>
|
|
<result column="houser_name" property="houserName"/>
|
|
<result column="hidden_danger_type" property="hiddenDangerType"/>
|
|
<result column="architecture_purpose" property="architecturePurpose"/>
|
|
<result column="house_address" property="houseAddress"/>
|
|
<result column="lessee_card_number" property="lesseeCardNumber"/>
|
|
<result column="house_number" property="houseNumber"/>
|
|
<result column="lease_purpose" property="leasePurpose"/>
|
|
<result column="houser_address" property="houserAddress"/>
|
|
<result column="lessee_phone" property="lesseePhone"/>
|
|
<result column="architecture_area" property="architectureArea"/>
|
|
<result column="houser_phone" property="houserPhone"/>
|
|
<result column="card_number" property="cardNumber"/>
|
|
<result column="card_code" property="cardCode"/>
|
|
</resultMap>
|
|
|
|
<!-- 新增出租房 -->
|
|
<insert id="saveRentalHousing" parameterType="map" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT IGNORE INTO gen_rental_housing(
|
|
rental_housing_id,
|
|
lessee_name,
|
|
longitude,
|
|
latitude,
|
|
houser_name,
|
|
hidden_danger_type,
|
|
architecture_purpose,
|
|
house_address,
|
|
lessee_card_number,
|
|
house_number,
|
|
lease_purpose,
|
|
houser_address,
|
|
lessee_phone,
|
|
architecture_area,
|
|
houser_phone,
|
|
card_number,
|
|
card_code,
|
|
creator,
|
|
gmt_create,
|
|
modifier,
|
|
gmt_modified,
|
|
is_delete
|
|
) SELECT
|
|
#{rentalHousingId},
|
|
#{lesseeName},
|
|
#{longitude},
|
|
#{latitude},
|
|
#{houserName},
|
|
#{hiddenDangerType},
|
|
#{architecturePurpose},
|
|
#{houseAddress},
|
|
#{lesseeCardNumber},
|
|
#{houseNumber},
|
|
#{leasePurpose},
|
|
#{houserAddress},
|
|
#{lesseePhone},
|
|
#{architectureArea},
|
|
#{houserPhone},
|
|
#{cardNumber},
|
|
#{cardCode},
|
|
#{creator},
|
|
#{gmtCreate},
|
|
#{modifier},
|
|
#{gmtModified},
|
|
#{isDelete}
|
|
FROM
|
|
DUAL
|
|
WHERE
|
|
NOT EXISTS (
|
|
SELECT
|
|
*
|
|
FROM
|
|
gen_rental_housing
|
|
WHERE
|
|
house_number = #{houseNumber}
|
|
AND is_delete = 0
|
|
)
|
|
</insert>
|
|
|
|
<!-- 批量导入出租房 -->
|
|
<insert id="saveRentalHousingList" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT IGNORE INTO gen_rental_housing(
|
|
rental_housing_id,
|
|
lessee_name,
|
|
longitude,
|
|
latitude,
|
|
houser_name,
|
|
hidden_danger_type,
|
|
architecture_purpose,
|
|
house_address,
|
|
lessee_card_number,
|
|
house_number,
|
|
lease_purpose,
|
|
houser_address,
|
|
lessee_phone,
|
|
architecture_area,
|
|
houser_phone,
|
|
card_number,
|
|
card_code,
|
|
creator,
|
|
gmt_create,
|
|
modifier,
|
|
gmt_modified,
|
|
is_delete
|
|
)
|
|
<foreach collection="list" index="index" item="item" separator="union all">
|
|
SELECT
|
|
#{item.rentalHousingId},
|
|
#{item.lesseeName},
|
|
#{item.longitude},
|
|
#{item.latitude},
|
|
#{item.houserName},
|
|
#{item.hiddenDangerType},
|
|
#{item.architecturePurpose},
|
|
#{item.houseAddress},
|
|
#{item.lesseeCardNumber},
|
|
#{item.houseNumber},
|
|
#{item.leasePurpose},
|
|
#{item.houserAddress},
|
|
#{item.lesseePhone},
|
|
#{item.architectureArea},
|
|
#{item.houserPhone},
|
|
#{item.cardNumber},
|
|
#{item.cardCode},
|
|
#{item.creator},
|
|
#{item.gmtCreate},
|
|
#{item.modifier},
|
|
#{item.gmtModified},
|
|
#{item.isDelete}
|
|
FROM
|
|
DUAL
|
|
WHERE
|
|
NOT EXISTS (
|
|
SELECT
|
|
*
|
|
FROM
|
|
gen_rental_housing
|
|
WHERE
|
|
house_number = #{item.houseNumber}
|
|
AND is_delete = 0
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- 删除出租房 -->
|
|
<update id="removeRentalHousing" parameterType="map">
|
|
UPDATE
|
|
gen_rental_housing
|
|
SET
|
|
is_delete = 1,
|
|
modifier = #{modifier},
|
|
gmt_modified = #{gmtModified}
|
|
WHERE
|
|
rental_housing_id IN
|
|
<foreach collection="rentalHousingIds" index="index" open="(" separator="," close=")">
|
|
#{rentalHousingIds[${index}]}
|
|
</foreach>
|
|
</update>
|
|
|
|
<!-- 删除出租房(物理) -->
|
|
<update id="deleteRentalHousing" parameterType="map">
|
|
DELETE FROM
|
|
gen_rental_housing
|
|
WHERE
|
|
rental_housing_id IN
|
|
<foreach collection="rentalHousingIds" index="index" open="(" separator="," close=")">
|
|
#{rentalHousingIds[${index}]}
|
|
</foreach>
|
|
</update>
|
|
|
|
<!-- 修改出租房 -->
|
|
<update id="updateRentalHousing" parameterType="map">
|
|
UPDATE
|
|
gen_rental_housing
|
|
SET
|
|
<if test="lesseeName != null and lesseeName != ''">
|
|
lessee_name = #{lesseeName},
|
|
</if>
|
|
<if test="longitude != null and longitude != ''">
|
|
longitude = #{longitude},
|
|
</if>
|
|
<if test="latitude != null and latitude != ''">
|
|
latitude = #{latitude},
|
|
</if>
|
|
<if test="houserName != null and houserName != ''">
|
|
houser_name = #{houserName},
|
|
</if>
|
|
<if test="hiddenDangerType != null and hiddenDangerType != ''">
|
|
hidden_danger_type = #{hiddenDangerType},
|
|
</if>
|
|
<if test="architecturePurpose != null and architecturePurpose != ''">
|
|
architecture_purpose = #{architecturePurpose},
|
|
</if>
|
|
<if test="houseAddress != null and houseAddress != ''">
|
|
house_address = #{houseAddress},
|
|
</if>
|
|
<if test="lesseeCardNumber != null and lesseeCardNumber != ''">
|
|
lessee_card_number = #{lesseeCardNumber},
|
|
</if>
|
|
<if test="houseNumber != null and houseNumber != ''">
|
|
house_number = #{houseNumber},
|
|
</if>
|
|
<if test="leasePurpose != null and leasePurpose != ''">
|
|
lease_purpose = #{leasePurpose},
|
|
</if>
|
|
<if test="houserAddress != null and houserAddress != ''">
|
|
houser_address = #{houserAddress},
|
|
</if>
|
|
<if test="lesseePhone != null and lesseePhone != ''">
|
|
lessee_phone = #{lesseePhone},
|
|
</if>
|
|
<if test="architectureArea != null and architectureArea != ''">
|
|
architecture_area = #{architectureArea},
|
|
</if>
|
|
<if test="houserPhone != null and houserPhone != ''">
|
|
houser_phone = #{houserPhone},
|
|
</if>
|
|
<if test="cardNumber != null and cardNumber != ''">
|
|
card_number = #{cardNumber},
|
|
</if>
|
|
<if test="cardCode != null and cardCode != ''">
|
|
card_code = #{cardCode},
|
|
</if>
|
|
modifier = #{modifier},
|
|
gmt_modified = #{gmtModified}
|
|
WHERE
|
|
rental_housing_id = #{rentalHousingId}
|
|
</update>
|
|
|
|
<!-- 出租房详情 -->
|
|
<select id="getRentalHousing" parameterType="map" resultMap="rentalHousingDTO">
|
|
SELECT
|
|
t1.lessee_name,
|
|
t1.longitude,
|
|
t1.latitude,
|
|
t1.houser_name,
|
|
t1.hidden_danger_type,
|
|
t1.architecture_purpose,
|
|
t1.house_address,
|
|
t1.lessee_card_number,
|
|
t1.house_number,
|
|
t1.lease_purpose,
|
|
t1.houser_address,
|
|
t1.lessee_phone,
|
|
t1.architecture_area,
|
|
t1.houser_phone,
|
|
t1.card_number,
|
|
t1.card_code,
|
|
t1.rental_housing_id
|
|
FROM
|
|
gen_rental_housing t1
|
|
WHERE
|
|
t1.is_delete = 0
|
|
<if test="rentalHousingId != null and rentalHousingId != ''">
|
|
AND
|
|
t1.rental_housing_id = #{rentalHousingId}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 出租房列表 -->
|
|
<select id="listRentalHousing" parameterType="map" resultMap="rentalHousingDTO">
|
|
SELECT
|
|
t1.lessee_name,
|
|
t1.longitude,
|
|
t1.latitude,
|
|
t1.houser_name,
|
|
t1.hidden_danger_type,
|
|
t1.architecture_purpose,
|
|
t1.house_address,
|
|
t1.lessee_card_number,
|
|
t1.house_number,
|
|
t1.lease_purpose,
|
|
t1.houser_address,
|
|
t1.lessee_phone,
|
|
t1.architecture_area,
|
|
t1.houser_phone,
|
|
t1.card_number,
|
|
t1.card_code,
|
|
t1.rental_housing_id
|
|
FROM
|
|
gen_rental_housing t1
|
|
WHERE
|
|
t1.is_delete = 0
|
|
<if test="keywords != null and keywords != ''">
|
|
AND (
|
|
t1.lessee_name LIKE CONCAT('%', #{keywords}, '%')
|
|
OR
|
|
t1.houser_name LIKE CONCAT('%', #{keywords}, '%')
|
|
OR
|
|
t1.lessee_card_number LIKE CONCAT('%', #{keywords}, '%')
|
|
OR
|
|
t1.house_number LIKE CONCAT('%', #{keywords}, '%')
|
|
OR
|
|
t1.card_number LIKE CONCAT('%', #{keywords}, '%')
|
|
)
|
|
</if>
|
|
<if test="startTime != null and startTime != ''">
|
|
AND
|
|
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
|
</if>
|
|
<if test="endTime != null and endTime != ''">
|
|
AND
|
|
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
|
</if>
|
|
<if test="rentalHousingIds != null and rentalHousingIds.size > 0">
|
|
AND
|
|
t1.rental_housing_id IN
|
|
<foreach collection="rentalHousingIds" index="index" open="(" separator="," close=")">
|
|
#{rentalHousingIds[${index}]}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 出租房统计 -->
|
|
<select id="countRentalHousing" parameterType="map" resultType="Integer">
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
gen_rental_housing t1
|
|
WHERE
|
|
t1.is_delete = 0
|
|
</select>
|
|
|
|
</mapper> |