package com.casic.missiles.modular.system.controller;

import com.casic.missiles.core.application.context.AbstractPermissionContext;
import com.casic.missiles.core.base.controller.BaseController;
import com.casic.missiles.core.datascope.DataScope;
import com.casic.missiles.model.response.ResponseData;
import com.casic.missiles.modular.system.model.DeviceMapVO;
import com.casic.missiles.modular.system.model.DeviceValueMapVO;
import com.casic.missiles.modular.system.service.BusMapOverviewGisService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/overviewGis")
@RequiredArgsConstructor
public class BusMapOverviewGisController extends BaseController {

    private final BusMapOverviewGisService busMapOverviewGisService;
    private final AbstractPermissionContext permissionService;

    /*
     * 获取列表
     */
    @RequestMapping(value = "/deviceList")
    public Object deviceList(@RequestParam(required = false) String keywords,
                             @RequestParam(required = false) String deviceType) {
        DataScope dataScope = permissionService.getAuthService().getLoginUserDataScope();
        List<DeviceMapVO> mapList = busMapOverviewGisService.deviceList(dataScope,deviceType, keywords);
        return ResponseData.success(mapList);
    }

    /*
     * 获取列表
     */
    @RequestMapping(value = "/deviceValue")
    public Object deviceValue(@RequestParam(required = true) String code) {
        DeviceValueMapVO deviceValue = busMapOverviewGisService.deviceValue(code);

        return ResponseData.success(deviceValue);
    }


}
