可以根据@requestparam的值为请求体提供不同的验证器吗?

wvmv3b1j  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(286)

是的,我已经看过这个了。但我的情况与此不同。在那里,场景中是否有请求参数。但是在我的例子中,我想根据@requestparam的值对@requestbody进行不同的验证。这是可以实现的吗?

  1. @PostMapping("/supplier")
  2. @ApiOperation(value = "Get local attributes of a supplier(s)", notes = "Returns the sms attributes of supplier", response = LocalDTO.class)
  3. public @ResponseBody
  4. ResponseEntity<ResponseDTO> getSmsForShippingPoint(
  5. @ApiParam(value = "Search By", required = true) @RequestParam(name = "searchBy") String searchBy,
  6. @ApiParam(value = "Suvc, Suffix, Site and SmsVendor", required = true) @RequestBody @Valid RequestSmsDTO requestSmsDTO) throws ValidationException {
  7. if(searchBy.equals("shipping-point")){
  8. ResponseDTO smsResponseDTO = supplierService.findSmsByShippingPoint(requestSmsDTO);
  9. return ResponseEntity.status(HttpStatus.OK)
  10. .body(smsResponseDTO);
  11. }
  12. return null;
  13. }

所以基于 searchBy 我需要对requestbody执行不同的验证。就我而言 RequestSmsDTO 对象

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题