package com.njcn.rdms.module.project.dal.mysql.workreport.common;

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.workreport.common.WorkReportStatusLogDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface WorkReportStatusLogMapper extends BaseMapperX<WorkReportStatusLogDO> {

    default List<WorkReportStatusLogDO> selectListByReport(String reportType, Long reportId) {
        return selectList(new LambdaQueryWrapperX<WorkReportStatusLogDO>()
                .eq(WorkReportStatusLogDO::getReportType, reportType)
                .eq(WorkReportStatusLogDO::getReportId, reportId)
                .orderByDesc(WorkReportStatusLogDO::getCreateTime)
                .orderByDesc(WorkReportStatusLogDO::getId));
    }

    default int deleteByReport(String reportType, Long reportId) {
        return delete(new LambdaQueryWrapperX<WorkReportStatusLogDO>()
                .eq(WorkReportStatusLogDO::getReportType, reportType)
                .eq(WorkReportStatusLogDO::getReportId, reportId));
    }
}
