btxtgxq-system-population/src/main/resources/mybatis/mapper/residential/residential-mapper.xml
2023-11-16 18:21:55 +08:00

440 lines
15 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.residential.IResidentialDao">
<resultMap id="residentialDTO" type="com.cm.population.pojo.dtos.residential.ResidentialDTO">
<result column="residential_id" property="residentialId"/>
<result column="name" property="name"/>
<result column="community" property="community"/>
<result column="community_name" property="communityName"/>
<result column="residential_type_id" property="residentialTypeId"/>
<result column="residential_type_name" property="residentialTypeName"/>
<result column="address" property="address"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
<result column="image" property="image"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
<result column="street" property="street"/>
<result column="street_name" property="streetName"/>
</resultMap>
<resultMap id="residentialBO" type="com.cm.population.pojo.bos.residential.ResidentialBO">
<result column="residential_id" property="residentialId"/>
<result column="name" property="name"/>
<result column="community" property="community"/>
<result column="community_name" property="communityName"/>
<result column="residential_type_id" property="residentialTypeId"/>
<result column="residential_type_name" property="residentialTypeName"/>
<result column="address" property="address"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
<result column="image" property="image"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
<result column="street" property="street"/>
<result column="street_name" property="streetName"/>
</resultMap>
<resultMap id="residentialPO" type="com.cm.population.pojo.pos.residential.ResidentialPO">
<result column="residential_id" property="residentialId"/>
<result column="name" property="name"/>
<result column="community" property="community"/>
<result column="community_name" property="communityName"/>
<result column="residential_type_id" property="residentialTypeId"/>
<result column="residential_type_name" property="residentialTypeName"/>
<result column="address" property="address"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
<result column="image" property="image"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
<result column="street" property="street"/>
<result column="street_name" property="streetName"/>
</resultMap>
<!-- 新增小区管理 -->
<insert id="save" parameterType="map">
INSERT INTO house_residential(
residential_id,
name,
street,
street_name,
community,
community_name,
residential_type_id,
residential_type_name,
address,
longitude,
latitude,
image,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{residentialId},
#{name},
#{street},
#{streetName},
#{community},
#{communityName},
#{residentialTypeId},
#{residentialTypeName},
#{address},
#{longitude},
#{latitude},
#{image},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除小区管理 -->
<update id="remove" parameterType="map">
UPDATE
house_residential
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
residential_id IN
<foreach collection="residentialIds" index="index" open="(" separator="," close=")">
#{residentialIds[${index}]}
</foreach>
</update>
<!-- 删除小区管理(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
house_residential
WHERE
residential_id IN
<foreach collection="residentialIds" index="index" open="(" separator="," close=")">
#{residentialIds[${index}]}
</foreach>
</update>
<!-- 修改小区管理 -->
<update id="update" parameterType="map">
UPDATE
house_residential
SET
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="street != null and street != ''">
street = #{street},
</if>
<if test="streetName != null and streetName != ''">
street_name = #{streetName},
</if>
<if test="community != null and community != ''">
community = #{community},
</if>
<if test="communityName != null and communityName != ''">
community_name = #{communityName},
</if>
<if test="residentialTypeId != null and residentialTypeId != ''">
residential_type_id = #{residentialTypeId},
</if>
<if test="residentialTypeName != null and residentialTypeName != ''">
residential_type_name = #{residentialTypeName},
</if>
<if test="address != null and address != ''">
address = #{address},
</if>
<if test="longitude != null and longitude != ''">
longitude = #{longitude},
</if>
<if test="latitude != null and latitude != ''">
latitude = #{latitude},
</if>
<if test="image != null and image != ''">
image = #{image},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
residential_id = residential_id
WHERE
residential_id = #{residentialId}
</update>
<!-- 小区管理详情 -->
<select id="get" parameterType="map" resultMap="residentialDTO">
SELECT
t1.name,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_type_id,
t1.residential_type_name,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.residential_id,
t1.creator
FROM
house_residential t1
WHERE
t1.is_delete = 0
<if test="residentialId != null and residentialId != ''">
AND
t1.residential_id = #{residentialId}
</if>
</select>
<!-- 小区管理详情 -->
<select id="getBO" parameterType="map" resultMap="residentialBO">
SELECT
t1.residential_id,
t1.name,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_type_id,
t1.residential_type_name,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
house_residential t1
WHERE
t1.is_delete = 0
<if test="residentialId != null and residentialId != ''">
AND
t1.residential_id = #{residentialId}
</if>
</select>
<!-- 小区管理详情 -->
<select id="getPO" parameterType="map" resultMap="residentialPO">
SELECT
t1.residential_id,
t1.name,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_type_id,
t1.residential_type_name,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
house_residential t1
WHERE
t1.is_delete = 0
<if test="residentialId != null and residentialId != ''">
AND
t1.residential_id = #{residentialId}
</if>
</select>
<!-- 小区管理列表 -->
<select id="list" parameterType="map" resultMap="residentialDTO">
SELECT
t1.residential_id,
t1.name,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_type_id,
t1.residential_type_name,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete,
1
FROM
house_residential t1
WHERE
t1.is_delete = 0
<if test="creator != null and creator != ''">
AND t1.creator = #{creator}
</if>
<if test="keywords != null and keywords != ''">
AND (
t1.name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="name != null and name != ''">
AND t1.name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="street != null and street != ''">
AND t1.street = #{street}
</if>
<if test="streetName != null and streetName != ''">
AND t1.street_name LIKE CONCAT('%', #{streetName}, '%')
</if>
<if test="community != null and community != ''">
AND t1.community = #{community}
</if>
<if test="communityName != null and communityName != ''">
AND t1.community_name LIKE CONCAT('%', #{communityName}, '%')
</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="residentialIds != null and residentialIds.size > 0">
AND
t1.residential_id IN
<foreach collection="residentialIds" index="index" open="(" separator="," close=")">
#{residentialIds[${index}]}
</foreach>
</if>
</select>
<!-- 小区管理列表 -->
<select id="listBO" parameterType="map" resultMap="residentialBO">
SELECT
t1.residential_id,
t1.name,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_type_id,
t1.residential_type_name,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
house_residential t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id 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="residentialIds != null and residentialIds.size > 0">
AND
t1.residential_id IN
<foreach collection="residentialIds" index="index" open="(" separator="," close=")">
#{residentialIds[${index}]}
</foreach>
</if>
</select>
<!-- 小区管理列表 -->
<select id="listPO" parameterType="map" resultMap="residentialPO">
SELECT
t1.residential_id,
t1.name,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_type_id,
t1.residential_type_name,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
house_residential t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id 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="residentialIds != null and residentialIds.size > 0">
AND
t1.residential_id IN
<foreach collection="residentialIds" index="index" open="(" separator="," close=")">
#{residentialIds[${index}]}
</foreach>
</if>
</select>
<!-- 小区管理统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
house_residential t1
WHERE
t1.is_delete = 0
</select>
<select id="getStreetId" parameterType="String" resultType="String">
SELECT dict_id FROM d_dict WHERE dict_name = #{street} and is_delete = 0
</select>
<select id="getCommunityId" parameterType="String" resultType="String">
SELECT community_id FROM d_community WHERE community_name = #{community} and is_delete = 0
</select>
</mapper>