PerryHsu
2022-12-26 0723f31c8823e51449bd2e34f4b26a75f9e9cd2b
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
77
78
79
80
81
82
package com.whyc.controller;
 
import com.whyc.dto.FileParamToXml;
import com.whyc.dto.Response;
import com.whyc.pojo.FileParam;
import com.whyc.service.FileInfoService;
import com.whyc.service.FileParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.*;
import java.util.Map.Entry;
 
@Api(tags = "文件")
@RestController
@RequestMapping("fileInfo")
public class FileInfoController {
    @Autowired
    private FileInfoService service;
 
    @Autowired
    private FileParamService paramService;
 
 
    @ApiOperation(value = "解析xml文件(传参一个文件)")
    @GetMapping("getXmlValue")
    public Response getXmlValue(@RequestParam String filePath){
        return paramService.getXmlValue(filePath);
    }
 
    @ApiOperation(value = "解析xml文件(传参一个文件夹)")
    @GetMapping("getXmlValueByPath")
    public Response getXmlValueByPath(@RequestParam String filePath){
        return paramService.getXmlValueByPath(filePath);
    }
 
    @ApiOperation("通过修改属性窗口值来修改文件值(传参对象)")
    @PostMapping("updateXmlByFileParam")
    public Response updateXmlByFileParam(@RequestBody FileParam fileParam,@RequestParam String filePath){
        return  paramService.updateXmlByFileParam(fileParam,filePath);
    }
 
 
    @ApiOperation("通过修改属性窗口值来修改文件值(json)")
    @PostMapping("updateXmlByParamMap")
    public Response updateXmlByParamMap(@RequestBody JSONObject paramJson, @RequestParam String filePath){
        Map<String,String> map=new HashMap<>();
        Set paramSet=paramJson.entrySet();
        for (Iterator iter = paramSet.iterator(); iter.hasNext(); ) {
            Entry entry = (Entry) iter.next();
            String key = (String) entry.getKey();
            String value = (String) entry.getValue();
            String xmlName = FileParamToXml.getNameByType(key);
            if (xmlName != null && !xmlName.isEmpty()) {
                map.put(xmlName, value);
            }
        }
        return  paramService.updateXmlByParamMap(map,filePath);
    }
 
    @ApiOperation("根据fileId通过修改属性窗口值来修改数据库属性")
    @PostMapping("updateFileParamByFileId")
    public Response updateFileParamByFileId(@RequestBody FileParam fileParam,@RequestParam String fileId){
        return  paramService.updateFileParamByFileId(fileParam,fileId);
    }
 
    @ApiOperation("更改台站下公用参数")
    @PostMapping("updateFileParamByStationId")
    public Response updateFileParamByStationId(@RequestBody FileParam fileParam,@RequestParam int stationId){
        return  paramService.updateFileParamByStationId(fileParam,stationId);
    }
 
    @ApiOperation("对比时下拉选择站点下挂在的文件信息")
    @GetMapping("selectFileInStation")
    public Response selectFileInStation(){
        return  service.selectFileInStation();
    }
 
}