<?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="org.fool.glorious.db.mapper.RecordMapper">

    <select id="selectRecords" resultType="org.fool.glorious.db.entity.Record">
        select * from
        <choose>
            <when test="type != null and type == 'php'">
                phpwebshell
            </when>
            <when test="type != null and type == 'jsp'">
                jspwebshell
            </when>
            <otherwise>
                jspwebshell
            </otherwise>
        </choose>

        <where>
            <if test="keyword != null and keyword != ''">
                content like "%"#{keyword}"%"
            </if>
        </where>

    </select>

    <insert id="insertRecord" parameterType="org.fool.glorious.db.entity.Record">
        insert into

        <choose>
            <when test="type == 'php'">
                phpwebshell
            </when>
            <when test="type == 'jsp'">
                jspwebshell
            </when>
            <otherwise>
                jspwebshell
            </otherwise>
        </choose>

        (name, type, size, content, keyword, remark)
            values(#{name}, #{type}, #{size}, #{content}, #{keyword}, #{remark})
    </insert>

</mapper>