package com.cool.store.dao;

import com.cool.store.dto.partner.PartnerIntentApplyInfoDTO;
import com.cool.store.entity.HyPartnerIntentInfoDO;
import com.cool.store.mapper.HyPartnerIntentInfoMapper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

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

/**
 * @Author suzhuhong
 * @Date 2023/6/9 15:02
 * @Version 1.0
 */
@Repository
public class HyPartnerIntentInfoDAO {


    @Resource
    HyPartnerIntentInfoMapper hyPartnerIntentInfoMapper;

    public  int insertSelective( HyPartnerIntentInfoDO record){
        return hyPartnerIntentInfoMapper.insertSelective(record);
    }

    public  int updateByPrimaryKeySelective(HyPartnerIntentInfoDO record){
        return hyPartnerIntentInfoMapper.updateByPrimaryKeySelective(record);
    }

    public  HyPartnerIntentInfoDO selectByPrimaryKeySelective(Long id){
        if (id==null){
            return null;
        }
        return hyPartnerIntentInfoMapper.selectByPrimaryKeySelective(id);
    }


    public List<PartnerIntentApplyInfoDTO> selectPartnerIntentApplyInfoList(String userId, String workflowStage, String workflowStatus){
        if (StringUtils.isEmpty(userId)){
            return new ArrayList<>();
        }
        return hyPartnerIntentInfoMapper.selectPartnerIntentApplyInfoList(userId,workflowStage,workflowStatus);
    }


    public  HyPartnerIntentInfoDO selectByLineId(Long lineId){
        if (lineId==null){
            return null;
        }
        return hyPartnerIntentInfoMapper.selectByLineId(lineId);
    }

    public  HyPartnerIntentInfoDO getByPartnerIdAndLineId(String partnerId, Long partnerLineId){
        if (StringUtils.isEmpty(partnerId) || Objects.isNull(partnerLineId)){
            return null;
        }
        return hyPartnerIntentInfoMapper.getByPartnerIdAndLineId(partnerId, partnerLineId);
    }

    public  int updateLineId(String newPartnerId,Long newLineId,Long oldLineId){
        if (newLineId==null || Objects.isNull(oldLineId)){
            return 0;
        }
        return hyPartnerIntentInfoMapper.updateLineId(newPartnerId,newLineId, oldLineId);
    }

}
