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.PropertyDirectReductionDetail;
import com.yuchen.saas.park.service.mapper.property.PropertyDirectReductionDetailMapper;
import com.yuchen.saas.park.service.service.property.IPropertyDirectReductionDetailService;
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 PropertyDirectReductionDetailServiceImpl extends BaseServiceImpl<PropertyDirectReductionDetailMapper, PropertyDirectReductionDetail> implements IPropertyDirectReductionDetailService {

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

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

    @Override
    public List<PropertyDirectReductionDetail> listByQuery(Long feeStandardId, Long feeItemId) {
        LambdaQueryWrapper<PropertyDirectReductionDetail> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(Func.isNotEmpty(feeStandardId),PropertyDirectReductionDetail::getFeeStandardId,feeStandardId)
                .eq(Func.isNotEmpty(feeItemId),PropertyDirectReductionDetail::getFeeItemId,feeItemId);
        return list(queryWrapper);
    }

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