package com.cy.guoyan.admin.module.ai.dal.mysql.chatsession;

import com.cy.guoyan.admin.framework.common.pojo.PageResult;
import com.cy.guoyan.admin.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cy.guoyan.admin.framework.mybatis.core.mapper.BaseMapperX;
import com.cy.guoyan.admin.module.ai.controller.admin.chatsession.vo.ChatSessionPageReqVO;
import com.cy.guoyan.admin.module.ai.dal.dataobject.chatsession.ChatSessionDO;
import org.apache.ibatis.annotations.Mapper;


/**
 * AI聊天会话 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ChatSessionMapper extends BaseMapperX<ChatSessionDO> {

    default PageResult<ChatSessionDO> selectPage(ChatSessionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ChatSessionDO>()
                .betweenIfPresent(ChatSessionDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(ChatSessionDO::getName, reqVO.getName())
                .eqIfPresent(ChatSessionDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(ChatSessionDO::getLastMessageTime, reqVO.getLastMessageTime())
                .eqIfPresent(ChatSessionDO::getDifyConversationId, reqVO.getDifyConversationId())
                .eqIfPresent(ChatSessionDO::getAppId, reqVO.getAppId())
                .eqIfPresent(ChatSessionDO::getInputsJson, reqVO.getInputsJson())
                .eqIfPresent(ChatSessionDO::getResponseJson, reqVO.getResponseJson())
                .eqIfPresent(ChatSessionDO::getStatus, reqVO.getStatus())
                .orderByDesc(ChatSessionDO::getId));
    }

}