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.api.entity.property.PropertyPayReductionHouse;
import com.yuchen.saas.park.service.mapper.property.PropertyPayReductionHouseMapper;
import com.yuchen.saas.park.service.service.property.IPropertyPayReductionHouseService;
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-22
 */
@Service
public class PropertyPayReductionHouseServiceImpl extends BaseServiceImpl<PropertyPayReductionHouseMapper, PropertyPayReductionHouse> implements IPropertyPayReductionHouseService {

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

    @Override
    public Integer countByPayReductionId(Long payReductionId) {
        LambdaQueryWrapper<PropertyPayReductionHouse> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(PropertyPayReductionHouse::getPayReductionId,payReductionId);
        return count(queryWrapper);
    }

    @Override
    public Boolean removeByPayReductionId(Long payReductionId) {
        LambdaQueryWrapper<PropertyPayReductionHouse> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(PropertyPayReductionHouse::getPayReductionId,payReductionId);
        return remove(queryWrapper);
    }

    @Override
    public List<PropertyPayReductionHouse> listByPayReductionId(Long payReductionId) {
        LambdaQueryWrapper<PropertyPayReductionHouse> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(PropertyPayReductionHouse::getPayReductionId,payReductionId);
        return list(queryWrapper);
    }

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