<?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.yinlihupo.enlish.service.domain.mapper.ExamWordsDOMapper">
    <resultMap id="BaseResultMap" type="com.yinlihupo.enlish.service.domain.dataobject.ExamWordsDO">
        <id column="id" jdbcType="INTEGER" property="id" />
        <result column="grade_id" jdbcType="INTEGER" property="gradeId" />
        <result column="level" jdbcType="INTEGER" property="level" />
        <result column="title" jdbcType="VARCHAR" property="title" />
        <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
        <result column="type" jdbcType="INTEGER" property="type" />
    </resultMap>
    <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.yinlihupo.enlish.service.domain.dataobject.ExamWordsDO">
        <result column="word_ids" jdbcType="LONGVARCHAR" property="wordIds" typeHandler="com.yinlihupo.enlish.service.config.ListWordIdTypeHandler" />
    </resultMap>

    <insert id="insert" useGeneratedKeys="true" keyProperty="id">
        insert into exam_words (grade_id, level, title, word_ids, type, created_at)
        VALUES (#{gradeId}, #{level}, #{title}, #{wordIds, typeHandler=com.yinlihupo.enlish.service.config.ListWordIdTypeHandler}, #{type}, #{createdAt})
    </insert>

    <update id="updateWordIdsOrder">
        update exam_words
        set word_ids = #{wordIds, typeHandler=com.yinlihupo.enlish.service.config.ListWordIdTypeHandler}
        where id = #{id}
    </update>

    <select id="selectById" resultMap="ResultMapWithBLOBs">
        select * from exam_words where id = #{id}
    </select>


</mapper>