btxtgxq-system-population/src/main/resources/mybatis/mapper/building/building-mapper.xml
2023-11-15 17:21:45 +08:00

476 lines
16 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.building.IBuildingDao">
<resultMap id="buildingDTO" type="com.cm.population.pojo.dtos.building.BuildingDTO">
<result column="building_id" property="buildingId"/>
<result column="community" property="community"/>
<result column="community_name" property="communityName"/>
<result column="residential_id" property="residentialId"/>
<result column="residential_name" property="residentialName"/>
<result column="name" property="name"/>
<result column="build_num" property="buildNum"/>
<result column="floors_num" property="floorsNum"/>
<result column="unit_num" property="unitNum"/>
<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="buildingBO" type="com.cm.population.pojo.bos.building.BuildingBO">
<result column="building_id" property="buildingId"/>
<result column="community" property="community"/>
<result column="community_name" property="communityName"/>
<result column="residential_id" property="residentialId"/>
<result column="residential_name" property="residentialName"/>
<result column="name" property="name"/>
<result column="build_num" property="buildNum"/>
<result column="floors_num" property="floorsNum"/>
<result column="unit_num" property="unitNum"/>
<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="buildingPO" type="com.cm.population.pojo.pos.building.BuildingPO">
<result column="building_id" property="buildingId"/>
<result column="community" property="community"/>
<result column="community_name" property="communityName"/>
<result column="residential_id" property="residentialId"/>
<result column="residential_name" property="residentialName"/>
<result column="name" property="name"/>
<result column="build_num" property="buildNum"/>
<result column="floors_num" property="floorsNum"/>
<result column="unit_num" property="unitNum"/>
<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_building(
building_id,
street,
street_name,
community,
community_name,
residential_id,
residential_name,
name,
build_num,
floors_num,
unit_num,
address,
longitude,
latitude,
image,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{buildingId},
#{street},
#{streetName},
#{community},
#{communityName},
#{residentialId},
#{residentialName},
#{name},
#{buildNum},
#{floorsNum},
#{unitNum},
#{address},
#{longitude},
#{latitude},
#{image},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除楼排管理 -->
<update id="remove" parameterType="map">
UPDATE
house_building
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
building_id IN
<foreach collection="buildingIds" index="index" open="(" separator="," close=")">
#{buildingIds[${index}]}
</foreach>
</update>
<!-- 删除楼排管理(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
house_building
WHERE
building_id IN
<foreach collection="buildingIds" index="index" open="(" separator="," close=")">
#{buildingIds[${index}]}
</foreach>
</update>
<!-- 修改楼排管理 -->
<update id="update" parameterType="map">
UPDATE
house_building
SET
<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="residentialId != null and residentialId != ''">
residential_id = #{residentialId},
</if>
<if test="residentialName != null and residentialName != ''">
residential_name = #{residentialName},
</if>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="buildNum != null">
build_num = #{buildNum},
</if>
<if test="floorsNum != null">
floors_num = #{floorsNum},
</if>
<if test="unitNum != null">
unit_num = #{unitNum},
</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},
building_id = building_id
WHERE
building_id = #{buildingId}
</update>
<!-- 楼排管理详情 -->
<select id="get" parameterType="map" resultMap="buildingDTO">
SELECT
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_id,
t1.residential_name,
t1.name,
t1.build_num,
t1.floors_num,
t1.unit_num,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.building_id,
t1.creator
FROM
house_building t1
WHERE
t1.is_delete = 0
<if test="buildingId != null and buildingId != ''">
AND
t1.building_id = #{buildingId}
</if>
</select>
<!-- 楼排管理详情 -->
<select id="getBO" parameterType="map" resultMap="buildingBO">
SELECT
t1.building_id,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_id,
t1.residential_name,
t1.name,
t1.build_num,
t1.floors_num,
t1.unit_num,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
house_building t1
WHERE
t1.is_delete = 0
<if test="buildingId != null and buildingId != ''">
AND
t1.building_id = #{buildingId}
</if>
</select>
<!-- 楼排管理详情 -->
<select id="getPO" parameterType="map" resultMap="buildingPO">
SELECT
t1.building_id,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_id,
t1.residential_name,
t1.name,
t1.build_num,
t1.floors_num,
t1.unit_num,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
house_building t1
WHERE
t1.is_delete = 0
<if test="buildingId != null and buildingId != ''">
AND
t1.building_id = #{buildingId}
</if>
</select>
<!-- 楼排管理列表 -->
<select id="list" parameterType="map" resultMap="buildingDTO">
SELECT
t1.building_id,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_id,
t1.residential_name,
t1.name,
t1.build_num,
t1.floors_num,
t1.unit_num,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete,
1
FROM
house_building t1
WHERE
t1.is_delete = 0
<if test="creator != null and creator != ''">
AND t1.creator = #{creator}
</if>
<if test="residentialId != null and residentialId != ''">
AND t1.residential_id = #{residentialId}
</if>
<if test="residentialName != null and residentialName != ''">
AND t1.residential_name = #{residentialName}
</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="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="buildingIds != null and buildingIds.size > 0">
AND
t1.building_id IN
<foreach collection="buildingIds" index="index" open="(" separator="," close=")">
#{buildingIds[${index}]}
</foreach>
</if>
</select>
<!-- 楼排管理列表 -->
<select id="listBO" parameterType="map" resultMap="buildingBO">
SELECT
t1.building_id,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_id,
t1.residential_name,
t1.name,
t1.build_num,
t1.floors_num,
t1.unit_num,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
house_building 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="buildingIds != null and buildingIds.size > 0">
AND
t1.building_id IN
<foreach collection="buildingIds" index="index" open="(" separator="," close=")">
#{buildingIds[${index}]}
</foreach>
</if>
</select>
<!-- 楼排管理列表 -->
<select id="listPO" parameterType="map" resultMap="buildingPO">
SELECT
t1.building_id,
t1.street,
t1.street_name,
t1.community,
t1.community_name,
t1.residential_id,
t1.residential_name,
t1.name,
t1.build_num,
t1.floors_num,
t1.unit_num,
t1.address,
t1.longitude,
t1.latitude,
t1.image,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
house_building 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="buildingIds != null and buildingIds.size > 0">
AND
t1.building_id IN
<foreach collection="buildingIds" index="index" open="(" separator="," close=")">
#{buildingIds[${index}]}
</foreach>
</if>
</select>
<!-- 楼排管理统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
house_building t1
WHERE
t1.is_delete = 0
</select>
</mapper>