package com.njzscloud.dispose.cst.order.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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.dispose.cst.order.mapper.OrderCargoPlaceMapper;
import com.njzscloud.dispose.cst.order.pojo.entity.OrderCargoPlaceEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 装/卸货地信息
 *
 * @author ljw
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class OrderCargoPlaceService extends ServiceImpl<OrderCargoPlaceMapper, OrderCargoPlaceEntity> {

    @Transactional(rollbackFor = Exception.class)
    public void add(OrderCargoPlaceEntity orderCargoPlaceEntity) {
        this.save(orderCargoPlaceEntity);
    }

    @Transactional(rollbackFor = Exception.class)
    public void modify(OrderCargoPlaceEntity orderCargoPlaceEntity) {
        this.updateById(orderCargoPlaceEntity);
    }

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

    public OrderCargoPlaceEntity detail(Long id) {
        return this.getById(id);
    }

    public PageResult<OrderCargoPlaceEntity> paging(PageParam pageParam, OrderCargoPlaceEntity orderCargoPlaceEntity) {
        return PageResult.of(this.page(pageParam.toPage(), Wrappers.query(orderCargoPlaceEntity)));
    }
}


