public ActionResult GetHobbies3([FromQuery][CustomizeValidator(RuleSet = "all")] QueryStudentHobbiesDto dto) { //isn't valid will not visit the okobjectresult, but visit the filter return(Ok(new { code = 0, data = new List <string> { "v1", "v2" }, msg = "" })); }
public ActionResult GetHobbies3([FromQuery] QueryStudentHobbiesDto dto) { var(flag, msg) = _studentService.QueryHobbies(dto); return(!flag ? Ok(new { code = -1, data = new List <string>(), msg }) : Ok(new { code = 0, data = new List <string> { "v1", "v2" }, msg = "" })); }
public IActionResult GetHobbies2([FromQuery] QueryStudentHobbiesDto dto) { var results = _validator.Validate(dto, ruleSet: "all"); return(!results.IsValid ? Ok(new { code = -1, data = new List <string>(), msg = results.Errors.FirstOrDefault().ErrorMessage }) : Ok(new { code = 0, data = new List <string> { "v1", "v2" }, msg = "" })); }
public ActionResult GetHobbies4([FromQuery][CustomizeValidator(RuleSet = "all")] QueryStudentHobbiesDto dto) { return(Ok(new { code = 0, data = new List <string> { "v1", "v2" }, msg = "" })); }