package com.cool.store.dao;

import com.cool.store.entity.MemberQuestionDO;
import com.cool.store.entity.QualificationsInfoDO;
import com.cool.store.mapper.QualificationsInfoMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

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

/**
 * @Author suzhuhong
 * @Date 2024/6/21 15:26
 * @Version 1.0
 */
@Repository
public class QualificationsInfoDAO {

    @Resource
    private QualificationsInfoMapper qualificationsInfoMapper;


    /**
     * 新增与更新
     * @param request
     * @return
     */
    public boolean insertOrUpdate(QualificationsInfoDO request){
       return qualificationsInfoMapper.insertOrUpdate(request);
    }

    public void updateAuditIdByLineId(Long auditId, Long id){
        if (id==null||auditId==null){
            return;
        }
        qualificationsInfoMapper.updateAuditIdByLineId(auditId, id);
    }

    public QualificationsInfoDO getByLineId(@Param("lineId") Long lineId){
        if (lineId==null){
            return new QualificationsInfoDO();
        }
        return qualificationsInfoMapper.getByLineId(lineId);
    }
    public List<QualificationsInfoDO> getByLineIds( List<Long> lineIds){
        if (lineIds==null|| lineIds.isEmpty()){
            return new java.util.ArrayList<>();
        }
        Example example = new Example(QualificationsInfoDO.class);
        example.createCriteria().andIn("lineId", lineIds);
        return qualificationsInfoMapper.selectByExample(example);
    }

    public List<QualificationsInfoDO> getByPartnerIds( List<String> partnerIds){
        if (partnerIds.isEmpty()){
            return new java.util.ArrayList<>();
        }
        Example example = new Example(QualificationsInfoDO.class);
        example.createCriteria().andIn("partnerId", partnerIds);
        return qualificationsInfoMapper.selectByExample(example);
    }
}
