<?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.yuyu.srdisassemble.data.mapper.SqlDataMapper">


    <update id="creatTable">
        create table if not exists srdisassemble
        (
            id BIGINT auto_increment comment 'ID',
            playername      varchar(255) null comment '玩家姓名',
            disassembleTime datetime     null comment '分解的时间',
            target          varchar(255) null comment '分解的目标',
            targetIndex     varchar(255) null comment '分解目标的索引'
            guiname         varchar(255) null comment '打开gui的名称'
            );
    </update>

    <update id="setChartseUtf8">
        ALTER TABLE srdisassemble CONVERT TO CHARACTER SET utf8mb4;
    </update>

    <insert id="addDisassembleEvent" parameterType="com.yuyu.srdisassemble.pojo.DisassembleData">
        insert into srdisassemble(playername,disassembleTime,target,targetIndex)
        values(
               #{data.playername},
               #{data.disassembleTime},
               #{data.target},
               #{data.targetIndex}
              )
    </insert>

    <select id="selectDisassembleEvent" resultMap="dataMap">
        select * from srdisassemble
        where playername = #{playername};
    </select>

    <select id="selectDisassembleEventAndTarget" resultType="com.yuyu.srdisassemble.pojo.DisassembleData">
        select * from srdisassemble
        where playername = #{playername}
        and target = #{target};
    </select>

    <delete id="deleteDisassemble">
        delete from srdisassemble where
                    id = #{id}
    </delete>

    <resultMap id="dataMap" type="com.yuyu.srdisassemble.pojo.DisassembleData">
        <result property="playername" javaType="java.lang.String" column="playername"></result>
        <result property="disassembleTime" javaType="java.util.Date" column="disassembleTime"></result>
        <result property="target" javaType="java.lang.String" column="target"></result>
        <result property="targetIndex" javaType="java.lang.String" column="targetIndex"></result>
    </resultMap>


</mapper>








