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

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.port.vo.ResourcePortRespVO;
import com.yc.ship.module.resource.dal.dataobject.port.ResourcePortDO;
import com.yc.ship.module.resource.service.port.ResourcePortService;
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/port")
@Validated
public class AppResourcePortController {

    @Resource
    private ResourcePortService portService;

    @GetMapping("/list-simple")
    @Operation(summary = "获得口岸列表（下拉筛选用）")
    public CommonResult<List<ResourcePortRespVO>> getPortListSimple() {
        List<ResourcePortDO> list = portService.enableList();
        return success(BeanUtils.toBean(list, ResourcePortRespVO.class));
    }
}
