Xxxu
2021-03-12 bd79403602e2192d84e83855c13132af0e623948
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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;
    }
}