package com.njcn.rdms.module.project.dal.mysql.project.execution;

import com.njcn.rdms.framework.mybatis.core.dataobject.BaseDO;
import com.njcn.rdms.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.rdms.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.njcn.rdms.module.project.dal.dataobject.project.execution.ProjectExecutionStatusLogDO;
import org.apache.ibatis.annotations.Mapper;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ProjectExecutionStatusLogMapper extends BaseMapperX<ProjectExecutionStatusLogDO> {

    default List<ProjectExecutionStatusLogDO> selectListByExecutionId(Long executionId, String actionType,
                                                                      LocalDateTime[] operateTime) {
        return selectList(new LambdaQueryWrapperX<ProjectExecutionStatusLogDO>()
                .eq(ProjectExecutionStatusLogDO::getExecutionId, executionId)
                .eqIfPresent(ProjectExecutionStatusLogDO::getActionType, actionType)
                .betweenIfPresent(BaseDO::getCreateTime, operateTime)
                .orderByDesc(BaseDO::getCreateTime)
                .orderByDesc(ProjectExecutionStatusLogDO::getId));
    }

}
