package com.bonus.material.lease.service.impl;

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.material.lease.mapper.LeaseUserBookMapper;
import com.bonus.material.lease.domain.LeaseUserBook;
import com.bonus.material.lease.service.ILeaseUserBookService;

/**
 * 预约车Service业务层处理
 * 
 * @author xsheng
 * @date 2024-10-16
 */
@Service
public class LeaseUserBookServiceImpl implements ILeaseUserBookService {
    @Autowired
    private LeaseUserBookMapper leaseUserBookMapper;

    /**
     * 查询预约车
     * 
     * @param id 预约车主键
     * @return 预约车
     */
    @Override
    public LeaseUserBook selectLeaseUserBookById(Long id) {
        return leaseUserBookMapper.selectLeaseUserBookById(id);
    }

    /**
     * 查询预约车列表
     * 
     * @param leaseUserBook 预约车
     * @return 预约车
     */
    @Override
    public List<LeaseUserBook> selectLeaseUserBookList(LeaseUserBook leaseUserBook) {
        return leaseUserBookMapper.selectLeaseUserBookList(leaseUserBook);
    }

    /**
     * 新增预约车
     * 
     * @param leaseUserBook 预约车
     * @return 结果
     */
    @Override
    public int insertLeaseUserBook(LeaseUserBook leaseUserBook) {
        leaseUserBook.setCreateTime(DateUtils.getNowDate());
        try {
            return leaseUserBookMapper.insertLeaseUserBook(leaseUserBook);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改预约车
     * 
     * @param leaseUserBook 预约车
     * @return 结果
     */
    @Override
    public int updateLeaseUserBook(LeaseUserBook leaseUserBook) {
        leaseUserBook.setUpdateTime(DateUtils.getNowDate());
        try {
            return leaseUserBookMapper.updateLeaseUserBook(leaseUserBook);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除预约车
     * 
     * @param ids 需要删除的预约车主键
     * @return 结果
     */
    @Override
    public int deleteLeaseUserBookByIds(Long[] ids) {
        return leaseUserBookMapper.deleteLeaseUserBookByIds(ids);
    }

    /**
     * 删除预约车信息
     * 
     * @param id 预约车主键
     * @return 结果
     */
    @Override
    public int deleteLeaseUserBookById(Long id) {
        return leaseUserBookMapper.deleteLeaseUserBookById(id);
    }
}
