
package com.lideeyunji.core.framework.mapper;

import com.lideeyunji.core.framework.entity.LogRequestApiEntity;
import com.baomidou.dynamic.datasource.annotation.Slave;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 请求日志，单独库
 */
@Slave
public interface LogApiMapper extends BaseMapper<LogRequestApiEntity> {

    //清除某一个日期前的api请求日志
    default Integer clearApiLog(Date clearDate){
        LambdaQueryWrapper<LogRequestApiEntity> wrapper=new LambdaQueryWrapper<>();
        wrapper.le(LogRequestApiEntity::getCreateTime,clearDate);
        return this.delete(wrapper);
    }

    // 统计模块使用记录
    List<Map<String, Object>> countModelUsageRecords(Date begin, Date end);
}
