<?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.dezhi.mapper.BBusiDezhiVideoPackageTeacherMapper">

  <resultMap type="BBusiDezhiVideoPackageTeacher" id="BBusiDezhiVideoPackageTeacherResult">
    <result property="id" column="id" />
    <result property="packId" column="pack_id" />
    <result property="teacherName" column="teacher_name" />
    <result property="teacherDesc" column="teacher_desc" />
    <result property="teacherIntro" column="teacher_intro" />
    <result property="teacherImgurl" column="teacher_imgurl" />
    <result property="teacherSubject" column="teacher_subject" />
    <result property="teacherPeriods" column="teacher_periods" />
    <result property="sectionImgurl" column="section_imgurl" />
    <result property="teacherId" column="teacher_id" />
    <result property="from" column="from" />
  </resultMap>

  <sql id="selectBBusiDezhiVideoPackageTeacherVo">
    select id, pack_id, teacher_name, teacher_desc, teacher_intro, teacher_imgurl, teacher_subject, teacher_periods, section_imgurl, teacher_id, `from` from
    b_busi_dezhi_video_package_teacher
  </sql>

  <select id="selectBBusiDezhiVideoPackageTeacherList" parameterType="BBusiDezhiVideoPackageTeacher" resultMap="BBusiDezhiVideoPackageTeacherResult">
    <include refid="selectBBusiDezhiVideoPackageTeacherVo" />
    <where>
      <if test="packId != null  and packId != ''"> and pack_id = #{packId}</if>
      <if test="teacherName != null  and teacherName != ''"> and teacher_name like concat('%', #{teacherName}, '%')</if>
      <if test="teacherDesc != null  and teacherDesc != ''"> and teacher_desc = #{teacherDesc}</if>
      <if test="teacherIntro != null  and teacherIntro != ''"> and teacher_intro = #{teacherIntro}</if>
      <if test="teacherImgurl != null  and teacherImgurl != ''"> and teacher_imgurl = #{teacherImgurl}</if>
      <if test="teacherSubject != null  and teacherSubject != ''"> and teacher_subject = #{teacherSubject}</if>
      <if test="teacherPeriods != null  and teacherPeriods != ''"> and teacher_periods = #{teacherPeriods}</if>
      <if test="sectionImgurl != null  and sectionImgurl != ''"> and section_imgurl = #{sectionImgurl}</if>
      <if test="teacherId != null  and teacherId != ''"> and teacher_id = #{teacherId}</if>
      <if test="from != null  and from != ''"> and from = #{from}</if>
    </where>
  </select>

  <select id="selectBBusiDezhiVideoPackageTeacherById" parameterType="Long" resultMap="BBusiDezhiVideoPackageTeacherResult">
    <include refid="selectBBusiDezhiVideoPackageTeacherVo" />
    where id = #{id}
  </select>

  <insert id="insertBBusiDezhiVideoPackageTeacher" parameterType="BBusiDezhiVideoPackageTeacher" useGeneratedKeys="true" keyProperty="id">
    insert into b_busi_dezhi_video_package_teacher
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="packId != null and packId != ''">pack_id,</if>
      <if test="teacherName != null">teacher_name,</if>
      <if test="teacherDesc != null">teacher_desc,</if>
      <if test="teacherIntro != null">teacher_intro,</if>
      <if test="teacherImgurl != null">teacher_imgurl,</if>
      <if test="teacherSubject != null">teacher_subject,</if>
      <if test="teacherPeriods != null">teacher_periods,</if>
      <if test="sectionImgurl != null">section_imgurl,</if>
      <if test="teacherId != null">teacher_id,</if>
      <if test="from != null">from,</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="packId != null and packId != ''">#{packId},</if>
      <if test="teacherName != null">#{teacherName},</if>
      <if test="teacherDesc != null">#{teacherDesc},</if>
      <if test="teacherIntro != null">#{teacherIntro},</if>
      <if test="teacherImgurl != null">#{teacherImgurl},</if>
      <if test="teacherSubject != null">#{teacherSubject},</if>
      <if test="teacherPeriods != null">#{teacherPeriods},</if>
      <if test="sectionImgurl != null">#{sectionImgurl},</if>
      <if test="teacherId != null">#{teacherId},</if>
      <if test="from != null">#{from},</if>
    </trim>
  </insert>

  <update id="updateBBusiDezhiVideoPackageTeacher" parameterType="BBusiDezhiVideoPackageTeacher">
    update b_busi_dezhi_video_package_teacher
    <trim prefix="SET" suffixOverrides=",">
      <if test="packId != null and packId != ''">pack_id = #{packId},</if>
      <if test="teacherName != null">teacher_name = #{teacherName},</if>
      <if test="teacherDesc != null">teacher_desc = #{teacherDesc},</if>
      <if test="teacherIntro != null">teacher_intro = #{teacherIntro},</if>
      <if test="teacherImgurl != null">teacher_imgurl = #{teacherImgurl},</if>
      <if test="teacherSubject != null">teacher_subject = #{teacherSubject},</if>
      <if test="teacherPeriods != null">teacher_periods = #{teacherPeriods},</if>
      <if test="sectionImgurl != null">section_imgurl = #{sectionImgurl},</if>
      <if test="teacherId != null">teacher_id = #{teacherId},</if>
      <if test="from != null">from = #{from},</if>
    </trim>
    where id = #{id}
  </update>

  <delete id="deleteBBusiDezhiVideoPackageTeacherById" parameterType="Long">
    delete from b_busi_dezhi_video_package_teacher where id = #{id}
  </delete>

  <delete id="deleteBBusiDezhiVideoPackageTeacherByIds" parameterType="String">
    delete from b_busi_dezhi_video_package_teacher where id in
    <foreach item="id" collection="array" open="(" separator="," close=")">
      #{id}
    </foreach>
  </delete>
</mapper>