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

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.routelight.vo.*;
import com.yc.ship.module.resource.dal.dataobject.routelight.ResourceRouteLightDO;
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.routelight.ResourceRouteLightMapper;

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 ResourceRouteLightServiceImpl implements ResourceRouteLightService {

    @Resource
    private ResourceRouteLightMapper routeLightMapper;

    @Override
    public Long createRouteLight(ResourceRouteLightSaveReqVO createReqVO) {
        // 插入
        ResourceRouteLightDO routeLight = BeanUtils.toBean(createReqVO, ResourceRouteLightDO.class);
        routeLightMapper.insert(routeLight);
        // 返回
        return routeLight.getId();
    }

    @Override
    public void updateRouteLight(ResourceRouteLightSaveReqVO updateReqVO) {
        // 更新
        ResourceRouteLightDO updateObj = BeanUtils.toBean(updateReqVO, ResourceRouteLightDO.class);
        routeLightMapper.updateById(updateObj);
    }

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


    @Override
    public ResourceRouteLightDO getRouteLight(Long id) {
        return routeLightMapper.selectById(id);
    }

    @Override
    public PageResult<ResourceRouteLightDO> getRouteLightPage(ResourceRouteLightPageReqVO pageReqVO) {
        return routeLightMapper.selectPage(pageReqVO);
    }

}