<?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.qmth.jkserver.dao.AttachmentDao">

    <select id="findById" resultType="com.qmth.jkserver.model.Attachment">
        select * from jk_attachment t
        <where>
            <if test="id != null and id != ''">
                and t.id = #{id}
            </if>
        </where>
    </select>

    <delete id="deleteById">
        delete t from jk_attachment t
        <where>
            <if test="id != null and id != ''">
                and t.id = #{id}
            </if>
        </where>
    </delete>

    <select id="findByRelateId" resultType="com.qmth.jkserver.model.Attachment">
        select * from jk_attachment t
        <where>
            <if test="relateId != null and relateId != ''">
                and t.relate_id = #{relateId}
            </if>
        </where>
    </select>

    <select id="findDistinctExtByExamCode" resultType="java.lang.String">
        SELECT DISTINCT t.ext as 'ext' FROM jk_attachment t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
        </where>
    </select>
</mapper>
