一些注解
Bean校验注解
@NotBlank一般用来校验String类型不能为空
@NotNull一般用来校验Integer类型不能为空
@NotEmpty一般用来校验List类型不能为空
需在控制器中配合 @Valid 使用,例如
1 2 3
| @RepeatSubmit @PostMapping(value = "/datasetsConfig") public R datasetsConfig(@RequestBody @Valid DatasetsConfigDTO dto)
|
controller
@RepeatSubmit 防止重复提交
@RepeatSubmit(interval = 60000, message = “请求过于频繁”) 限制频次
1 2 3 4 5 6 7
| @GetMapping(value = "/getDocumentsSegments/{datasetsId}/{documentId}") public R<DocumentsListSegmentsVO> getDocumentsSegments(@PathVariable String datasetsId, @PathVariable String documentId, @RequestParam(value = "limit", defaultValue = "12") Integer limit, @RequestParam(value = "keyword") String keyword, @RequestParam(value = "enabled", defaultValue = "all") String enabled) { return R.ok(); }
|
1 2 3 4
| @PostMapping(value = "/addDocumentsSegments/{datasetsId}/{documentId}") public R<AddDocumentSegmentVO> addDocumentsSegments(@PathVariable String datasetsId, @PathVariable String documentId, @RequestBody @Valid AddDocumentsSegmentsDTO dto) { return R.ok(); }
|
1 2 3 4 5
| @Log(title = "角色管理", businessType = BusinessType.UPDATE) @PutMapping("/setName") public AjaxResult editName(@RequestBody SysRoleP sysRoleP) { return success(); }
|
1 2 3 4
| @DeleteMapping("/formGroup") public Object deleteFormGroup(@RequestParam Long id){ return oaFormGroupsService.deleteFormGroup(id); }
|
允许参数为空
1 2 3 4 5
| @GetMapping("/info") public AjaxResult editOrReplenish(@RequestParam(value = "instanceId") Long instanceId, @RequestParam(value = "reportId", required = false) Long reportId) { return R.ok(); }
|
sql
@TableField(exist = false)
private Long[] menuIds;