NoticeController extends BaseControllerImpl<Notice> { @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询通知") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") public Result<Notice> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) { return super.findById(id); }  @Autowired void setNoticeService(NoticeService noticeService); @Override @GetMapping("/dict") @ApiOperation("获取通知的数据字典") @PreAuthorize("hasAnyAuthority('" + LIST_PERM + "')") Result<TableInfo> getTableInfo(); @Override @PostMapping @ApiOperation("保存通知") @PreAuthorize("hasAnyAuthority('" + ADD_PERM + "')") Result<Notice> save(@Valid @RequestBody Notice 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<Notice> update(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id, @RequestBody Notice model) {; @Override @GetMapping @ApiOperation("查询所有通知") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<List<Notice>> findAll(Notice model); @Override @GetMapping("/{page:[0-9]+}/{size:[0-9]+}") @ApiOperation("分页查询通知列表") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<QueryResult<Notice>> query(@ApiParam(value = "页码", required = true) @PathVariable("page") int page, @ApiParam(value = "每页数据条数", required = true) @PathVariable("size") int size, Notice model) {; @Override @GetMapping("/{id:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("根据ID查询通知") @PreAuthorize("hasAnyAuthority('" + QUERY_PERM + "')") Result<Notice> findById(@ApiParam(value = "主键id", required = true) @PathVariable("id") String id) {; @Override @PostMapping("/import") @ApiOperation("从文件导入通知") @PreAuthorize("hasAnyAuthority('" + IMPORT_PERM + "')") Result<List<Notice>> importData(MultipartFile file); @Override @GetMapping("/export") @ApiOperation("导出通知到文件") @PreAuthorize("permitAll()") void exportData(@RequestParam(required = false) List<String> ids, HttpServletResponse response); @Override @PostMapping("/batch") @ApiOperation("批量操作通知") @PreAuthorize("hasAuthority('" + ADD_PERM + "') and hasAuthority('" + EDIT_PERM + "') and hasAuthority('" + DELETE_PERM + "')") Result batch(@RequestBody BatchModel<Notice> batch); @PostMapping("/sendNotice/{noticeId:^[a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9]+$}") @ApiOperation("发送通知") @PreAuthorize("isAuthenticated()") Result<Void> sendNotice(@ApiParam("通知id") @PathVariable String noticeId, @ApiParam("用户id数组") @RequestBody String[] receiverIds) {; @GetMapping("/receiveNotice") @ApiOperation("接收通知") @PreAuthorize("isAuthenticated()") Result<List<NotificationRecord>> receiveNotice();  }
@Test @WithMockUser(username = TEST_USER, authorities = QUERY_PERM) public void testFindById() throws Exception { String id = "{}"; String result = mockMvc.perform(get("/sys/notice/" + id) .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); }