package com.yolo.keyboard.dal.mysql.usercalllog;

import java.util.*;

import com.yolo.keyboard.framework.common.pojo.PageResult;
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yolo.keyboard.framework.mybatis.core.mapper.BaseMapperX;
import com.yolo.keyboard.dal.dataobject.usercalllog.KeyboardUserCallLogDO;
import org.apache.ibatis.annotations.Mapper;
import com.yolo.keyboard.controller.admin.usercalllog.vo.*;

/**
 * 用户每次调用日志（用于记录token、模型、耗时、成功率等） Mapper
 *
 * @author Ziin
 */
@Mapper
public interface KeyboardUserCallLogMapper extends BaseMapperX<KeyboardUserCallLogDO> {

    default PageResult<KeyboardUserCallLogDO> selectPage(KeyboardUserCallLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardUserCallLogDO>()
                .eqIfPresent(KeyboardUserCallLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(KeyboardUserCallLogDO::getRequestId, reqVO.getRequestId())
                .eqIfPresent(KeyboardUserCallLogDO::getFeature, reqVO.getFeature())
                .eqIfPresent(KeyboardUserCallLogDO::getModel, reqVO.getModel())
                .eqIfPresent(KeyboardUserCallLogDO::getInputTokens, reqVO.getInputTokens())
                .eqIfPresent(KeyboardUserCallLogDO::getOutputTokens, reqVO.getOutputTokens())
                .eqIfPresent(KeyboardUserCallLogDO::getTotalTokens, reqVO.getTotalTokens())
                .eqIfPresent(KeyboardUserCallLogDO::getSuccess, reqVO.getSuccess())
                .eqIfPresent(KeyboardUserCallLogDO::getLatencyMs, reqVO.getLatencyMs())
                .eqIfPresent(KeyboardUserCallLogDO::getErrorCode, reqVO.getErrorCode())
                .eqIfPresent(KeyboardUserCallLogDO::getCreatedAt, reqVO.getCreatedAt())
                .eqIfPresent(KeyboardUserCallLogDO::getGenId, reqVO.getGenId())
                .orderByDesc(KeyboardUserCallLogDO::getId));
    }

}