<?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.web.v2.mapper.JsSampleMapper">
    <!-- 查询最新记录并加锁 -->
    <select id="selectLatestForUpdate" resultType="com.ruoyi.web.v2.model.JsSample">
        SELECT * FROM js_sample
        WHERE is_deleted = 0
        ORDER BY id DESC
        LIMIT 1
    FOR UPDATE
    </select>

    <!-- 查询单条记录 -->
    <select id="selectForOne" parameterType="com.ruoyi.web.v2.model.JsSample" resultType="com.ruoyi.web.v2.model.JsSample">
        SELECT * FROM js_sample
        <where>
            is_deleted = 0
            <if test="id != null">
                and id=#{id}
            </if>
            <if test="entranceBatchId != null">
                and entrance_batch_id=#{entranceBatchId}
            </if>
        </where>
        ORDER BY id DESC
        LIMIT 1
    </select>
</mapper>
