ride-lease/ridelease-system/src/main/resources/mapper/system/RlCityMapper.xml

66 lines
2.5 KiB
XML
Raw Normal View History

2024-09-19 11:25:42 +08:00
<?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.ruoyi.system.mapper.RlCityMapper">
<resultMap type="RlCity" id="RlCityResult">
<result property="cityId" column="city_id" />
<result property="name" column="name" />
<result property="pinyin" column="pinyin" />
<result property="level" column="level" />
</resultMap>
<sql id="selectRlCityVo">
select city_id, name, pinyin, level from rl_city
</sql>
<select id="selectRlCityList" parameterType="RlCity" resultMap="RlCityResult">
<include refid="selectRlCityVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="pinyin != null and pinyin != ''"> and pinyin = #{pinyin}</if>
<if test="level != null and level != ''"> and level = #{level}</if>
</where>
</select>
<select id="selectRlCityByCityId" parameterType="Long" resultMap="RlCityResult">
<include refid="selectRlCityVo"/>
where city_id = #{cityId}
</select>
<insert id="insertRlCity" parameterType="RlCity" useGeneratedKeys="true" keyProperty="cityId">
insert into rl_city
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="pinyin != null">pinyin,</if>
<if test="level != null">level,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="pinyin != null">#{pinyin},</if>
<if test="level != null">#{level},</if>
</trim>
</insert>
<update id="updateRlCity" parameterType="RlCity">
update rl_city
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="pinyin != null">pinyin = #{pinyin},</if>
<if test="level != null">level = #{level},</if>
</trim>
where city_id = #{cityId}
</update>
<delete id="deleteRlCityByCityId" parameterType="Long">
delete from rl_city where city_id = #{cityId}
</delete>
<delete id="deleteRlCityByCityIds" parameterType="String">
delete from rl_city where city_id in
<foreach item="cityId" collection="array" open="(" separator="," close=")">
#{cityId}
</foreach>
</delete>
</mapper>