From b931c44bee33ccae4d14594a6419bcf0a26b29dd Mon Sep 17 00:00:00 2001
From: 野心家 <1051256694@qq.com>
Date: 星期三, 24 一月 2024 09:39:50 +0800
Subject: [PATCH] 修复Loc_mast导出问题

---
 src/main/java/com/zy/asrs/service/impl/ApiLogServiceImpl.java |   42 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/ApiLogServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/ApiLogServiceImpl.java
index e428fee..1bea28a 100644
--- a/src/main/java/com/zy/asrs/service/impl/ApiLogServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/ApiLogServiceImpl.java
@@ -1,12 +1,48 @@
 package com.zy.asrs.service.impl;
 
-import com.zy.asrs.mapper.ApiLogMapper;
-import com.zy.asrs.entity.ApiLog;
-import com.zy.asrs.service.ApiLogService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.zy.asrs.entity.ApiLog;
+import com.zy.asrs.mapper.ApiLogMapper;
+import com.zy.asrs.service.ApiLogService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+@Slf4j
 @Service("apiLogService")
 public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper, ApiLog> implements ApiLogService {
+    @Async
+    @Override
+    public void save(String namespace, String url, String appkey, String ip, String request, String response, boolean success) {
+        Date now = new Date();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+        ApiLog apiLog = new ApiLog(
+                dateFormat.format(now),    // 鏃ュ織缂栧彿
+                namespace,    // 鍚嶇О绌洪棿
+                url,    // 鎺ュ彛鍦板潃
+                "110",    // 骞冲彴瀵嗛挜
+                String.valueOf(now.getTime()),    // 鏃堕棿鎴�
+                ip,    // 瀹㈡埛绔疘P
+                request,    // 璇锋眰鍐呭
+                response,
+                "0",    // 寮傚父鍐呭
+                success?1:0 ,    // 缁撴灉
+                1,    // 鐘舵��
+                now,    // 娣诲姞鏃堕棿
+                now,    // 淇敼鏃堕棿
+                "null"    // 澶囨敞
+        );
+        if (this.baseMapper.insert(apiLog) < 0) {
+            log.error("鎺ュ彛璋冪敤鏃ュ織淇濆瓨澶辫触锛�");
+        }
+    }
 
+    @Override
+    public boolean clearWeekBefore() {
+        return this.baseMapper.clearWeekBefore() > 0;
+    }
 }

--
Gitblit v1.9.1