|
|
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Tag(name = "日志管理", description = "操作日志查询接口")
|
|
|
@RestController
|
|
|
@@ -23,17 +24,31 @@ public class OperationLogController {
|
|
|
private UserOperationLogService logService;
|
|
|
|
|
|
@Operation(summary = "分页查询操作日志")
|
|
|
- @GetMapping("/operations")
|
|
|
+ @PostMapping("/operations")
|
|
|
public Result<Page<UserOperationLog>> queryLogs(
|
|
|
@RequestAttribute("userId") Long adminId,
|
|
|
- @RequestParam(required = false) Long userId,
|
|
|
- @RequestParam(required = false) String operationType,
|
|
|
- @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
|
|
|
- @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
|
|
|
- @RequestParam(defaultValue = "1") Integer page,
|
|
|
- @RequestParam(defaultValue = "20") Integer size) {
|
|
|
-
|
|
|
- // 可以添加权限检查:admin角色才能查看
|
|
|
+ @RequestBody Map<String, Object> params) {
|
|
|
+ Long userId = params.get("userId") != null ? ((Number) params.get("userId")).longValue() : null;
|
|
|
+ String operationType = (String) params.get("operationType");
|
|
|
+ Integer page = params.get("page") != null ? (Integer) params.get("page") : 1;
|
|
|
+ Integer size = params.get("size") != null ? (Integer) params.get("size") : 20;
|
|
|
+
|
|
|
+ // 解析日期
|
|
|
+ Date startDate = null;
|
|
|
+ Date endDate = null;
|
|
|
+ try {
|
|
|
+ if (params.get("startDate") != null) {
|
|
|
+ java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ startDate = sdf.parse((String) params.get("startDate"));
|
|
|
+ }
|
|
|
+ if (params.get("endDate") != null) {
|
|
|
+ java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ endDate = sdf.parse((String) params.get("endDate"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 日期解析失败
|
|
|
+ }
|
|
|
+
|
|
|
Page<UserOperationLog> result = logService.queryLogs(
|
|
|
userId, operationType, startDate, endDate, page, size);
|
|
|
|
|
|
@@ -41,11 +56,12 @@ public class OperationLogController {
|
|
|
}
|
|
|
|
|
|
@Operation(summary = "获取用户最近操作记录")
|
|
|
- @GetMapping("/recent/{userId}")
|
|
|
+ @PostMapping("/recent")
|
|
|
public Result<List<UserOperationLog>> getRecentLogs(
|
|
|
@RequestAttribute("userId") Long adminId,
|
|
|
- @PathVariable Long userId,
|
|
|
- @RequestParam(defaultValue = "10") Integer limit) {
|
|
|
+ @RequestBody Map<String, Object> params) {
|
|
|
+ Long userId = ((Number) params.get("userId")).longValue();
|
|
|
+ Integer limit = params.get("limit") != null ? (Integer) params.get("limit") : 10;
|
|
|
|
|
|
List<UserOperationLog> logs = logService.getRecentLogs(userId, limit);
|
|
|
return Result.success(logs);
|