You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.0 KiB
47 lines
1.0 KiB
using Microsoft.AspNetCore.Mvc; |
|
using System.Threading.Tasks; |
|
using Volo.Abp; |
|
using Volo.Abp.AspNetCore.Mvc; |
|
using Volo.Abp.Authorization; |
|
|
|
namespace BookStore.Controllers; |
|
|
|
[Route("api/wrap")] |
|
public class WrapController : AbpControllerBase |
|
{ |
|
[HttpGet("string")] |
|
public Task<string> GetResultAsync() |
|
{ |
|
return Task.FromResult("Hello!"); |
|
} |
|
|
|
[HttpGet("person")] |
|
public Task<Person> GetPersonAsync() |
|
{ |
|
var person = new Person |
|
{ |
|
Name = "wwwk", |
|
Age = 18 |
|
}; |
|
|
|
return Task.FromResult(person); |
|
} |
|
|
|
[HttpGet("throw-exception")] |
|
public Task ThrowException() |
|
{ |
|
throw new UserFriendlyException("触发了一个异常!"); |
|
} |
|
|
|
[HttpGet("throw-auth-exception")] |
|
public Task ThrowAuthException() |
|
{ |
|
throw new AbpAuthorizationException(code: AbpAuthorizationErrorCodes.GivenPolicyHasNotGrantedForGivenResource); |
|
} |
|
} |
|
|
|
public class Person |
|
{ |
|
public string Name { get; set; } |
|
public int Age { get; set; } |
|
} |