package api;
|
|
|
import bean.TerminalEntity;
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
|
import javax.swing.*;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
|
public class APIUtils {
|
|
public static List<TerminalEntity> initTerminalList() {
|
Map result = PostUtils.postWithToken("", Constant.GET_TERMINAL_LIST);
|
|
Map data = (Map) result.get("list");
|
|
JSONArray objs = (JSONArray) data.get("list");
|
|
List<TerminalEntity> terminalList = new ArrayList<>();
|
|
for (Object obj :objs) {
|
terminalList.add(JSON.parseObject(JSON.toJSONString(obj),TerminalEntity.class));
|
}
|
return terminalList;
|
}
|
|
|
public static Map login(String loginCode) {
|
Map map = new HashMap();
|
map.put("loginCode", loginCode);
|
Map result = PostUtils.post(JSON.toJSONString(map),Constant.LOGIN);
|
return result;
|
}
|
|
public static boolean changeVol(List<Integer> ids, int value) {
|
Map map = new HashMap();
|
map.put("deviceIds", ids);
|
map.put("vol", value);
|
Map result = PostUtils.postWithToken(JSON.toJSONString(map),Constant.CHANGE_VOL);
|
if(result.get("code").equals("0")){
|
return true;
|
}
|
return false;
|
}
|
}
|