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

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import com.yc.ship.module.resource.controller.admin.routetrip.vo.*;
import com.yc.ship.module.resource.dal.dataobject.routetrip.ResourceRouteTripDO;
import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.common.util.object.BeanUtils;

import com.yc.ship.module.resource.dal.mysql.routetrip.ResourceRouteTripMapper;


/**
 * 资源管理-航线行程 Service 实现类
 *
 * @author 管理员
 */
@Service
@Validated
public class ResourceRouteTripServiceImpl implements ResourceRouteTripService {

    @Resource
    private ResourceRouteTripMapper routeTripMapper;

    @Override
    public Long createRouteTrip(ResourceRouteTripSaveReqVO createReqVO) {
        // 插入
        ResourceRouteTripDO routeTrip = BeanUtils.toBean(createReqVO, ResourceRouteTripDO.class);
        routeTripMapper.insert(routeTrip);
        // 返回
        return routeTrip.getId();
    }

    @Override
    public void updateRouteTrip(ResourceRouteTripSaveReqVO updateReqVO) {
        // 更新
        ResourceRouteTripDO updateObj = BeanUtils.toBean(updateReqVO, ResourceRouteTripDO.class);
        routeTripMapper.updateById(updateObj);
    }

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


    @Override
    public ResourceRouteTripDO getRouteTrip(Long id) {
        return routeTripMapper.selectById(id);
    }

    @Override
    public PageResult<ResourceRouteTripDO> getRouteTripPage(ResourceRouteTripPageReqVO pageReqVO) {
        return routeTripMapper.selectPage(pageReqVO);
    }

}