package com.cool.store.dao;

import com.cool.store.entity.DecorationDesignInfoDO;
import com.cool.store.mapper.DecorationDesignInfoMapper;
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 suzhuhong
 * @Date 2024/6/20 17:23
 * @Version 1.0
 */
@Repository
public class DecorationDesignInfoDAO {

    @Resource
    DecorationDesignInfoMapper decorationDesignInfoMapper;

    public DecorationDesignInfoDO getById(Long id){
        if(id == null){
            return null;
        }
        return decorationDesignInfoMapper.selectByPrimaryKey(id);
    }
    public List<DecorationDesignInfoDO> getByIds(List<Long> shopIds){
        if(CollectionUtils.isEmpty(shopIds)){
            return new ArrayList<>();
        }
        Example example = new Example(DecorationDesignInfoDO.class);
        example.createCriteria().andIn("shopId", shopIds);
        return decorationDesignInfoMapper.selectByExample(example);
    }

    public Integer insertSelective(DecorationDesignInfoDO decorationDesignInfoDO){
        return decorationDesignInfoMapper.insertSelective(decorationDesignInfoDO);
    }

    public Integer updateByPrimaryKeySelective(DecorationDesignInfoDO decorationDesignInfoDO){
        return decorationDesignInfoMapper.updateByPrimaryKeySelective(decorationDesignInfoDO);
    }

    public DecorationDesignInfoDO getByShopId(Long shopId){
        if(shopId == null){
            return null;
        }
        return decorationDesignInfoMapper.selectByShopId(shopId);
    }




}
