@Test public void testBatch() throws Exception { BatchModel<Position> batchModel = new BatchModel<>(); batchModel.setDelete(new String[]{"1","2"}); String content = objectMapper.writeValueAsString(batchModel); String result = mockMvc.perform(post("/sys/position/batch") .header(HttpHeaders.AUTHORIZATION, String.join(" ", accessToken.getTokenType(), accessToken.getValue())) .content(content) .contentType(MediaType.APPLICATION_JSON_UTF8) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()) .andExpect(jsonPath("$.data.id").isNotEmpty()) .andReturn().getResponse().getContentAsString(); log.info("{}",result); }
@Override @PostMapping("/batch") @ApiOperation("批量操作数据") @PreAuthorize("hasAuthority('" + ADD_PERM +"') and hasAuthority('" + EDIT_PERM +"') and hasAuthority('" + DELETE_PERM +"')") public Result batch(@RequestBody BatchModel<Position> batch) { return super.batch(batch); }
PositionController extends LeftTreeRightTableControllerImpl<Department, Position> { @Override @PostMapping("/batch") @ApiOperation("批量操作数据") @PreAuthorize("hasAuthority('" + ADD_PERM +"') and hasAuthority('" + EDIT_PERM +"') and hasAuthority('" + DELETE_PERM +"')") public Result batch(@RequestBody BatchModel<Position> batch) { return super.batch(batch); } }
PositionController extends LeftTreeRightTableControllerImpl<Department, Position> { @Override @PostMapping("/batch") @ApiOperation("批量操作数据") @PreAuthorize("hasAuthority('" + ADD_PERM +"') and hasAuthority('" + EDIT_PERM +"') and hasAuthority('" + DELETE_PERM +"')") public Result batch(@RequestBody BatchModel<Position> batch) { return super.batch(batch); }  }
PositionController extends LeftTreeRightTableControllerImpl<Department, Position> { @Override @PostMapping("/batch") @ApiOperation("批量操作数据") @PreAuthorize("hasAuthority('" + ADD_PERM +"') and hasAuthority('" + EDIT_PERM +"') and hasAuthority('" + DELETE_PERM +"')") public Result batch(@RequestBody BatchModel<Position> batch) { return super.batch(batch); }  @Autowired void setPositionService(PositionService positionService); @Override @GetMapping("/dict") @ApiOperation("获取岗位的数据字典") @PreAuthorize("hasAnyAuthority('" + LIST_PERM + "')") Result<TableInfo> getTableInfo(); @Override @PostMapping @ApiOperation("保存岗位") @PreAuthorize("hasAnyAuthority('" + ADD_PERM + "')") Result<Position> save(@Valid @RequestBody Position 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<Position> update(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id, @RequestBody Position model) {; @Override @GetMapping @ApiOperation("查询所有岗位") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Position>> findAll(Position model); @Override @GetMapping("/{page:[0-9]+}/{size:[0-9]+}") @ApiOperation("分页查询岗位列表") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<QueryResult<Position>> query(@ApiParam(value = "页码", required = true) @PathVariable("page") int page, @ApiParam(value = "每页数据条数", required = true) @PathVariable("size") int size, Position model) {; @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询岗位") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<Position> 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<Position> batch); @Override @PostMapping("/import") @ApiOperation("从文件导入岗位") @PreAuthorize("hasAnyAuthority('" + IMPORT_PERM + "')") Result<List<Position>> importData(MultipartFile file); @Override @GetMapping("/export") @ApiOperation("导出岗位到文件") @PreAuthorize("permitAll()") void exportData(@RequestBody(required = false) List<String> ids, HttpServletResponse response); @Override @GetMapping("/leftTree") @ApiOperation("获取左树数据") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Department>> leftTreeData(); }
PositionController extends LeftTreeRightTableControllerImpl<Department, Position> { @Override @PostMapping("/batch") @ApiOperation("批量操作数据") @PreAuthorize("hasAuthority('" + ADD_PERM +"') and hasAuthority('" + EDIT_PERM +"') and hasAuthority('" + DELETE_PERM +"')") public Result batch(@RequestBody BatchModel<Position> batch) { return super.batch(batch); }  @Autowired void setPositionService(PositionService positionService); @Override @GetMapping("/dict") @ApiOperation("获取岗位的数据字典") @PreAuthorize("hasAnyAuthority('" + LIST_PERM + "')") Result<TableInfo> getTableInfo(); @Override @PostMapping @ApiOperation("保存岗位") @PreAuthorize("hasAnyAuthority('" + ADD_PERM + "')") Result<Position> save(@Valid @RequestBody Position 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<Position> update(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id, @RequestBody Position model) {; @Override @GetMapping @ApiOperation("查询所有岗位") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Position>> findAll(Position model); @Override @GetMapping("/{page:[0-9]+}/{size:[0-9]+}") @ApiOperation("分页查询岗位列表") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<QueryResult<Position>> query(@ApiParam(value = "页码", required = true) @PathVariable("page") int page, @ApiParam(value = "每页数据条数", required = true) @PathVariable("size") int size, Position model) {; @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询岗位") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<Position> 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<Position> batch); @Override @PostMapping("/import") @ApiOperation("从文件导入岗位") @PreAuthorize("hasAnyAuthority('" + IMPORT_PERM + "')") Result<List<Position>> importData(MultipartFile file); @Override @GetMapping("/export") @ApiOperation("导出岗位到文件") @PreAuthorize("permitAll()") void exportData(@RequestBody(required = false) List<String> ids, HttpServletResponse response); @Override @GetMapping("/leftTree") @ApiOperation("获取左树数据") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Department>> leftTreeData();  }