<?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.ie.mapper.PaperquesMapper">

  <resultMap type="Paperques" id="PaperquesResult">
    <result property="id" column="id" />
    <result property="paperId" column="paperId" />
    <result property="questionId" column="question_id" />
    <result property="sorces" column="sorces" />
    <result property="type" column="type" />
  </resultMap>

  <sql id="selectPaperquesVo">
    select id, paperId, question_id, sorces from paperques
  </sql>

  <select id="selectPaperquesList" parameterType="Paperques" resultMap="PaperquesResult">
    <include refid="selectPaperquesVo" />
    <where>
      <if test="paperId != null "> and paperId = #{paperId}</if>
      <if test="questionId != null "> and question_id = #{questionId}</if>
      <if test="sorces != null "> and sorces = #{sorces}</if>
      <if test="type != null and type != '' "> and type = #{type}</if>
    </where>
  </select>

  <select id="selectPaperquesById" parameterType="Long" resultMap="PaperquesResult">
    <include refid="selectPaperquesVo" />
    where id = #{id}
  </select>

  <insert id="insertPaperques" parameterType="Paperques" useGeneratedKeys="true" keyProperty="id">
    insert into paperques
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="paperId != null">paperId,</if>
      <if test="questionId != null">question_id,</if>
      <if test="sorces != null">sorces,</if>
      <if test="type != null">type,</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="paperId != null">#{paperId},</if>
      <if test="questionId != null">#{questionId},</if>
      <if test="sorces != null">#{sorces},</if>
      <if test="type != null">#{type},</if>
    </trim>
  </insert>

  <insert id="batchInsert" parameterType="Paperques" useGeneratedKeys="true" keyProperty="id">
    insert into paperques(paperId, question_id, sorces, type) VALUES
    <foreach collection="list" item="item" index="index" separator=",">
      (#{item.paperId}, #{item.questionId}, #{item.sorces}, #{item.type})
    </foreach>
  </insert>

  <update id="updatePaperques" parameterType="Paperques">
    update paperques
    <trim prefix="SET" suffixOverrides=",">
      <if test="paperId != null">paperId = #{paperId},</if>
      <if test="questionId != null">question_id = #{questionId},</if>
      <if test="sorces != null">sorces = #{sorces},</if>
      <if test="type != null">type = #{type},</if>
    </trim>
    where id = #{id}
  </update>

  <delete id="deletePaperquesById" parameterType="Long">
    delete from paperques where id = #{id}
  </delete>

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