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("getXmlValue")
|
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);
|
}
|
}
|