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

import com.xisc.pm.domain.entity.PmSteelCastFlow;
import com.xisc.pm.domain.repository.PmSteelCastFlowRepository;
import com.xisc.pm.infra.mapper.PmSteelCastFlowMapper;
import org.apache.commons.collections.CollectionUtils;
import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.hzero.mybatis.domian.Condition;
import org.hzero.mybatis.util.Sqls;
import org.springframework.stereotype.Component;

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

/**
 * 炼钢连铸制造命令铸机流表(PmSteelCastFlow)资源库
 *
 * @author 纪文桃 wentao.ji01@hand-china.com
 * @since 2024-08-15 11:11:18
 */
@Component
public class PmSteelCastFlowRepositoryImpl extends BaseRepositoryImpl<PmSteelCastFlow> implements PmSteelCastFlowRepository {
    @Resource
    private PmSteelCastFlowMapper pmSteelCastFlowMapper;

    @Override
    public List<PmSteelCastFlow> selectList(PmSteelCastFlow pmSteelCastFlow) {
        return pmSteelCastFlowMapper.selectList(pmSteelCastFlow);
    }

    @Override
    public PmSteelCastFlow selectByPrimary(Long steelCastFlowId) {
        PmSteelCastFlow pmSteelCastFlow = new PmSteelCastFlow();
        pmSteelCastFlow.setSteelCastFlowId(steelCastFlowId);
        List<PmSteelCastFlow> pmSteelCastFlows = pmSteelCastFlowMapper.selectList(pmSteelCastFlow);
        if (CollectionUtils.isEmpty(pmSteelCastFlows)) {
            return null;
        }
        return pmSteelCastFlows.get(0);
    }

    @Override
    public List<PmSteelCastFlow> selectByPonoList(List<String> ponoList, Long tenantId) {
        return this.selectByCondition(Condition.builder(PmSteelCastFlow.class)
                .andWhere(Sqls.custom().andIn(PmSteelCastFlow.FIELD_PONO, ponoList))
                .andWhere(Sqls.custom().andEqualTo(PmSteelCastFlow.FIELD_TENANT_ID, tenantId))
                .build());
    }
}
