From 7a47adbbc342c6f171d9be6a5e335f765edd7b72 Mon Sep 17 00:00:00 2001 From: khalil <842328916@qq.com> Date: Tue, 26 Aug 2025 15:04:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0-sud=E5=B0=8F=E6=B8=B8?= =?UTF-8?q?=E6=88=8F=E6=97=B6=E9=95=BF=E7=BB=9F=E8=AE=A1-=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../miniGame/MiniGameForSudAdminService.java | 6 ++--- .../MiniGameForSudAdminController.java | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/miniGame/MiniGameForSudAdminService.java b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/miniGame/MiniGameForSudAdminService.java index b450c84c6..59fc2652d 100644 --- a/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/miniGame/MiniGameForSudAdminService.java +++ b/accompany-admin/accompany-admin-service/src/main/java/com/accompany/admin/service/miniGame/MiniGameForSudAdminService.java @@ -49,8 +49,8 @@ public class MiniGameForSudAdminService extends ServiceImpl statList = miniGameForSudAdminMapper.statGameDurationByMonth(gameId, startTime, endTime); @@ -66,7 +66,6 @@ public class MiniGameForSudAdminService extends ServiceImpl result = miniGameForSudAdminService.listStat(gameId, month); return BusiResult.success(result); } + + @SneakyThrows + @ApiOperation("导出休闲游戏时长统计") + @ApiImplicitParams({ + @ApiImplicitParam(name = "gameId", value = "游戏ID", required = false, dataType = "Long", paramType = "query"), + @ApiImplicitParam(name = "month", value = "月份(格式: yyyy-MM)", required = true, dataType = "String", paramType = "query") + }) + @GetMapping("/exportStat") + public void exportStat( + Long gameId, + String month, + HttpServletResponse response) { + if (!StringUtils.hasText(month)){ + throw new AdminServiceException(BusiStatus.PARAMERROR); + } + List dataList = miniGameForSudAdminService.listStat(gameId, month); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("休闲游戏时长统计", "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), MiniGameForSudAdminStatsVo.class).sheet("休闲游戏时长统计").doWrite(dataList); + } @ApiOperation("获取休闲游戏时长明细列表") @ApiImplicitParams({