package com.aidex.web.controller.app;


import com.aidex.common.app.domain.vo.LocationVO;
import com.aidex.common.app.domain.vo.SysWharfVO;
import com.aidex.common.app.server.IAppService;
import com.aidex.common.core.domain.R;
import com.aidex.common.gps.domain.LocationEntity;
import com.aidex.system.domain.SysNotice;
import com.aidex.system.domain.SysWharf;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/app")
@Tag(name = "小程序相关接口", description = "小程序管调用接口")
public class AppController {


    @Autowired
    private IAppService iAppService;

    @GetMapping("/carousel")
    @ApiOperation(value = "获取轮播信息", notes = "获取轮播信息", produces = "application/json")
    public R<List<SysNotice>> carousel()
    {
        return R.data(iAppService.getCarouselList());
    }

    @GetMapping("/notice")
    @ApiOperation(value = "获取通知公告", notes = "获取通知公告", produces = "application/json")
    public R<List<SysNotice>> notice()
    {
        return R.data(iAppService.getNoticeList());
    }

    @GetMapping("/noticeAndCarouseldetails/{id}")
    @ApiOperation(value = "获取轮播或公告详情", notes = "获取轮播或公告详情", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "数据主键ID", required = true, dataType = "String", paramType = "query")})
    public R<SysNotice> noticeAndCarouseldetails(@PathVariable("id") String id)
    {
        return R.data(iAppService.findCarouselAndNoticeDetails(id));
    }

    @GetMapping("/wharf")
    @ApiOperation(value = "获取全部站点列表", notes = "获取全部站点列表", produces = "application/json")
    public R<List<SysWharf>> findSysWharfList()
    {
        return R.data(iAppService.findSysWharfList());
    }

    @GetMapping("/location")
    @ApiOperation(value = "获取全部船只位置", notes = "获取全部船只位置", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "direction", value = "正向（TRUE）/反向（FALSE）、默认正向", required = true, dataType = "Boolean", paramType = "query")})
    public R<List<LocationVO>> getLocationAll(@RequestParam(defaultValue = "true", name = "direction") Boolean direction)
    {
        return R.data(iAppService.findAllLocation(direction));
    }

    @GetMapping("/wharf/my")
    @ApiOperation(value = "获取离我最近的站点及距离", notes = "获取离我最近的站点及距离", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lat", value = "纬度", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "lon", value = "经度", required = true, dataType = "String", paramType = "query")})
    public R<List<SysWharfVO>> getWharfMy(@RequestParam(defaultValue = "",name = "lat") String lat, @RequestParam(defaultValue = "",name = "lon") String lon )
    {
        return R.data(iAppService.findNearestStation(lat,lon));
    }
}
