<?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.secKill.dao.SecKillDao"> <!-- 目的:为dao接口方法提供sql语句配置 --> <update id="reduceNumber"> <!-- 具体的sql --> UPDATE seckill SET number = number - 1 WHERE seckill_id = #{secKillId} AND start_time <![CDATA[ <= ]]> #{killTime} AND end_time >= #{killTime} AND number > 0 </update> <select id="queryById" resultType="SecKill" parameterType="long"> SELECT seckill_id, NAME, number, start_time, end_time, create_time FROM seckill WHERE seckill_id = #{secKillId} </select> <select id="queryAll" resultType="SecKill"> SELECT seckill_id, NAME, number, start_time, end_time, create_time FROM seckill ORDER BY create_time DESC LIMIT #{offset}, #{limit} </select> <select id="killByProcedure" statementType="CALLABLE"> call execute_seckill ( #{secKillId, jdbcType = BIGINT, mode = IN }, #{phone, jdbcType = BIGINT, mode = IN }, #{killTime, jdbcType = TIMESTAMP, mode = IN }, #{result, jdbcType = INTEGER, mode = OUT } ) </select> </mapper>
|