Files
smart_management/src/main/resources/mybatis/information/SceneMappingMapper.xml

61 lines
2.5 KiB
XML
Raw Normal View History

<?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">
2025-05-30 16:13:27 +08:00
<mapper namespace="com.zg.project.information.mapper.SceneMappingMapper">
<resultMap type="SceneMapping" id="SceneMappingResult">
<result property="id" column="id" />
<result property="sceneCode" column="scene_code" />
<result property="sceneName" column="scene_name" />
</resultMap>
<sql id="selectSceneMappingVo">
select id, scene_code, scene_name from scene_mapping
</sql>
<select id="selectSceneMappingList" parameterType="SceneMapping" resultMap="SceneMappingResult">
<include refid="selectSceneMappingVo"/>
<where>
<if test="sceneCode != null and sceneCode != ''"> and scene_code = #{sceneCode}</if>
<if test="sceneName != null and sceneName != ''"> and scene_name like concat('%', #{sceneName}, '%')</if>
</where>
</select>
<select id="selectSceneMappingById" parameterType="Long" resultMap="SceneMappingResult">
<include refid="selectSceneMappingVo"/>
where id = #{id}
</select>
<insert id="insertSceneMapping" parameterType="SceneMapping" useGeneratedKeys="true" keyProperty="id">
insert into scene_mapping
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sceneCode != null and sceneCode != ''">scene_code,</if>
<if test="sceneName != null and sceneName != ''">scene_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sceneCode != null and sceneCode != ''">#{sceneCode},</if>
<if test="sceneName != null and sceneName != ''">#{sceneName},</if>
</trim>
</insert>
<update id="updateSceneMapping" parameterType="SceneMapping">
update scene_mapping
<trim prefix="SET" suffixOverrides=",">
<if test="sceneCode != null and sceneCode != ''">scene_code = #{sceneCode},</if>
<if test="sceneName != null and sceneName != ''">scene_name = #{sceneName},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSceneMappingById" parameterType="Long">
delete from scene_mapping where id = #{id}
</delete>
<delete id="deleteSceneMappingByIds" parameterType="String">
delete from scene_mapping where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>