sql

<?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.example.demotest.dao.VideoMapper">
    <sql id="sele_fi">
        name
        ,phone,cove
    </sql>
    <select id="selectById" resultType="video">
        select *
        from video
        where id = #{video_id};
    </select>
    <select id="selectByIdList" resultType="video">
        select <include refid="sele_fi"></include>
        from video;
    </select>
    <insert id="add" parameterType="video" useGeneratedKeys="true" keyColumn="id"
            keyProperty="id">
        insert into video (name, phone, cove)
        values (#{name}, #{phone}, #{cove})
    </insert>
    <insert id="addHandle" parameterType="video">
        insert into video (name, phone, cove)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.name}, #{item.phone}, #{item.cove})
        </foreach>
    </insert>
    <update id="editUpdate" parameterType="video">
        update video
        <trim prefix="set" suffixOverrides=",">
            <if test="name !=null">
                name = #{name},
            </if>
            <if test="phone !=null">
                phone = #{phone},
            </if>
            <if test="cove !=null">
                cove = #{cove},
            </if>
        </trim>
        where id = #{id}
    </update>
    <delete id="deleteId" parameterType="video">
        delete
        from video
        where id = #{id}
    </delete>
</mapper>

  

posted @ 2023-05-28 20:46  zjxgdq  阅读(7)  评论(0编辑  收藏  举报