package com.xisc.pm.infra.repository.impl;

import com.xisc.pm.api.dto.PmSubLogRequestDTO;
import org.apache.commons.collections.CollectionUtils;
import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.springframework.stereotype.Component;
import com.xisc.pm.domain.entity.PmSubLog;
import com.xisc.pm.domain.repository.PmSubLogRepository;
import com.xisc.pm.infra.mapper.PmSubLogMapper;

import javax.annotation.Resource;
import java.util.List;

/**
 * 自动替代日志表(PmSubLog)资源库
 *
 * @author BKGY
 * @since 2024-12-26 15:08:28
 */
@Component
public class PmSubLogRepositoryImpl extends BaseRepositoryImpl<PmSubLog> implements PmSubLogRepository {
    @Resource
    private PmSubLogMapper pmSubLogMapper;

    @Override
    public List<PmSubLog> selectList(PmSubLogRequestDTO pmSubLogRequestDTO) {
        return pmSubLogMapper.selectList(pmSubLogRequestDTO);
    }

    @Override
    public PmSubLog selectByPrimary(Long id) {
        PmSubLogRequestDTO pmSubLog = new PmSubLogRequestDTO();
        pmSubLog.setId(id);
        List<PmSubLog> pmSubLogs = pmSubLogMapper.selectList(pmSubLog);
        if (CollectionUtils.isEmpty(pmSubLogs)) {
            return null;
        }
        return pmSubLogs.get(0);
    }

}

