<?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.ccsens.game.persist.dao.GameUserJoinDao" >
<resultMap id= "resultMap_memberInfo" type= "com.ccsens.game.bean.vo.ClientVo$MemberInfo" >
<id column= "uId" property= "id" />
<result column= "uHeadImgUrl" property= "headImgUrl" />
<result column= "uNickname" property= "nickname" />
<result column= "uTimes" property= "times" />
<result column= "uScore" property= "score" />
</resultMap>
<update id= "updateTimeBatch" >
update `t_game_user_join` t
set t.local_start_time = #{startTime,jdbcType=BIGINT} + t.time_difference, t.local_end_time = #{endTime,jdbcType=BIGINT} + t.time_difference
where t.record_id = #{recordId,jdbcType=BIGINT}
</update>
<select id= "selectTopTen" resultType= "com.ccsens.game.bean.vo.ScreenVo$TopUsers" >
select user_id, avatar_url as headImgUrl, nickname, score, score/100 as times
from t_game_user_join
where record_id = #{recordId,jdbcType=BIGINT} and rec_status = 0
ORDER BY score DESC
limit 10
</select>
<select id= "selectByRecordId" parameterType= "java.util.Map" resultMap= "resultMap_memberInfo" >
SELECT
user_id as uId,
avatar_url as uHeadImgUrl,
nickname as uNickname,
times as uTimes,
score as uScore
FROM
t_game_user_join
WHERE
record_id = #{recordId} and rec_status = 0
</select>
<select id= "getRanking" resultType= "int" >
SELECT rowNo FROM
(
SELECT user_id,(@rowNum:=@rowNum+1) AS rowNo
FROM
(select user_id,score from t_game_user_join where rec_status = 0 and record_id = #{recordId,jdbcType=BIGINT}) a,
(SELECT(@rowNum:=0)) b
ORDER BY a.score DESC
) c
WHERE c.user_id= #{userId,jdbcType=BIGINT} limit 1
</select>
<select id= "gameCount" resultType= "com.ccsens.game.bean.dto.message.ChangeStatusMessageDto$CompletedData" >
select count(*) as totalMembers, sum(score) as totalScore, AVG(score) as averageTimes from t_game_user_join where record_id = #{recordId,jdbcType=BIGINT} and rec_status = 0
</select>
<select id= "overNum" resultType= "Integer" >
select count(*) from t_game_user_join where record_id = #{recordId,jdbcType=BIGINT} and score < #{score,jdbcType=INTEGER} and rec_status = 0
</select>
<select id= "getAllRanking" resultType= "com.ccsens.game.bean.vo.ClientVo$MemberInfo" >
SELECT a.*,(@rowNum:=@rowNum+1) AS sort
FROM
(select id,score, avatar_url as headImgUrl,nickname, times from t_game_user_join
where
rec_status = 0
and
record_id = #{recordId,jdbcType=BIGINT}) a,
(SELECT(@rowNum:=0)) b
ORDER BY a.score DESC limit #{start}, #{pageSize}
</select>
</mapper>