perryhsu
2020-10-17 a543f4de1c91ef6f43aace92975c6cf28de23618
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
package com.fgkj.controller;
 
import com.fgkj.util.*;
 
import com.fgkj.db.DBUtil1;
import com.fgkj.dto.App_Param;
import com.fgkj.dto.ServiceModel;
import com.fgkj.services.App_ParamService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
@RequestMapping("appParam")
@RestController
@Api
public class App_ParamController{
 
    @Autowired
    private App_ParamService service;
 
    //根据discharge/charge/poweroff查询
    @GetMapping("byInfo")
    public ServiceModel serchByInfo(@RequestBody App_Param param) {
        // App_Param param = getGson().fromJson(json, App_Param.class);
        ServiceModel model = service.serchByInfo(param);
 
        return model;
    }
    
    //修改参数
    @PutMapping("/")
    public ServiceModel update(@RequestBody List<App_Param> params) {
        // List<App_Param> params = getGson().fromJson(json, new TypeToken<List<App_Param>>(){}.getType());
        ServiceModel model = service.update(params);
        return model;
    }
    
    /**
     * 获取连接数据库的ip地址
     * @return
     */
    @GetMapping("ip")
    public ServiceModel seaechIp(){
        String ip = DBUtil1.getIp();
        ServiceModel model = new ServiceModel();
        if(ip != null && ip.length() > 0){
            model.setCode(1);
            model.setMsg(ip);
        }else{
            model.setMsg("获取失败");
        }
 
        return model;
    }
    
    /**
     * 设置服务器ip地址
     * @return
     */
    @PutMapping("ip")
    public ServiceModel updataIp(@RequestParam String json){
 
        ServiceModel model = DBUtil1.setIp(json);
 
        return model;
    }
 
}