10 changed files with 168 additions and 36 deletions
@ -1,9 +1,29 @@ |
|||||
package com.ccsens.game.persist.dao; |
package com.ccsens.game.persist.dao; |
||||
|
|
||||
import com.ccsens.game.bean.po.GameGroup; |
import com.ccsens.game.bean.po.GameGroup; |
||||
|
import com.ccsens.game.bean.vo.ClientVo; |
||||
|
import com.ccsens.game.bean.vo.ScreenVo; |
||||
import com.ccsens.game.persist.mapper.GameGroupMapper; |
import com.ccsens.game.persist.mapper.GameGroupMapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
import org.springframework.stereotype.Repository; |
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
@Repository |
@Repository |
||||
public interface GameGroupDao extends GameGroupMapper { |
public interface GameGroupDao extends GameGroupMapper { |
||||
|
/** |
||||
|
* 查询分组信息 |
||||
|
* @param id 游戏ID |
||||
|
* @return 分组信息 |
||||
|
*/ |
||||
|
List<ScreenVo.GroupVo> queryGroups(@Param("gameId") Long id); |
||||
|
|
||||
|
/** |
||||
|
* 查询各组分数,次数 |
||||
|
* @param groupId 分组ID |
||||
|
* @param gameId 游戏ID |
||||
|
* @param rankRule 排序规则 |
||||
|
* @return 分组分数,次数 |
||||
|
*/ |
||||
|
List<ClientVo.GroupVo> queryScores(@Param("groupId") long groupId, @Param("gameId") long gameId, @Param("rankRule") byte rankRule); |
||||
} |
} |
||||
|
@ -0,0 +1,41 @@ |
|||||
|
<?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.GameGroupDao"> |
||||
|
|
||||
|
<select id="queryGroups" resultType="com.ccsens.game.bean.vo.ScreenVo$GroupVo"> |
||||
|
SELECT |
||||
|
g.id AS groupId, |
||||
|
g.NAME AS groupName, |
||||
|
g.head_portrait_url as headPortraitUrl, |
||||
|
sum( u.score ) AS score, |
||||
|
count( ug.id ) AS totalMembers |
||||
|
FROM |
||||
|
t_game_group g |
||||
|
LEFT JOIN ( SELECT * FROM t_game_user_join_group WHERE rec_status = 0 ) ug ON g.id = ug.game_group_id |
||||
|
LEFT JOIN ( SELECT * FROM t_game_user_join WHERE rec_status = 0 ) u ON ug.user_join_id = u.id |
||||
|
WHERE |
||||
|
g.rec_status = 0 |
||||
|
AND g.record_id = #{gameId} |
||||
|
GROUP BY |
||||
|
g.id |
||||
|
order by sum(u.score) desc |
||||
|
</select> |
||||
|
<select id="queryScores" resultType="com.ccsens.game.bean.vo.ClientVo$GroupVo"> |
||||
|
SELECT |
||||
|
g.id AS groupId, |
||||
|
g.head_portrait_url as headPortraitUrl, |
||||
|
g.NAME AS groupName, |
||||
|
if (${rankRule}=1,sum(u.score),(if(count( ug.id )=0, 0 ,sum(u.score)/count( ug.id )))) AS groupScore, |
||||
|
sum(u.times) as groupTimes |
||||
|
FROM |
||||
|
t_game_group g |
||||
|
LEFT JOIN ( SELECT * FROM t_game_user_join_group WHERE rec_status = 0 ) ug ON g.id = ug.game_group_id |
||||
|
LEFT JOIN ( SELECT * FROM t_game_user_join WHERE rec_status = 0 ) u ON ug.user_join_id = u.id |
||||
|
WHERE |
||||
|
g.rec_status = 0 |
||||
|
AND g.record_id = #{gameId} |
||||
|
GROUP BY |
||||
|
g.id |
||||
|
order by groupScore desc |
||||
|
</select> |
||||
|
</mapper> |
Loading…
Reference in new issue