package com.cool.store.dao;

import com.cool.store.entity.BuildInformationDO;
import com.cool.store.entity.OrderSysInfoDO;
import com.cool.store.mapper.OrderSysInfoMapper;
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.List;

/**
 * @Author: WangShuo
 * @Date: 2025/04/06/16:03
 * @Version 1.0
 * @注释:
 */
@Repository
public class OrderSysInfoDAO {

    @Resource
    private OrderSysInfoMapper orderSysInfoMapper;

    public Integer insertSelective(OrderSysInfoDO orderSysInfoDO) {
        return orderSysInfoMapper.insertSelective(orderSysInfoDO);
    }

    public OrderSysInfoDO selectByShopId(Long shopId) {
        Example example = new Example(OrderSysInfoDO.class);
        example.createCriteria().andEqualTo("shopId", shopId);
        return orderSysInfoMapper.selectOneByExample(example);
    }

    public Integer updateByShopId(OrderSysInfoDO orderSysInfoDO) {
        Example example = new Example(OrderSysInfoDO.class);
        example.createCriteria().andEqualTo("shopId", orderSysInfoDO.getShopId());
        return orderSysInfoMapper.updateByExampleSelective(orderSysInfoDO, example);
    }

    //只获取特定几个字段值
    public List<OrderSysInfoDO> getSpecificByShopIdList(List<Long> shopIdList) {
        if (CollectionUtils.isEmpty(shopIdList)) {
            return new ArrayList<>();
        }
        return orderSysInfoMapper.getSpecificByShopIdList(shopIdList);
    }

    public Integer updateAddresseeAddress(OrderSysInfoDO orderSysInfoDO) {
        return orderSysInfoMapper.updateAddresseeAddress(orderSysInfoDO);
    }

    public List<OrderSysInfoDO> selectByShopIdList(List<Long> shopIdList) {
        if (CollectionUtils.isEmpty(shopIdList)) {
            return new ArrayList<>();
        }
        Example example = new Example(OrderSysInfoDO.class);
        example.createCriteria().andIn("shopId", shopIdList);
        return orderSysInfoMapper.selectByExample(example);
    }

    /**
     * @Auther: wangshuo
     * @Date: 2025/5/12
     * @description:数据处理专用插入特定字段
     */
    public Integer batchInsertSpecific(List<OrderSysInfoDO> orderSysInfoDOList) {
        if (CollectionUtils.isEmpty(orderSysInfoDOList)) {
            return 0;
        }
        return orderSysInfoMapper.batchInsertSpecific(orderSysInfoDOList);
    }
    /**
     * @Auther: wangshuo
     * @Date: 2025/5/12
     * @description:数据处理专用update特定字段
     */
    public Integer batchUpdateSpecific(List<OrderSysInfoDO> orderSysInfoDOList) {
        if (CollectionUtils.isEmpty(orderSysInfoDOList)) {
            return 0;
        }
        return orderSysInfoMapper.batchUpdateSpecific(orderSysInfoDOList);
    }
}
