package com.ruoyi.web.controller.app;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.SysScenic;
import com.ruoyi.system.domain.SysSource;
import com.ruoyi.system.domain.dto.ARSourceDto;
import com.ruoyi.system.domain.dto.Coordinate;
import com.ruoyi.system.domain.dto.ShowSysSourceARListDto;
import com.ruoyi.system.domain.dto.ShowSysSourceListDto;
import com.ruoyi.system.service.ISysSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/app/ar")
public class AppARController extends BaseController {

    @Autowired
    private ISysSourceService sysSourceService;

    @PostMapping("/getSource")
    public String getSource(){
        System.out.println("AR发送数据");
        return "获取消息成功";
    }

    // 发布--获取系统资源位列表, 附带搜索功能
    @PostMapping("/getAllSource")
    public AjaxResult getAllSource(@RequestBody ARSourceDto sysSource) {

//        SysSource sysSource_1 = new SysSource();

        System.out.println("AR发送数据: "+sysSource.getCity()+sysSource.getScenic());
        List<Coordinate> coordinates = sysSource.getCoordinates();
//        for (Coordinate coordinate : coordinates) {
//            System.out.println("坐标: "+coordinate.getX()+coordinate.getY());
//        }


        List<ShowSysSourceARListDto> showSysSourceList = sysSourceService.getARSource(sysSource.getCity(),  sysSource.getScenic(), coordinates);

//        List<ShowSysSourceARListDto> showSysSourceList = sysSourceService.getSysSourceARList(sysSource);
//
//
        AjaxResult ajaxResult = AjaxResult.success();

        ajaxResult.put("sourceList", showSysSourceList);

        return ajaxResult;

//        return success();
    }
    @PostMapping("/getPeople")
    public String getAR(){
        return "{ source_id:111111,city:济南,scenic:泉城广场,part:A,coordinate:0101,work_address:https://iknow-pic.cdn.bcebos.com/37d12f2eb9389b507e7594cf9735e5dde6116ea0}";
    }

}
