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.
46 lines
1007 B
46 lines
1007 B
3 years ago
|
using Microsoft.AspNetCore.Mvc;
|
||
|
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; }
|
||
|
}
|