package com.cool.store.dao;

import com.cool.store.entity.HyPartnerBaseInfoDO;
import com.cool.store.mapper.HyPartnerBaseInfoMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

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

/**
 * @Author suzhuhong
 * @Date 2023/6/13 20:25
 * @Version 1.0
 */
@Repository
public class HyPartnerBaseInfoDAO {


    @Resource
    HyPartnerBaseInfoMapper hyPartnerBaseInfoMapper;



    public  int insertSelective( HyPartnerBaseInfoDO record){
       return hyPartnerBaseInfoMapper.insertSelective(record);
    }

    public  int batchInsert( List<HyPartnerBaseInfoDO> records){
        if (CollectionUtils.isEmpty(records)){
            return 0;
        }
        return hyPartnerBaseInfoMapper.batchInsert(records);
    }

    public  HyPartnerBaseInfoDO selectById(@Param("id") Long id){
        return hyPartnerBaseInfoMapper.selectById(id);
    }

    /**
     *
     * 默认更新方法，根据主键更新，不会把null值更新到数据库，避免覆盖之前有值的
     * dateTime:2023-05-29 03:51
     */
    public int updateByPrimaryKeySelective(HyPartnerBaseInfoDO record){
        return hyPartnerBaseInfoMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(HyPartnerBaseInfoDO record){
        return hyPartnerBaseInfoMapper.updateByPrimaryKey(record);
    }


    public int updateByPartnerId(String userName,String mobile,String partnerId){
        return hyPartnerBaseInfoMapper.updateByPartnerId(userName,mobile,partnerId);
    }
    public int cleanIdCardInfoByPartnerLineId(String idCard, String idCardPhotoFront,
                                              String idCardPhotoBlack, Long partnerLineId){
        return hyPartnerBaseInfoMapper.cleanIdCardInfoByPartnerLineId(idCard, idCardPhotoFront, idCardPhotoBlack, partnerLineId);
    }


    public HyPartnerBaseInfoDO getByPartnerIdAndLineId(String partnerId, Long partnerLineId){
        if (StringUtils.isEmpty(partnerId) || partnerLineId == null){
            return null;
        }
        return hyPartnerBaseInfoMapper.getByPartnerIdAndLineId(partnerId, partnerLineId);
    }

    public HyPartnerBaseInfoDO getByPartnerLineId(Long partnerLineId){
        if (partnerLineId == null){
            return null;
        }
        return hyPartnerBaseInfoMapper.getByPartnerLineId(partnerLineId);
    }

    public List<HyPartnerBaseInfoDO> getByPartnerLineIds(List<Long> partnerLineId){
        if (CollectionUtils.isEmpty(partnerLineId)){
            return new ArrayList<>();
        }
        return hyPartnerBaseInfoMapper.getByPartnerLineIds(partnerLineId);
    }

    public HyPartnerBaseInfoDO getByIdCard(String idCard){
        if (StringUtils.isEmpty(idCard)){
            return null;
        }
        return hyPartnerBaseInfoMapper.getByIdCard(idCard);
    }
}
