| | |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RequestPart; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.thymeleaf.context.Context; |
| | |
| | | writeContentToResponse(model, response); |
| | | } |
| | | |
| | | @ApiOperation(value = "将 swagger json文件转换成 word文档并下载", notes = "") |
| | | @ApiResponses(value = {@ApiResponse(code = 200, message = "请求成功。")}) |
| | | @RequestMapping(value = "/OpenApiFileToWord2", method = {RequestMethod.POST}) |
| | | public void getWord2( |
| | | Model model, |
| | | @ApiParam("swagger json url") @RequestParam("url") String url, |
| | | HttpServletResponse response |
| | | ) throws Exception { |
| | | generateModelData(model, url); |
| | | writeContentToResponse(model, response); |
| | | } |
| | | |
| | | private void generateModelData(Model model, MultipartFile jsonFile) throws IOException { |
| | | Map<String, Object> result = openApiWordService.tableList(jsonFile); |
| | | fileName = jsonFile.getOriginalFilename(); |
| | |
| | | model.addAllAttributes(result); |
| | | } |
| | | |
| | | private void generateModelData(Model model, String url, Integer download) { |
| | | private void generateModelData(Model model, String url) { |
| | | url = StringUtils.defaultIfBlank(url, swaggerUrl); |
| | | Map<String, Object> result = openApiWordService.tableList(url); |
| | | model.addAttribute("url", url); |
| | | model.addAttribute("download", download); |
| | | model.addAttribute("download", 0); |
| | | model.addAllAttributes(result); |
| | | } |
| | | |