<?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>
<select id= "selectByRecordId" parameterType= "java.util.Map" resultMap= "resultMap_memberInfo" >
SELECT
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}
</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}
</select>
<select id= "overNum" resultType= "Integer" >
select count(*) from t_game_user_join where record_id = #{recordId,jdbcType=BIGINT} and score < #{score,jdbcType=INTEGER}
</select>
<select id= "getAllRanking" resultType= "com.ccsens.game.bean.vo.ClientVo$Ranking" >
SELECT user_id as userId,(@rowNum:=@rowNum+1) AS rank
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
</select>
</mapper>