using Util.Exceptions; using Util.Microservices.Dapr.WebApiSample.Dtos; namespace Util.Microservices.Dapr.WebApiSample.Controllers { /// /// 测试2控制器 - 用于测试使用服务调用获取未包装的原始对象 /// [ApiController] [Route("Test2")] public class Test2Controller : ControllerBase { /// /// 测试Get方法访问 - 无参数 - 无返回值 - 成功 /// [HttpGet] public void Get() { } /// /// 测试Get方法访问 - 无参数 - 无返回值 - 失败 /// [HttpGet( "fail" )] public IActionResult Get_Fail() { return new BadRequestResult(); } /// /// 测试Post方法访问 - 有参数 - 无返回值 /// [HttpPost] public void Post( CustomerDto dto ) { if ( dto.Code != "2" ) throw new Warning( "id必须为2" ); } /// /// 测试Get方法访问 - 无参数 - 有返回值 /// [HttpGet( "customer" )] public CustomerDto Get_Customer() { var dto = new CustomerDto { Name = "ok" }; return dto; } /// /// 测试Get方法访问 - 有参数 - 有返回值 /// [HttpGet( "query" )] public CustomerDto Query( [FromQuery] CustomerQuery query ) { var dto = new CustomerDto { Name = query.Name }; return dto; } } }