jiangping
2024-07-30 eea92f23bf8ead897f346ae6ccc8603ac039e566
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/InterfaceLogServiceImpl.java
@@ -2,6 +2,7 @@
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.InterfaceLogMapper;
import com.doumee.dao.business.model.InterfaceLog;
@@ -13,6 +14,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.yaml.snakeyaml.scanner.Constant;
import java.util.List;
@@ -161,4 +163,15 @@
                  .apply("to_days(create_date)+15 < to_days(now())")
                  .like(InterfaceLog::getUrl,"/artemis/api/"));
    }
    @Override
    public    void remainLastLogs(){
          InterfaceLog log = interfaceLogMapper.selectOne(new QueryWrapper<InterfaceLog>()
                  .select("max(id) as id").last("limit 1"));
          //只保留进10w条数据
          if(log!=null) {
              interfaceLogMapper.delete(new UpdateWrapper<InterfaceLog>().lambda()
                      .lt(InterfaceLog::getId, Constants.formatIntegerNum(log.getId()) - 100000));
          }
    }
}