package com.yc.ship.module.resource.controller.app.route;

import com.yc.ship.framework.common.pojo.CommonResult;
import com.yc.ship.framework.common.pojo.PageResult;

import com.yc.ship.framework.common.util.object.BeanUtils;
import com.yc.ship.module.resource.controller.admin.route.vo.ResourceRouteRespVO;
import com.yc.ship.module.resource.controller.admin.ship.vo.ResourceShipRespVO;
import com.yc.ship.module.resource.controller.app.route.vo.AppResourceRoutePageReqVO;
import com.yc.ship.module.resource.controller.app.route.vo.AppResourceRoutePriceVO;
import com.yc.ship.module.resource.controller.app.route.vo.AppResourceRouteRespVO;

import com.yc.ship.module.resource.dal.dataobject.dock.ResourceDockDO;
import com.yc.ship.module.resource.dal.dataobject.route.ResourceRouteDO;
import com.yc.ship.module.resource.dal.dataobject.ship.ResourceShipDO;
import com.yc.ship.module.resource.service.dock.ResourceDockService;
import com.yc.ship.module.resource.service.route.ResourceRouteService;
import com.yc.ship.module.resource.service.ship.ResourceShipService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.util.List;

import static com.yc.ship.framework.common.pojo.CommonResult.success;

@Tag(name = "航线 APP - 航线接口")
@RestController
@RequestMapping("/resource/route")
@Validated
public class AppResourceRouteController {

    @Resource
    private ResourceRouteService routeService;
    @PostMapping("/page")
    @Operation(summary = "获得航线分页列表")
    public CommonResult<PageResult<AppResourceRouteRespVO>> getRoutePage(@RequestBody @Valid AppResourceRoutePageReqVO pageReqVO) {
        PageResult<AppResourceRouteRespVO> pageResult = routeService.getAppRoutePage(pageReqVO);
        return success(pageResult);
    }

    @GetMapping("/detail")
    @Operation(summary = "获得航线详情")
    public CommonResult<AppResourceRouteRespVO> getRouteDetail(@RequestParam("routeId") Long routeId) {
        ResourceRouteDO route = routeService.getRoute(routeId);
        return success(BeanUtils.toBean(route, AppResourceRouteRespVO.class));
    }

    @GetMapping("/simple-list")
    @Operation(summary = "获得航线列表(下拉筛选用)")
    public CommonResult<List<ResourceRouteRespVO>> getRouteList() {
        List<ResourceRouteDO> list = routeService.getEnableRouteList();
        return success(BeanUtils.toBean(list, ResourceRouteRespVO.class));
    }
}
