package com.yh.saas.platform.controller;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alipay.sofa.runtime.api.annotation.SofaReference;
import com.winsea.svc.base.base.entity.CommonVessel;
import com.winsea.svc.base.base.service.ICommonVesselService;
import com.winsea.svc.base.security.util.AuthSecurityUtils;

/**
 * <p>
 * 记录船舶信息 前端控制器
 * </p>
 *
 * @author gdc
 * @since 2019-04-18
 */
@RestController
@RequestMapping("/vessel")
public class VesselController {

	@SofaReference
	private ICommonVesselService vesselInfoService;

	/**
	 * 获取用户拥有的船舶列表
	 * 
	 * @param vesselStatus 船舶状态
	 * @return 船舶列表
	 */
	@GetMapping("/query/getUserVesselListByStatus")
	public List<CommonVessel> getUserVesselListByStatus(
			@RequestParam(name = "vesselStatus", required = false) CommonVessel.VesselStatus vesselStatus) {
		return vesselInfoService.getStaffVessels(AuthSecurityUtils.getCurrentUserInfo().getUserId(), vesselStatus);
	}

	/**
	 * 查询船舶是否购买客户端
	 * 
	 * @param vesselId 船舶id
	 * @return 是否购买
	 * @author ZhangMingYu
	 */
	@GetMapping("/query/findVesselClientFlag")
	public Boolean findVesselClientFlag(String vesselId) {
		return vesselInfoService.findVesselClientFlag(vesselId);
	}

	/**
	 * 查询船舶信息
	 * 
	 * @param vesselId 船舶id
	 * @return 船舶信息
	 * @author Dongah
	 */
	@GetMapping("/query/getVesselInfo")
	public CommonVessel getVesselInfo(String vesselId) {
		return vesselInfoService.getVesselInfo(vesselId);
	}

	/**
	 * 获取租户下所有的船舶
	 * 
	 * @param tenantId
	 * @return
	 */
	@GetMapping("/query/getVesselListByTenantId")
	public List<CommonVessel> getVesselListByTenantId(CommonVessel vessel) {
		return this.vesselInfoService.getVesselListByTenantId(vessel);
	}

//	/**
//	 * 根据所属公司获取船舶信息
//	 * @param underCompId
//	 * @return
//	 */
//	@GetMapping("/query/getVesselListByUnderCompId")
//	public List<CommonVessel> getVesselListByUnderCompId(CommonVessel vessel){
//		return this.vesselInfoService.getVesselListByUnderCompId(vessel);
//	}
}
