btxtgxq-system-city/src/main/resources/mybatis/mapper/community/community-mapper.xml
2023-10-27 17:44:11 +08:00

167 lines
5.1 KiB
XML
Executable File

<?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.systemcity.dao.community.ICommunityDao">
<resultMap id="communityDTO" type="com.cm.systemcity.pojo.dtos.community.CommunityDTO">
<id property="communityId" column="community_id"/>
<result property="communityName" column="community_name"/>
<result property="communitySummary" column="community_summary"/>
<result property="communityOrder" column="community_order"/>
<result property="areaId" column="area_id"/>
<result property="areaName" column="area_name"/>
<result property="jumpSystemUrl" column="jump_system_url"/>
</resultMap>
<!-- 新增社区 -->
<insert id="saveCommunity" parameterType="map">
INSERT INTO city_community(
community_id,
community_name,
community_summary,
community_order,
area_id,
area_name,
jump_system_url,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{communityId},
#{communityName},
#{communitySummary},
#{communityOrder},
#{areaId},
#{areaName},
#{jumpSystemUrl},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除社区 -->
<update id="removeCommunity" parameterType="map">
UPDATE
city_community
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
community_id IN
<foreach collection="communityIds" index="index" open="(" separator="," close=")">
#{communityIds[${index}]}
</foreach>
</update>
<!-- 修改社区 -->
<update id="updateCommunity" parameterType="map">
UPDATE
city_community
SET
<if test="communityName != null and communityName != ''">
community_name = #{communityName},
</if>
<if test="communitySummary != null and communitySummary != ''">
community_summary = #{communitySummary},
</if>
<if test="communityOrder != null">
community_order = #{communityOrder},
</if>
<if test="areaId != null and areaId != ''">
area_id = #{areaId},
</if>
<if test="areaName != null and areaName != ''">
area_name = #{areaName},
</if>
<if test="jumpSystemUrl != null and jumpSystemUrl != ''">
jump_system_url = #{jumpSystemUrl},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
community_id = #{communityId}
</update>
<!-- 社区列表 -->
<select id="listCommunity" parameterType="map" resultMap="communityDTO">
SELECT
t1.*
FROM
city_community t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND
t1.community_name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="startTime != null and startTime != ''">
AND
t1.gmt_create <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
t1.gmt_create <![CDATA[ <= ]]> #{endTime}
</if>
<if test="areaId != null and areaId != ''">
AND
t1.area_id = #{areaId}
</if>
<if test="communityIds != null and communityIds.size > 0">
AND
t1.community_id IN
<foreach collection="communityIds" index="index" open="(" separator="," close=")">
#{communityIds[${index}]}
</foreach>
</if>
</select>
<!-- 社区详情 -->
<select id="getCommunity" parameterType="map" resultMap="communityDTO">
SELECT
t1.*
FROM
city_community t1
WHERE
t1.is_delete = 0
<if test="communityId != null and communityId != ''">
AND
t1.community_id = #{communityId}
</if>
<if test="communityName != null and communityName != ''">
AND
t1.community_name = #{communityName}
</if>
</select>
<!-- 社区总数 -->
<select id="countCommunity" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
city_community
WHERE
is_delete = 0
</select>
<!-- 网格长所在片区列表 -->
<select id="listCommunityByCommunityBoss" parameterType="map" resultMap="communityDTO">
SELECT
t2.*
FROM
city_community_boss_community t1
LEFT JOIN
city_community t2
ON
t1.community_id = t2.community_id
WHERE
t2.is_delete = 0
AND
t1.community_boss_id = #{communityBossId}
</select>
</mapper>