Files
cpzs-frontend/userController

482 lines
14 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 管理员获取所有双色球推测记录支持分页和用户ID筛选
* @param userId 用户ID可选
* @param current 当前页码默认为1
* @param pageSize 每页大小默认为10
* @param request HTTP请求
* @return 分页的双色球预测记录
*/
@GetMapping("/admin/all-records")
@Operation(summary = "管理员获取所有推测记录", description = "管理员获取所有双色球推测记录支持分页和根据用户ID、中奖等级筛选")
public ApiResponse<PageResponse<PredictRecord>> getAllRecordsForAdmin(
@Parameter(description = "用户ID可选用于筛选指定用户的记录")
@RequestParam(value = "userId", required = false) Long userId,
@Parameter(description = "中奖等级(可选),例如:一等奖、二等奖、未中奖")
@RequestParam(value = "predictResult", required = false) String predictResult,
@Parameter(description = "当前页码从1开始默认为1")
@RequestParam(value = "current", defaultValue = "1") Integer current,
@Parameter(description = "每页大小默认为10")
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request) {
// 验证管理员权限
User loginUser = userService.getLoginUser(request);
if (loginUser == null) {
return ResultUtils.error(ErrorCode.NOT_LOGIN_ERROR, "用户未登录");
}
if (!userService.isAdmin(loginUser)) {
return ResultUtils.error(ErrorCode.NO_AUTH_ERROR, "无权限访问,仅管理员可用");
}
try {
log.info("管理员获取所有双色球推测记录userId={}predictResult={}current={}pageSize={}",
userId, predictResult, current, pageSize);
// 调用Service层方法
PageResponse<PredictRecord> result = predictRecordService.getAllRecordsForAdmin(userId, predictResult, current, pageSize);
log.info("管理员获取双色球推测记录完成,总记录数:{}", result.getTotal());
return ResultUtils.success(result);
} catch (Exception e) {
log.error("管理员获取双色球推测记录失败:{}", e.getMessage(), e);
return ResultUtils.error(ErrorCode.SYSTEM_ERROR, "获取推测记录失败:" + e.getMessage());
}
}
GET http://localhost:8123/api/ball-analysis/admin/all-records?
userId={{$random.integer(100)}}&
predictResult={{$random.alphanumeric(8)}}&
current={{$random.integer(100)}}&
pageSize={{$random.integer(100)}}
响应示例
{
"code": 0,
"success": true,
"message": "操作成功",
"data": {
"records": [
{
"id": 57,
"userId": 1,
"drawId": 2025096,
"drawDate": 1759766400000,
"redBall1": 25,
"redBall2": 17,
"redBall3": 18,
"redBall4": 15,
"redBall5": 21,
"redBall6": 29,
"blueBall": 11,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1759824079000,
"bonus": 0,
"type": "ssq"
},
{
"id": 56,
"userId": 1,
"drawId": 2025096,
"drawDate": 1759766400000,
"redBall1": 13,
"redBall2": 18,
"redBall3": 2,
"redBall4": 4,
"redBall5": 5,
"redBall6": 1,
"blueBall": 10,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1759818889000,
"bonus": 0,
"type": "ssq"
},
{
"id": 55,
"userId": 1,
"drawId": 2025096,
"drawDate": 1758384000000,
"redBall1": 22,
"redBall2": 33,
"redBall3": 24,
"redBall4": 25,
"redBall5": 20,
"redBall6": 15,
"blueBall": 14,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1758427874000,
"bonus": 0,
"type": "ssq"
},
{
"id": 54,
"userId": 1,
"drawId": 2025096,
"drawDate": 1758384000000,
"redBall1": 23,
"redBall2": 25,
"redBall3": 33,
"redBall4": 29,
"redBall5": 24,
"redBall6": 20,
"blueBall": 15,
"predictStatus": "已中奖",
"predictResult": "六等奖",
"predictTime": 1758427335000,
"bonus": 5,
"type": "ssq"
},
{
"id": 53,
"userId": 1,
"drawId": 2025096,
"drawDate": 1758384000000,
"redBall1": 22,
"redBall2": 27,
"redBall3": 29,
"redBall4": 24,
"redBall5": 30,
"redBall6": 25,
"blueBall": 14,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1758427265000,
"bonus": 0,
"type": "ssq"
},
{
"id": 52,
"userId": 1,
"drawId": 2025096,
"drawDate": 1758384000000,
"redBall1": 18,
"redBall2": 27,
"redBall3": 32,
"redBall4": 30,
"redBall5": 29,
"redBall6": 28,
"blueBall": 15,
"predictStatus": "已中奖",
"predictResult": "六等奖",
"predictTime": 1758426942000,
"bonus": 5,
"type": "ssq"
},
{
"id": 51,
"userId": 1,
"drawId": 2025096,
"drawDate": 1758384000000,
"redBall1": 26,
"redBall2": 18,
"redBall3": 23,
"redBall4": 19,
"redBall5": 20,
"redBall6": 25,
"blueBall": 14,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1758426099000,
"bonus": 0,
"type": "ssq"
},
{
"id": 50,
"userId": 1,
"drawId": 2025096,
"drawDate": 1757520000000,
"redBall1": 22,
"redBall2": 18,
"redBall3": 19,
"redBall4": 23,
"redBall5": 20,
"redBall6": 15,
"blueBall": 13,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1757597385000,
"bonus": 0,
"type": "ssq"
},
{
"id": 49,
"userId": 1,
"drawId": 2025096,
"drawDate": 1757260800000,
"redBall1": 14,
"redBall2": 20,
"redBall3": 18,
"redBall4": 27,
"redBall5": 33,
"redBall6": 13,
"blueBall": 15,
"predictStatus": "已中奖",
"predictResult": "六等奖",
"predictTime": 1757312366000,
"bonus": 5,
"type": "ssq"
},
{
"id": 48,
"userId": 1,
"drawId": 2025095,
"drawDate": 1756828800000,
"redBall1": 17,
"redBall2": 22,
"redBall3": 27,
"redBall4": 16,
"redBall5": 6,
"redBall6": 7,
"blueBall": 4,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1756882722000,
"bonus": 0,
"type": "ssq"
}
],
"total": 35,
"page": 1,
"size": 10,
"totalPages": 4,
"hasNext": true,
"hasPrevious": false
}
}
@GetMapping("/admin/all-records")
@Operation(summary = "管理员获取所有推测记录", description = "管理员获取所有大乐透推测记录支持分页和根据用户ID、中奖等级筛选")
public ApiResponse<PageResponse<DltPredictRecord>> getAllRecordsForAdmin(
@Parameter(description = "用户ID可选用于筛选指定用户的记录")
@RequestParam(value = "userId", required = false) Long userId,
@Parameter(description = "中奖等级(可选),例如:一等奖、二等奖、未中奖")
@RequestParam(value = "predictResult", required = false) String predictResult,
@Parameter(description = "当前页码从1开始默认为1")
@RequestParam(value = "current", defaultValue = "1") Integer current,
@Parameter(description = "每页大小默认为10")
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request) {
// 验证管理员权限
User loginUser = userService.getLoginUser(request);
if (loginUser == null) {
return ResultUtils.error(ErrorCode.NOT_LOGIN_ERROR, "用户未登录");
}
if (!userService.isAdmin(loginUser)) {
return ResultUtils.error(ErrorCode.NO_AUTH_ERROR, "无权限访问,仅管理员可用");
}
try {
log.info("管理员获取所有大乐透推测记录userId={}predictResult={}current={}pageSize={}",
userId, predictResult, current, pageSize);
// 调用Service层方法
PageResponse<DltPredictRecord> result = dltPredictRecordService.getAllRecordsForAdmin(userId, predictResult, current, pageSize);
log.info("管理员获取大乐透推测记录完成,总记录数:{}", result.getTotal());
return ResultUtils.success(result);
} catch (Exception e) {
log.error("管理员获取大乐透推测记录失败:{}", e.getMessage(), e);
return ResultUtils.error(ErrorCode.SYSTEM_ERROR, "获取推测记录失败:" + e.getMessage());
}
}
GET http://localhost:8123/api/dlt-predict/admin/all-records?
userId={{$random.integer(100)}}&
predictResult={{$random.alphanumeric(8)}}&
current={{$random.integer(100)}}&
pageSize={{$random.integer(100)}}
{
"code": 0,
"success": true,
"message": "操作成功",
"data": {
"records": [
{
"id": 23,
"userId": 1,
"drawId": 25117,
"drawDate": null,
"frontendBall1": 16,
"frontendBall2": 13,
"frontendBall3": 14,
"frontendBall4": 9,
"frontendBall5": 4,
"backendBall1": 2,
"backendBall2": 5,
"predictStatus": "待开奖",
"predictResult": "待开奖",
"predictTime": 1763967816000,
"bonus": 0
},
{
"id": 22,
"userId": 1,
"drawId": 25106,
"drawDate": null,
"frontendBall1": 10,
"frontendBall2": 32,
"frontendBall3": 33,
"frontendBall4": 35,
"frontendBall5": 1,
"backendBall1": 6,
"backendBall2": 8,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1759909486000,
"bonus": 0
},
{
"id": 21,
"userId": 1,
"drawId": 25106,
"drawDate": null,
"frontendBall1": 11,
"frontendBall2": 22,
"frontendBall3": 25,
"frontendBall4": 28,
"frontendBall5": 29,
"backendBall1": 11,
"backendBall2": 12,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1759909424000,
"bonus": 0
},
{
"id": 20,
"userId": 1,
"drawId": 25106,
"drawDate": null,
"frontendBall1": 5,
"frontendBall2": 22,
"frontendBall3": 28,
"frontendBall4": 30,
"frontendBall5": 35,
"backendBall1": 7,
"backendBall2": 3,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1759909344000,
"bonus": 0
},
{
"id": 19,
"userId": 1,
"drawId": 25109,
"drawDate": null,
"frontendBall1": 5,
"frontendBall2": 28,
"frontendBall3": 18,
"frontendBall4": 32,
"frontendBall5": 22,
"backendBall1": 9,
"backendBall2": 12,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1758511498000,
"bonus": 0
},
{
"id": 18,
"userId": 1,
"drawId": 25109,
"drawDate": null,
"frontendBall1": 3,
"frontendBall2": 11,
"frontendBall3": 23,
"frontendBall4": 29,
"frontendBall5": 34,
"backendBall1": 2,
"backendBall2": 7,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1758510538000,
"bonus": 0
},
{
"id": 17,
"userId": 1,
"drawId": 25109,
"drawDate": null,
"frontendBall1": 32,
"frontendBall2": 1,
"frontendBall3": 2,
"frontendBall4": 5,
"frontendBall5": 23,
"backendBall1": 3,
"backendBall2": 7,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1758510155000,
"bonus": 0
},
{
"id": 16,
"userId": 1,
"drawId": 25109,
"drawDate": null,
"frontendBall1": 19,
"frontendBall2": 12,
"frontendBall3": 2,
"frontendBall4": 33,
"frontendBall5": 22,
"backendBall1": 1,
"backendBall2": 7,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1758509942000,
"bonus": 0
},
{
"id": 15,
"userId": 1,
"drawId": 25109,
"drawDate": null,
"frontendBall1": 29,
"frontendBall2": 20,
"frontendBall3": 22,
"frontendBall4": 32,
"frontendBall5": 35,
"backendBall1": 10,
"backendBall2": 2,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1758509591000,
"bonus": 0
},
{
"id": 14,
"userId": 1,
"drawId": 25109,
"drawDate": null,
"frontendBall1": 14,
"frontendBall2": 28,
"frontendBall3": 30,
"frontendBall4": 2,
"frontendBall5": 20,
"backendBall1": 2,
"backendBall2": 3,
"predictStatus": "未中奖",
"predictResult": "未中奖",
"predictTime": 1758509292000,
"bonus": 0
}
],
"total": 14,
"page": 1,
"size": 10,
"totalPages": 2,
"hasNext": true,
"hasPrevious": false
}
}