package com.emr.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.emr.entity.Power_User;
import com.emr.service.PowerUserService;
import com.emr.util.HttpClientUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

@Controller
public class PowerUserController {

    @Autowired
    private PowerUserService powerUserService;

    @RequestMapping("getPowerUserList")
    @ResponseBody
    public Object getPowerUserList(HttpServletRequest request,String type){
        Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
        String handleName = user.getUserPosition();//姓名
        request.setAttribute("handleName",handleName);
        JSONArray powerUserList = powerUserService.getPowerUserList(type);
        if(powerUserList == null){
            return "ERROR";
        }else{
            return powerUserList;
        }
    }
}
