GenController extends BaseControllerImpl<Gen> { @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询代码生成模板") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") public Result<Gen> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) { return super.findById(id); }  @Autowired void setGenService(GenService genService); @Override @GetMapping("/dict") @ApiOperation("获取代码生成模板的数据字典") @PreAuthorize("hasAnyAuthority('" + LIST_PERM + "')") Result<TableInfo> getTableInfo(); @Override @PostMapping @ApiOperation("保存代码生成模板") @PreAuthorize("hasAnyAuthority('" + ADD_PERM + "')") Result<Gen> save(@Valid @RequestBody Gen model); @Override @DeleteMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("删除代码生成模板") @PreAuthorize("hasAnyAuthority('" + DELETE_PERM + "')") Result<Void> delete(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) {; @Override @PutMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("更新代码生成模板") @PreAuthorize("hasAnyAuthority('" + EDIT_PERM + "')") Result<Gen> update(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id, @RequestBody Gen model) {; @Override @GetMapping @ApiOperation("查询所有代码生成模板") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Gen>> findAll(Gen model); @Override @GetMapping("/{page:[0-9]+}/{size:[0-9]+}") @ApiOperation("分页查询代码生成模板列表") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<QueryResult<Gen>> query(@ApiParam(value = "页码", required = true) @PathVariable("page") int page, @ApiParam(value = "每页数据条数", required = true) @PathVariable("size") int size, Gen model) {; @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询代码生成模板") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<Gen> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) {; @Override @PostMapping("/batch") @ApiOperation("批量操作代码生成模板") @PreAuthorize("hasAuthority('" + ADD_PERM +"') and hasAuthority('" + EDIT_PERM +"') and hasAuthority('" + DELETE_PERM +"')") Result batch(@RequestBody BatchModel<Gen> batch); @GetMapping("/gen/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据实体类生成文件") @PreAuthorize("permitAll()") void gen(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id, @RequestParam("className") Class<T> clazz, HttpServletResponse response) thr; @GetMapping("/gen") @ApiOperation("根据实体类生成所有文件") @PreAuthorize("permitAll()") void gen(@RequestParam("className") Class<T> clazz, HttpServletResponse response); @GetMapping("/preview/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("预览实体类生成的文件") @PreAuthorize("hasAnyAuthority('" + GEN_PERM +"')") Result<Map<String, String>> preview(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id, @RequestParam("className") Class<T> clazz) {; @GetMapping("/genInfo") @ApiOperation("查询实体类代码生成信息") @PreAuthorize("hasAnyAuthority('" + GEN_PERM +"')") Result<List<GenInfo>> genning(@RequestParam("className") Class<T> clazz); @Override @PostMapping("/import") @ApiOperation("从文件导入代码模板") @PreAuthorize("hasAnyAuthority('" + IMPORT_PERM + "')") Result<List<Gen>> importData(MultipartFile file); @Override @GetMapping("/export") @ApiOperation("导出代码模板到文件") @PreAuthorize("permitAll()") void exportData(@RequestBody(required = false) List<String> ids, HttpServletResponse response);  }
@Test public void testFindById() throws Exception { String id = "{}"; String result = mockMvc.perform(get("/tool/gen/"+ id) .header(HttpHeaders.AUTHORIZATION, String.join(" ", accessToken.getTokenType(), accessToken.getValue())) .contentType(MediaType.APPLICATION_JSON_UTF8) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()) .andExpect(jsonPath("$.data.id").value(id)) .andReturn().getResponse().getContentAsString(); log.info(result); }