whyclj
2019-10-29 1c0469e45346d464e0c5672ee68f9ecd4fb6be7c
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.fgkj.actions;
 
import java.util.List;
 
import com.fgkj.db.DBUtil;
import com.fgkj.db.DBUtil;
import com.fgkj.db.DBUtil1;
import com.fgkj.dto.App_Param;
import com.fgkj.dto.ServiceModel;
import com.fgkj.services.App_ParamService;
import com.google.gson.reflect.TypeToken;
 
public class App_ParamAction extends ActionUtil{
    private App_ParamService service = new App_ParamService();
    private String json;
    private String result;
    
    //根据discharge/charge/poweroff查询
    public String serchByInfo() {
        App_Param param = getGson().fromJson(json, App_Param.class);
        ServiceModel model = service.serchByInfo(param);
        result = tojson(model);
        return SUCCESS;
    }
    
    //修改参数
    public String update() {
        List<App_Param> params = getGson().fromJson(json, new TypeToken<List<App_Param>>(){}.getType());
        ServiceModel model = service.update(params);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    
    /**
     * 获取连接数据库的ip地址
     * @return
     */
    public String seaechIp(){
        String ip = DBUtil1.getIp();
        ServiceModel model = new ServiceModel();
        if(ip != null && ip.length() > 0){
            model.setCode(1);
            model.setMsg(ip);
        }else{
            model.setMsg("获取失败");
        }
        result = tojson(model);
        return SUCCESS;
    }
    
    /**
     * 设置服务器ip地址
     * @return
     */
    public String updataIp(){
        ServiceModel model = DBUtil1.setIp(json);
        result = tojson(model);
        return SUCCESS;
    }
 
    public String getJson() {
        return json;
    }
 
    public void setJson(String json) {
        this.json = json;
    }
 
    public String getResult() {
        return result;
    }
 
    public void setResult(String result) {
        this.result = result;
    }
}