package com.gyee.runeconomy.controller;


import com.gyee.common.model.StringUtils;
import com.gyee.runeconomy.dto.R;
import com.gyee.runeconomy.dto.ResultMsg;
import com.gyee.runeconomy.model.auto.ProBasicWeatherStation;
import com.gyee.runeconomy.service.TokenService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 气象站名称 前端控制器
 * </p>
 *
 * @author wang
 * @since 2023-04-04
 */
@RestController
@RequestMapping("//weatherstation")
public class ProBasicWeatherStationController {

    @Resource
    private TokenService tokenService;

    @GetMapping("/queryall")
    @ResponseBody
    @ApiOperation(value = "获得测风塔信息", notes = "获得测风塔信息")
    public R queryAll() throws Exception {

        HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
        List<ProBasicWeatherStation> wslist = tokenService.getWeawpls(request);

        if (StringUtils.isNotNull(wslist)) {
            return R.data(ResultMsg.ok(wslist));
        } else {
            return R.error(ResultMsg.error());
        }
    }
}
