后台-sud小游戏时长统计-gameId
This commit is contained in:
@@ -11,7 +11,7 @@ public class MiniGameForSudAdminStatsVo {
|
||||
* 游戏ID
|
||||
*/
|
||||
@ApiModelProperty("游戏ID")
|
||||
private Long gameId;
|
||||
private String gameId;
|
||||
|
||||
/**
|
||||
* 游戏名称
|
||||
|
@@ -20,7 +20,7 @@ public interface MiniGameForSudAdminMapper extends BaseMapper<MiniGameRound> {
|
||||
* @param endTime 结束时间戳
|
||||
* @return 统计结果
|
||||
*/
|
||||
List<MiniGameForSudAdminStatsVo> statGameDurationByMonth(@Param("gameId") Long gameId,
|
||||
List<MiniGameForSudAdminStatsVo> statGameDurationByMonth(@Param("gameId") String gameId,
|
||||
@Param("startTime") Long startTime,
|
||||
@Param("endTime") Long endTime);
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface MiniGameForSudAdminMapper extends BaseMapper<MiniGameRound> {
|
||||
* @return 统计结果
|
||||
*/
|
||||
List<MiniGameForSudAdminDetailVo> pageGameRoundDetail(Page<MiniGameForSudAdminDetailVo> page,
|
||||
@Param("gameId") Long gameId,
|
||||
@Param("gameId") String gameId,
|
||||
@Param("startTime") Long startTime,
|
||||
@Param("endTime") Long endTime);
|
||||
|
||||
|
@@ -6,9 +6,8 @@ import com.accompany.business.model.miniGame.MiniGame;
|
||||
import com.accompany.business.model.miniGame.MiniGameRound;
|
||||
import com.accompany.admin.mapper.miniGame.MiniGameForSudAdminMapper;
|
||||
import com.accompany.business.service.miniGame.MiniGameService;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -16,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -39,10 +37,17 @@ public class MiniGameForSudAdminService extends ServiceImpl<MiniGameForSudAdminM
|
||||
* @param month 月份 (格式: yyyy-MM)
|
||||
* @return 统计列表
|
||||
*/
|
||||
public List<MiniGameForSudAdminStatsVo> listStat(Long gameId, String month) {
|
||||
public List<MiniGameForSudAdminStatsVo> listStat(String gameId, String month) {
|
||||
// 获取所有游戏信息
|
||||
List<MiniGame> miniGameList = null == gameId? miniGameService.miniGameAllList(null):
|
||||
Collections.singletonList(miniGameService.queryMiniGameByMgId(gameId));
|
||||
List<MiniGame> miniGameList = miniGameService.miniGameAllList(null);
|
||||
if (CollectionUtils.isEmpty(miniGameList)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if (!StringUtils.isBlank(gameId)){
|
||||
miniGameList = miniGameList.stream().filter(game -> game.getMgIdStr().equals(gameId)).toList();
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(miniGameList)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -58,13 +63,13 @@ public class MiniGameForSudAdminService extends ServiceImpl<MiniGameForSudAdminM
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Map<Long, MiniGameForSudAdminStatsVo> statMap = statList.stream().collect(Collectors.toMap(MiniGameForSudAdminStatsVo::getGameId, vo -> vo));
|
||||
Map<String, MiniGameForSudAdminStatsVo> statMap = statList.stream().collect(Collectors.toMap(MiniGameForSudAdminStatsVo::getGameId, vo -> vo));
|
||||
|
||||
return miniGameList.stream().map(game -> {
|
||||
MiniGameForSudAdminStatsVo vo = statMap.get(game.getMgId());
|
||||
MiniGameForSudAdminStatsVo vo = statMap.get(game.getMgIdStr());
|
||||
if (vo == null){
|
||||
vo = new MiniGameForSudAdminStatsVo();
|
||||
vo.setGameId(game.getMgId());
|
||||
vo.setGameId(game.getMgIdStr());
|
||||
vo.setGameName(game.getName());
|
||||
vo.setTotalDuration(0L);
|
||||
vo.setEnDuration(0L);
|
||||
@@ -87,12 +92,7 @@ public class MiniGameForSudAdminService extends ServiceImpl<MiniGameForSudAdminM
|
||||
* @param size 每页大小
|
||||
* @return 明细列表
|
||||
*/
|
||||
public Page<MiniGameForSudAdminDetailVo> pageDetail(Long gameId, String month, Integer page, Integer size) {
|
||||
// 获取所有游戏信息
|
||||
MiniGame miniGame = miniGameService.queryMiniGameByMgId(gameId);
|
||||
if (null == miniGame) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
public Page<MiniGameForSudAdminDetailVo> pageDetail(String gameId, String month, Integer page, Integer size) {
|
||||
|
||||
Page<MiniGameForSudAdminDetailVo> voPage = new Page<>(page, size);
|
||||
|
||||
@@ -105,17 +105,5 @@ public class MiniGameForSudAdminService extends ServiceImpl<MiniGameForSudAdminM
|
||||
|
||||
return voPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出游戏时长明细
|
||||
* @param gameId 游戏ID
|
||||
* @param month 月份 (格式: yyyy-MM)
|
||||
* @param response HTTP响应
|
||||
*/
|
||||
public void exportDetail(Long gameId, String month, HttpServletResponse response) {
|
||||
// 实现导出逻辑
|
||||
// 这里可以使用Apache POI或其他库来生成Excel文件
|
||||
// 为简化起见,此处仅提供方法框架
|
||||
log.info("导出游戏时长明细: gameId={}, month={}", gameId, month);
|
||||
}
|
||||
|
||||
}
|
@@ -16,7 +16,7 @@
|
||||
JOIN users u ON mgr.room_uid = u.uid
|
||||
WHERE
|
||||
battle_start_at between #{startTime} and #{endTime}
|
||||
<if test="gameId != null">
|
||||
<if test="gameId != null and gameId != ''">
|
||||
AND mgr.mg_id = #{gameId}
|
||||
</if>
|
||||
and mgr.state = 2
|
||||
@@ -31,7 +31,7 @@
|
||||
left join partition_info pi on u.partition_id = pi.partition_id
|
||||
where
|
||||
battle_start_at between #{startTime} and #{endTime}
|
||||
<if test="gameId != null">
|
||||
<if test="gameId != null and gameId != ''">
|
||||
and mgr.mg_id = #{gameId}
|
||||
</if>
|
||||
and mgr.state = 2
|
||||
|
@@ -33,12 +33,12 @@ public class MiniGameForSudAdminController {
|
||||
|
||||
@ApiOperation("获取休闲游戏时长统计列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "gameId", value = "游戏ID", required = false, dataType = "Long", paramType = "query"),
|
||||
@ApiImplicitParam(name = "gameId", value = "游戏ID", required = false, dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "month", value = "月份(格式: yyyy-MM)", required = true, dataType = "String", paramType = "query")
|
||||
})
|
||||
@GetMapping("/listStat")
|
||||
public BusiResult<List<MiniGameForSudAdminStatsVo>> listStat(
|
||||
Long gameId,
|
||||
String gameId,
|
||||
String month) {
|
||||
if (!StringUtils.hasText(month)){
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
@@ -50,12 +50,12 @@ public class MiniGameForSudAdminController {
|
||||
@SneakyThrows
|
||||
@ApiOperation("导出休闲游戏时长统计")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "gameId", value = "游戏ID", required = false, dataType = "Long", paramType = "query"),
|
||||
@ApiImplicitParam(name = "gameId", value = "游戏ID", required = false, dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "month", value = "月份(格式: yyyy-MM)", required = true, dataType = "String", paramType = "query")
|
||||
})
|
||||
@GetMapping("/exportStat")
|
||||
public void exportStat(
|
||||
Long gameId,
|
||||
String gameId,
|
||||
String month,
|
||||
HttpServletResponse response) {
|
||||
if (!StringUtils.hasText(month)){
|
||||
@@ -72,14 +72,14 @@ public class MiniGameForSudAdminController {
|
||||
|
||||
@ApiOperation("获取休闲游戏时长明细列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "gameId", value = "游戏ID", required = true, dataType = "Long", paramType = "query"),
|
||||
@ApiImplicitParam(name = "gameId", value = "游戏ID", required = true, dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "month", value = "月份(格式: yyyy-MM)", required = true, dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "Integer", paramType = "query"),
|
||||
@ApiImplicitParam(name = "size", value = "每页大小", required = true, dataType = "Integer", paramType = "query")
|
||||
})
|
||||
@GetMapping("/pageDetail")
|
||||
public BusiResult<Page<MiniGameForSudAdminDetailVo>> pageDetail(
|
||||
Long gameId,
|
||||
String gameId,
|
||||
String month,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
@@ -90,12 +90,12 @@ public class MiniGameForSudAdminController {
|
||||
@SneakyThrows
|
||||
@ApiOperation("导出休闲游戏时长明细")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "gameId", value = "游戏ID", required = true, dataType = "Long", paramType = "query"),
|
||||
@ApiImplicitParam(name = "gameId", value = "游戏ID", required = true, dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "month", value = "月份(格式: yyyy-MM)", required = true, dataType = "String", paramType = "query")
|
||||
})
|
||||
@GetMapping("/exportDetail")
|
||||
public void exportDetail(
|
||||
Long gameId,
|
||||
String gameId,
|
||||
String month,
|
||||
HttpServletResponse response) {
|
||||
if (null == gameId || !StringUtils.hasText(month)) {
|
||||
|
Reference in New Issue
Block a user