package com.cool.store.dao;

import com.cool.store.entity.BuildInformationDO;
import com.cool.store.mapper.BuildInformationMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

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

/**
 * @Author: WangShuo
 * @Date: 2024/10/09/下午2:18
 * @Version 1.0
 * @注释:
 */
@Repository
public class BuildInformationDAO {
    @Resource
    private BuildInformationMapper buildInformationMapper;

    public Integer insertSelective(BuildInformationDO buildInformationDO) {
        if (buildInformationDO == null) {
            return 0;
        }
        return buildInformationMapper.insertSelective(buildInformationDO);
    }

    public Integer updateByShopIdSelective(BuildInformationDO buildInformationDO) {
        if (buildInformationDO == null) {
            return 0;
        }
        Example example = new Example(BuildInformationDO.class);
        example.createCriteria().andEqualTo("shopId", buildInformationDO.getShopId());
        return buildInformationMapper.updateByExampleSelective(buildInformationDO,example);
    }
    public BuildInformationDO selectOneByShopId(Long shopId) {
        Example example = new Example(BuildInformationDO.class);
        example.createCriteria().andEqualTo("shopId",shopId);
        return buildInformationMapper.selectOneByExample(example);
    }

    /**
     * @Auther: wangshuo
     * @Date: 2025/4/28
     * @description: 获取小程序店铺名称 导出用
     */
    public List<BuildInformationDO> getSpecificByShopIdList(List<Long> shopIdList) {
        if (CollectionUtils.isEmpty(shopIdList)) {
            return Collections.emptyList();
        }
      return buildInformationMapper.getSpecificByShopIdList(shopIdList);
    }
    /**
     * @Auther: wangshuo
     * @Date: 2025/5/12
     * @description:数据处理用初始化 批量插入新数据
     */
    public Integer batchInsertSpecific(List<Long> shopIds) {
        if (CollectionUtils.isEmpty(shopIds)) {
            return 0;
        }
        return buildInformationMapper.batchInsertSpecific(shopIds);
    }


}
