package com.njzscloud.supervisory.order.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.order.mapper.OrderCarInOutMapper;
import com.njzscloud.supervisory.order.pojo.entity.OrderCarInOutEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 订单车辆进出场信息
 */
@Slf4j
@Service
public class OrderCarInOutService extends ServiceImpl<OrderCarInOutMapper, OrderCarInOutEntity> implements IService<OrderCarInOutEntity> {

    /**
     * 新增
     */
    public void add(OrderCarInOutEntity orderCarInOutEntity) {
        this.save(orderCarInOutEntity);
    }

    /**
     * 修改
     */
    public void modify(OrderCarInOutEntity orderCarInOutEntity) {
        this.updateById(orderCarInOutEntity);
    }

    /**
     * 删除
     */
    @Transactional(rollbackFor = Exception.class)
    public void del(List<Long> ids) {
        this.removeBatchByIds(ids);
    }

    /**
     * 详情
     */
    public OrderCarInOutEntity detail(Long id) {
        return this.getById(id);
    }

    /**
     * 分页查询
     */
    public PageResult<OrderCarInOutEntity> paging(PageParam pageParam, OrderCarInOutEntity orderCarInOutEntity) {
        return PageResult.of(this.page(pageParam.toPage(), Wrappers.<OrderCarInOutEntity>query(orderCarInOutEntity)));
    }

}
