package com.cool.store.dao;

import com.cool.store.constants.CommonConstants;
import com.cool.store.entity.ShopRentInfoDO;
import com.cool.store.mapper.ShopRentInfoMapper;
import com.cool.store.vo.point.ShopRentInfoVO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;

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

/**
 * @author zhangchenbiao
 * @FileName: ShopRentInfoDAO
 * @Description:
 * @date 2024-04-16 11:34
 */
@Repository
public class ShopRentInfoDAO {

    @Resource
    private ShopRentInfoMapper shopRentInfoMapper;

    public Long addShopRentInfo(ShopRentInfoDO shopRentInfo) {
        shopRentInfoMapper.insertSelective(shopRentInfo);
        return shopRentInfo.getId();
    }

    public ShopRentInfoDO getRentContractByShopId(Long shopId) {
        if(Objects.isNull(shopId)){
            return null;
        }
        return shopRentInfoMapper.getRentContractByShopId(shopId);
    }

    public Integer updateRentContract(ShopRentInfoDO shopRentInfo) {
        if(Objects.isNull(shopRentInfo.getId())){
            return CommonConstants.ZERO;
        }
        return shopRentInfoMapper.updateByPrimaryKeySelective(shopRentInfo);
    }

    public Integer deleteRentContractByShopId(Long shopId) {
        if(Objects.isNull(shopId)){
            return CommonConstants.ZERO;
        }
        return shopRentInfoMapper.deleteRentContractByShopId(shopId);
    }

    public List<ShopRentInfoDO> getRentContractByShopIds(List<Long> shopIds) {
        if(CollectionUtils.isEmpty(shopIds)){
            return null;
        }
        return shopRentInfoMapper.getRentContractByShopIds(shopIds);
    }
}
