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

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.routecost.vo.*;
import com.yc.ship.module.resource.dal.dataobject.routecost.ResourceRouteCostDO;
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.routecost.ResourceRouteCostMapper;

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 ResourceRouteCostServiceImpl implements ResourceRouteCostService {

    @Resource
    private ResourceRouteCostMapper routeCostMapper;

    @Override
    public Long createRouteCost(ResourceRouteCostSaveReqVO createReqVO) {
        // 插入
        ResourceRouteCostDO routeCost = BeanUtils.toBean(createReqVO, ResourceRouteCostDO.class);
        routeCostMapper.insert(routeCost);
        // 返回
        return routeCost.getId();
    }

    @Override
    public void updateRouteCost(ResourceRouteCostSaveReqVO updateReqVO) {
        // 更新
        ResourceRouteCostDO updateObj = BeanUtils.toBean(updateReqVO, ResourceRouteCostDO.class);
        routeCostMapper.updateById(updateObj);
    }

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



    @Override
    public ResourceRouteCostDO getRouteCost(Long id) {
        return routeCostMapper.selectById(id);
    }

    @Override
    public PageResult<ResourceRouteCostDO> getRouteCostPage(ResourceRouteCostPageReqVO pageReqVO) {
        return routeCostMapper.selectPage(pageReqVO);
    }

}