package com.yc.ship.module.resource.service.routetripdetail;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;
import com.yc.ship.module.resource.controller.admin.routetripdetail.vo.*;
import com.yc.ship.module.resource.dal.dataobject.routetripdetail.ResourceRouteTripDetailDO;
import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.common.pojo.PageParam;
import com.yc.ship.framework.common.util.object.BeanUtils;

import com.yc.ship.module.resource.dal.mysql.routetripdetail.ResourceRouteTripDetailMapper;

import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.yc.ship.module.resource.enums.ErrorCodeConstants.*;

/**
 * 资源管理-航线行程详细 Service 实现类
 *
 * @author 管理员
 */
@Service
@Validated
public class ResourceRouteTripDetailServiceImpl implements ResourceRouteTripDetailService {

    @Resource
    private ResourceRouteTripDetailMapper routeTripDetailMapper;

    @Override
    public Long createRouteTripDetail(ResourceRouteTripDetailSaveReqVO createReqVO) {
        // 插入
        ResourceRouteTripDetailDO routeTripDetail = BeanUtils.toBean(createReqVO, ResourceRouteTripDetailDO.class);
        routeTripDetailMapper.insert(routeTripDetail);
        // 返回
        return routeTripDetail.getId();
    }

    @Override
    public void updateRouteTripDetail(ResourceRouteTripDetailSaveReqVO updateReqVO) {
        // 更新
        ResourceRouteTripDetailDO updateObj = BeanUtils.toBean(updateReqVO, ResourceRouteTripDetailDO.class);
        routeTripDetailMapper.updateById(updateObj);
    }

    @Override
    public void deleteRouteTripDetail(Long id) {
        // 删除
        routeTripDetailMapper.deleteById(id);
    }


    @Override
    public ResourceRouteTripDetailDO getRouteTripDetail(Long id) {
        return routeTripDetailMapper.selectById(id);
    }

    @Override
    public PageResult<ResourceRouteTripDetailDO> getRouteTripDetailPage(ResourceRouteTripDetailPageReqVO pageReqVO) {
        return routeTripDetailMapper.selectPage(pageReqVO);
    }

}