|
@@ -21,12 +21,15 @@ package com.pig4cloud.pigx.admin.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
import com.pig4cloud.pigx.admin.api.entity.SysLog;
|
|
|
+import com.pig4cloud.pigx.admin.api.vo.PreLogVo;
|
|
|
import com.pig4cloud.pigx.admin.mapper.SysLogMapper;
|
|
|
import com.pig4cloud.pigx.admin.service.SysLogService;
|
|
|
import com.pig4cloud.pigx.common.core.constant.CommonConstant;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -48,4 +51,27 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
|
|
sysLog.setUpdateTime(LocalDateTime.now());
|
|
|
return updateById(sysLog);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量插入前端错误日志
|
|
|
+ *
|
|
|
+ * @param preLogVoList 日志信息
|
|
|
+ * @return true/false
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean insertLogs(List<PreLogVo> preLogVoList) {
|
|
|
+ List<SysLog> sysLogs = new ArrayList<>();
|
|
|
+ preLogVoList.forEach(pre -> {
|
|
|
+ SysLog log = new SysLog();
|
|
|
+ log.setType(CommonConstant.STATUS_LOCK);
|
|
|
+ log.setTitle(pre.getInfo());
|
|
|
+ log.setException(pre.getStack());
|
|
|
+ log.setParams(pre.getMessage());
|
|
|
+ log.setCreateTime(LocalDateTime.now());
|
|
|
+ log.setRequestUri(pre.getUrl());
|
|
|
+ log.setCreateBy(pre.getUser());
|
|
|
+ sysLogs.add(log);
|
|
|
+ });
|
|
|
+ return this.insertBatch(sysLogs);
|
|
|
+ }
|
|
|
}
|