package com.gyee.wisdom.alarm.sharding.controller;

import com.gyee.wisdom.alarm.sharding.entity.Equipmentmodel;
import com.gyee.wisdom.alarm.sharding.entity.WindPowerStation;
import com.gyee.wisdom.alarm.sharding.service.EquipmentmodelService;
import com.gyee.wisdom.alarm.sharding.service.WindpowerstationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 风机接口
 */
@Slf4j
@RestController
@RequestMapping("/windpowerstation")
@CrossOrigin
public class WindpowerstationController {
    @Autowired
    private WindpowerstationService windpowerstationService;

    @Autowired
    private EquipmentmodelService equipmentmodelService;

    @GetMapping()
    public WindPowerStation getAllWindPowerStation(@RequestParam(value = "id", required = false) String id) {
        if(id.isEmpty()){
            List<Equipmentmodel> equipmentmodels =  equipmentmodelService.getAllEquipmentmodel();
            WindPowerStation windPowerStation = new WindPowerStation();
            windPowerStation.setEquipmentmodel(equipmentmodels);
            return windPowerStation;
        }
        return windpowerstationService.getAllWindPowerStation(id);
    }
}
