package cn.com.ty.lift.business.maintenance.service;

import cn.com.ty.lift.business.maintenance.dao.entity.MtRecordCost;
import cn.com.ty.lift.business.maintenance.dao.mapper.MtRecordCostMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  保养记录收费项 服务实现类
 * </p>
 *
 * @author wcz
 * @since 2020-01-18
 */
@Service
public class MtRecordCostService extends ServiceImpl<MtRecordCostMapper, MtRecordCost> {

    /**
     * 根据维保记录查询收费项
     * @param recordId 维保记录id
     * @return List<MtRecordCost>
     */
    public List<MtRecordCost> listByRecord(Long recordId){
        LambdaQueryWrapper<MtRecordCost> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(MtRecordCost::getMtRecordId,recordId);
        return list(lambdaQueryWrapper);
    }

    /**
     * 根据id和维保记录id查询唯一
     * @param recordId 维保记录id
     * @param id 收费项id
     * @return MtRecordCost
     */
    public boolean removeByRecordAndId(Long recordId,Long id){
        LambdaQueryWrapper<MtRecordCost> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(MtRecordCost::getId,id);
        lambdaQueryWrapper.eq(MtRecordCost::getMtRecordId,recordId);
        return remove(lambdaQueryWrapper);
    }
}
