@ResponseBody @Security(open = false, role = Role.DEVELOPER) @RequestMapping(params = "method=generator.update") public GeneratorUpdateResponse update(GeneratorUpdateRequest request) { Generator generator = generatorService.update(request); return new GeneratorUpdateResponse(generator); }
@ResponseBody @Security(open = false, role = Role.USER) @RequestMapping(params = "method=generator.search") public GeneratorSearchResponse search(GeneratorSearchRequest request) { PagerResult<Generator> pagerResult = generatorService.search(request); return new GeneratorSearchResponse(pagerResult); }
@ResponseBody @Security(open = false, role = Role.USER) @RequestMapping(params = "method=generator.get") public GeneratorGetResponse get(GeneratorGetRequest request) { Generator generator = generatorService.get(request); return new GeneratorGetResponse(generator); }
@ResponseBody @Security(open = false, role = Role.DEVELOPER) @RequestMapping(params = "method=generator.import") public GeneratorImportResponse _import(GeneratorImportRequest request) { Generator generator = generatorService._import(request); return new GeneratorImportResponse(generator); }
@ResponseBody @Security(open = false, role = Role.USER) @RequestMapping(params = "method=generator.authSearch") public GeneratorSearchResponse authSearch(GeneratorSearchRequest request) { Long userId = request.getAuthentication().getUserId(); request.setDeveloperId(userId); PagerResult<Generator> pagerResult = generatorService.search(request); return new GeneratorSearchResponse(pagerResult); }
@Security(open = false, role = Role.DEVELOPER) @RequestMapping(params = "method=generator.export") public ResponseEntity<byte[]> export(GeneratorExportRequest request) throws IOException { Long userId = request.getAuthentication().getUserId(); Generator generator = generatorService.export(request); File file = new File( ConfigProperties.TEMPORARY_PATH + ConfigProperties.fileSeparator + userId + ConfigProperties.fileSeparator + generator.getName() + "(" + generator.getId() + ").zip"); HttpHeaders headers = new HttpHeaders(); String fileName = java.net.URLEncoder.encode(file.getName(), "UTF-8"); headers.setContentDispositionFormData("attachment", fileName); headers.add("filename", fileName); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); return new ResponseEntity<>(FileUtils.readFileToByteArray(file), headers, HttpStatus.CREATED); }