package com.cool.store.dao.order;

import com.cool.store.entity.ShopInfoDO;
import com.cool.store.entity.order.StoreWishlistDO;
import com.cool.store.mapper.order.StoreWishlistMapper;
import com.cool.store.vo.order.MiniStoreWishlistListVO;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import java.util.Collections;
import java.util.List;

@Repository
@RequiredArgsConstructor
public class StoreWishlistDAO {

    private final StoreWishlistMapper mapper;

    public boolean insertBatch(List<StoreWishlistDO> list) {
        if (CollectionUtils.isEmpty(list)) {
            return false;
        }
        return mapper.insertBatch(list) > 0;
    }

    public boolean insert(StoreWishlistDO item) {
        if (item == null) {
            return false;
        }
        return mapper.insertSelective(item) > 0;
    }

    public int updateByExampleSelective(StoreWishlistDO item) {
        if (item == null) {
            return 0;
        }
        return mapper.updateByPrimaryKeySelective(item);
    }

    public boolean softDeleteByLineIdAndStoreTypeAndVersion(Long lineId, Long storeTypeId, String versionNo) {
        if (lineId == null || storeTypeId == null || versionNo == null) {
            return false;
        }
        return mapper.softDeleteByLineIdAndStoreTypeAndVersion(lineId, storeTypeId, versionNo) > 0;
    }

    public StoreWishlistDO getById(Long id) {
        if (id == null) {
            return null;
        }
        return mapper.getById(id);
    }

    public StoreWishlistDO getByPointId(Long lineId,Long pointId) {
        if (lineId == null||pointId==null) {
            return null;
        }
        return mapper.getByPointId(lineId,pointId);
    }

    public Boolean updateByLineId(Long id) {
        if (id == null) {
            return null;
        }
        return mapper.updateByLineId(id);
    }

    public Integer getPointBindWishlistCount( Long pointId,  Integer wishlistStatus) {
        if (pointId == null||wishlistStatus==null) {
            return 0;
        }
        return mapper.getPointBindWishlistCount(pointId,wishlistStatus);
    }

    public List<StoreWishlistDO> listByLineIdAndStoreTypeAndVersion(Long lineId, Long storeTypeId, String versionNo) {
        if (lineId == null || storeTypeId == null || versionNo == null) {
            return Collections.emptyList();
        }
        return mapper.listByLineIdAndStoreTypeAndVersion(lineId, storeTypeId, versionNo);
    }

    public List<MiniStoreWishlistListVO> listByLineId(Long lineId, Long storeTypeId,Integer wishlistStatus) {
        if (lineId == null) {
            return Collections.emptyList();
        }
        return mapper.listByLineId(lineId, storeTypeId,wishlistStatus);
    }

    public List<MiniStoreWishlistListVO> listByVersionList(String keyword,Long storeTypeId,Integer wishlistStatus) {
        return mapper.listByVersionList(keyword,storeTypeId,wishlistStatus);
    }

    public Boolean unbindPoint(Long id) {
        if (id == null) {
            return Boolean.FALSE;
        }
        return mapper.unbindPoint(id);
    }
}
