| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.zy.asrs.entity.ApiLog; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service("apiLogService") |
| | |
| | | null, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | if (!this.insert(apiLog)) { |
| | | log.error("接口调用日志保存失败!"); |
| | | } |
| | | insertApiLogIgnoreFailure(apiLog); |
| | | } |
| | | |
| | | @Async |
| | |
| | | null, // 修改时间 |
| | | memo // 备注 |
| | | ); |
| | | if (!this.insert(apiLog)) { |
| | | log.error("接口调用日志保存失败!"); |
| | | insertApiLogIgnoreFailure(apiLog); |
| | | } |
| | | |
| | | /** 日志落库失败不影响业务,打印完整实体与异常 */ |
| | | private void insertApiLogIgnoreFailure(ApiLog apiLog) { |
| | | try { |
| | | if (!this.insert(apiLog)) { |
| | | log.error("接口调用日志保存失败 apiLog: {}", JSON.toJSONString(apiLog)); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("接口调用日志保存异常 apiLog: {}", JSON.toJSONString(apiLog), e); |
| | | } |
| | | } |
| | | |
| | |
| | | public boolean clearWeekBefore() { |
| | | return this.baseMapper.clearWeekBefore() > 0; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiLog> getLatestData(Integer limit) { |
| | | return this.baseMapper.getLatestData(limit); |
| | | } |
| | | } |