Skip to content

Commit

Permalink
refactor($starter): update common controller for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Jun 26, 2022
1 parent 432b700 commit e4a52e0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import cn.hutool.json.JSON
import com.jmsoftware.maf.common.bean.ResponseBodyBean
import com.jmsoftware.maf.common.domain.ValidationTestPayload
import com.jmsoftware.maf.reactivespringcloudstarter.service.CommonService
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*
import javax.validation.Valid

/**
* # CommonController
Expand All @@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.*
*
* @author Johnny Miller (锺俊), e-mail: johnnysviva@outlook.com, date: 4/16/22 11:37 AM
*/
@Validated
@RestController
@RequestMapping("/common")
class CommonController(
Expand All @@ -24,7 +27,7 @@ class CommonController(
}

@PostMapping("/validation-test")
fun validationTest(@RequestBody payload: ValidationTestPayload): ResponseBodyBean<String> {
fun validationTest(@Valid @RequestBody payload: ValidationTestPayload): ResponseBodyBean<String> {
commonService.validateObject(payload)
return ResponseBodyBean.ofSuccess(payload.name, "validationTest()")
}
Expand Down

0 comments on commit e4a52e0

Please sign in to comment.