package com.yuchen.saas.park.service.service.property.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yuchen.saas.park.api.entity.property.PropertyDirectReductionHouse;
import com.yuchen.saas.park.service.mapper.property.PropertyDirectReductionHouseMapper;
import com.yuchen.saas.park.service.service.property.IPropertyDirectReductionHouseService;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.nest.springwrap.core.tool.utils.Func;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 减免活动-直接减免-范围 服务实现类
 * </p>
 *
 * @author cxj
 * @since 2023-12-19
 */
@Service
public class PropertyDirectReductionHouseServiceImpl extends BaseServiceImpl<PropertyDirectReductionHouseMapper, PropertyDirectReductionHouse> implements IPropertyDirectReductionHouseService {

    @Override
    public List<PropertyDirectReductionHouse> listByDirectReductionId(Long directReductionId) {
        LambdaQueryWrapper<PropertyDirectReductionHouse> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(PropertyDirectReductionHouse::getDirectReductionId,directReductionId);
        return list(queryWrapper);
    }

    @Override
    public Integer countByDirectReductionId(Long directReductionId) {
        LambdaQueryWrapper<PropertyDirectReductionHouse> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(PropertyDirectReductionHouse::getDirectReductionId,directReductionId);
        return count(queryWrapper);
    }

    @Override
    public List<PropertyDirectReductionHouse> listByQuery(Long buildingId, Long houseId) {
        LambdaQueryWrapper<PropertyDirectReductionHouse> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(Func.isNotEmpty(buildingId),PropertyDirectReductionHouse::getBuildingId,buildingId)
                .eq(Func.isNotEmpty(houseId),PropertyDirectReductionHouse::getHouseId,houseId);
        return list(queryWrapper);
    }

    @Override
    public Boolean removeByDirectReductionId(Long directReductionId) {
        LambdaQueryWrapper<PropertyDirectReductionHouse> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(PropertyDirectReductionHouse::getDirectReductionId,directReductionId);
        return remove(queryWrapper);
    }

    @Override
    public List<PropertyDirectReductionHouse> listByHouseId(Long houseId) {
        LambdaQueryWrapper<PropertyDirectReductionHouse> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(PropertyDirectReductionHouse::getHouseId,houseId);
        return list(queryWrapper);
    }
}
