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

import com.yc.ship.framework.common.pojo.CommonResult;
import com.yc.ship.framework.common.util.object.BeanUtils;
import com.yc.ship.module.resource.controller.admin.ship.vo.ResourceShipRespVO;
import com.yc.ship.module.resource.controller.app.ship.vo.AppResourceShipRespVO;
import com.yc.ship.module.resource.dal.dataobject.ship.ResourceShipDO;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

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

@Tag(name = "游轮 APP - 游轮接口")
@RestController
@RequestMapping("/resource/ship")
@Validated
public class AppResourceShipController {

    @Resource
    private ResourceShipService shipService;

    @GetMapping("/list-simple")
    @Operation(summary = "获取游轮列表（下拉筛选用）")
    public CommonResult<List<AppResourceShipRespVO>> getShipListSimple() {
        List<ResourceShipDO> list = shipService.getListSimple();
        return success(BeanUtils.toBean(list, AppResourceShipRespVO.class));
    }

    @GetMapping("/detail")
    @Operation(summary = "获取游轮详情")
    public CommonResult<AppResourceShipRespVO> getShipDetail(Long id) {
        ResourceShipDO ship = shipService.getShip(id);
        return success(BeanUtils.toBean(ship, AppResourceShipRespVO.class));
    }

}
