123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?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.api.games.dao.GameAnswerMapper">
- <resultMap id="BaseResultMap" type="com.api.games.model.GameAnswer">
- <!--
- WARNING - @mbg.generated
- -->
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="game_log_id" jdbcType="BIGINT" property="gameLogId" />
- <result column="answer" jdbcType="INTEGER" property="answer" />
- <result column="correct" jdbcType="INTEGER" property="correct" />
- <result column="reaction" jdbcType="DECIMAL" property="reaction" />
- <result column="show_num" jdbcType="INTEGER" property="showNum" />
- </resultMap>
- <select id="getAvgReaction" resultType="float">
- SELECT avg(reaction) FROM game_answer where game_log_id = #{id} and reaction > 0;
- </select>
- <select id="listByGameIdNew" resultMap="BaseResultMap">
- select * from game_answer where game_log_id =#{id}
- </select>
- <select id="listByGameId" resultType="com.api.common.mybatis.ResultMap">
- SELECT * fROM (select * from game_answer where game_log_id =#{id}) a
- left join game_log gl on (gl.id = a.game_log_id)
- left join sys_user sy on (sy.id = gl.user_id)
- left join user_config uc on (uc.user_id = gl.user_id)
- </select>
- <select id="statistics" resultType="com.api.common.mybatis.ResultMap">
- SELECT sum(case when answer=a.correct=show_num then 1 else 0 end)/count(*) as correctRate,avg(a.reaction) avg_reaction
- fROM game_answer as a
- left join game_log gl on (gl.id = a.game_log_id)
- left join sys_user sy on (sy.id = gl.user_id)
- left join user_config uc on (uc.user_id = gl.user_id)
- where 1=1
- <if test="gameId !=null">
- and game_log_id =#{gameId}
- </if>
- <if test="nickname!=null and nickname!=''">
- and sy.nickname = #{nickname}
- </if>
- <if test="startTime!=null and startTime!=''">
- and date(start_time) = #{startTime}
- </if>
- <if test="sign!=null and sign!=''">
- and sign = #{sign}
- </if>
- <if test="version!=null and version!=''">
- and version = #{version}
- </if>
- <if test="schedule!=null and schedule!=''">
- and schedule = #{schedule}
- </if>
- </select>
- <select id="list" resultType="com.api.common.mybatis.ResultMap">
- SELECT *,gl.id as gid fROM (select * from game_answer) a
- left join game_log gl on (gl.id = a.game_log_id)
- left join sys_user sy on (sy.id = gl.user_id)
- left join user_config uc on (uc.user_id = gl.user_id)
- where 1=1
- <if test="params.nickname!=null and params.nickname!=''">
- and sy.nickname = #{params.nickname}
- </if>
- <if test="params.gameId !=null">
- and game_log_id =#{gameId}
- </if>
- <if test="params.startTime!=null and params.startTime!=''">
- and date(start_time) = #{params.startTime}
- </if>
- <if test="params.sign!=null and params.sign!=''">
- and sign = #{params.sign}
- </if>
- <if test="params.version!=null and params.version!=''">
- and version = #{params.version}
- </if>
- <if test="params.schedule!=null and params.schedule!=''">
- and schedule = #{params.schedule}
- </if>
- order by 1
- <if test="order.nickname!=null and order.nickname!=''">
- ,sy.nickname ${order.nickname}
- </if>
- <if test="order.startTime!=null and order.startTime!=''">
- ,start_time ${order.startTime}
- </if>
- <if test="order.endTime!=null and order.endTime!=''">
- ,end_time ${order.endTime}
- </if>
- <if test="order.version!=null and order.version!=''">
- ,version ${order.version}
- </if>
- <if test="order.sign!=null and order.sign!=''">
- ,sign ${order.sign}
- </if>
- </select>
- </mapper>
|