package com.gyee.wisdom.dataadapter.controller.thing;


import com.gyee.wisdom.common.utils.StringUtil;
import com.gyee.wisdom.dataadapter.dto.ElectricalDto;
import com.gyee.wisdom.dataadapter.domain.thing.ElectricalTestingPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

@RestController
@RequestMapping("/electrical")
@CrossOrigin
public class ElectricalTestingPointController {
    @Autowired
    protected ElectricalTestingPointService electricalTestingPointService;


    @GetMapping("/electricaltestingpoint")
    public List<ElectricalDto> getElectricalTestingPoint(
//            @RequestParam(value = "pagenum",required = true) Integer pageNum,
//            @RequestParam(value = "pagesize",required = true) Integer pageSize,
            @RequestParam(value = "windpowerstationid", required = true) String windpowerstationid,
            @RequestParam(value = "name", required = false) String name,
            @RequestParam(value = "uniformcode", required = false) String uniformcode,
            @RequestParam(value = "type", required = false) String type
    ) {
        List<ElectricalDto> list = new ArrayList<>();
        if (StringUtil.isBlank(type)){
            list = electricalTestingPointService.getElectricalDtoAI(uniformcode, name, windpowerstationid);
            List<ElectricalDto> list2 = electricalTestingPointService.getElectricalDtoDI(uniformcode, name, windpowerstationid);
            list.addAll(list2);
        }
       else if (type.equals("AI")){
           list = electricalTestingPointService.getElectricalDtoAI(uniformcode, name, windpowerstationid);
        }
       else if(type.equals("DI")){
           list = electricalTestingPointService.getElectricalDtoDI(uniformcode, name, windpowerstationid);

        }
       else{

        }

        return list;

    }

}
