package com.gyee.frame.controller.gen;

import com.gyee.frame.common.base.BaseController;
import com.gyee.frame.common.domain.AjaxResult;
import com.gyee.frame.common.spring.InitialRunner;
import com.gyee.frame.model.auto.Project;
import com.gyee.frame.model.auto.Windpowerstation;
import com.gyee.frame.util.StringUtils;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("GyeeMatrixController")
@Api(value = "")
public class GyeeMatrixController extends BaseController{
	

	@GetMapping("/GyeeMatrixList")
	@ResponseBody
	public AjaxResult getMatrixList(String keyid){

		List<Map<String,String>> ls=new ArrayList<>();
		if(StringUtils.isNotNull(keyid))
		{
			if(keyid.equals("0"))
			{

				for(Windpowerstation wp: InitialRunner.wpls)
				{
					Map<String,String> map=new HashMap<>();
					map.put("id",wp.getId());
					map.put("name",wp.getName());
					ls.add(map);
				}
			}else {

				for(Project pj: InitialRunner.pjls)
				{
					Map<String,String> map=new HashMap<>();
					if(pj.getWindpowerstationid().equals(keyid))
					{
						map.put("id",pj.getId());
						map.put("name",pj.getName());
						ls.add(map);
					}
				}
			}
		}

		if(ls.isEmpty()){
			return AjaxResult.error(500, "无法获取权限");
			
		}else{
			return AjaxResult.successData(200, ls);
		}
	}
	

	
}
