aircraft-server/aircraft-system/src/main/resources/mapper/EmScenicMapper.xml

61 lines
2.1 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.aircraft.modules.system.mapper.EmScenicMapper">
<select id="findByAreaIdAndName" resultType="com.aircraft.modules.system.domain.EmScenic">
SELECT id,
area_id,
name,
people_num,
remark,
create_by,
create_time,
update_by,
update_time,
del_flag
FROM em_scenic
WHERE area_id = #{areaId}
AND name = #{name}
AND del_flag = 0
</select>
<select id="countByAreaId" parameterType="com.aircraft.modules.system.domain.vo.AreaNumStatisVo"
resultType="com.aircraft.modules.system.domain.vo.AreaNumStatisVo">
select area_id, count(id) as scenicNum
from em_scenic
where del_flag = 0
group by area_id
</select>
<select id="getScenicNameMap" resultType="java.util.HashMap">
SELECT
id AS "scenicId", -- 更明确的别名
name AS "scenicName"
FROM em_scenic
WHERE del_flag = 0
<!-- 确保参数正确传递并且当scenicIds为空时的处理逻辑 -->
<if test="scenicIds != null">
<if test="scenicIds.size() > 0">
AND id IN
<foreach collection="scenicIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="scenicIds.size() == 0">
<!-- 当传入空列表时,确保不返回任何结果 -->
AND 1 = 0
</if>
</if>
<if test="scenicIds == null">
AND 1 = 0
</if>
</select>
<select id="listByIds" resultType="com.aircraft.modules.system.domain.EmScenic">
SELECT * FROM em_scenic
WHERE id IN
<foreach collection="list" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>