|
|
@ -1,5 +1,6 @@
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
|
|
using WebMVCApi.Models;
|
|
|
|
using WebMVCApi.Models;
|
|
|
|
|
|
|
|
|
|
|
|
namespace WebMVCApi.Controllers
|
|
|
|
namespace WebMVCApi.Controllers
|
|
|
@ -12,6 +13,13 @@ namespace WebMVCApi.Controllers
|
|
|
|
[ApiController]
|
|
|
|
[ApiController]
|
|
|
|
public class TestController : ControllerBase
|
|
|
|
public class TestController : ControllerBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private IMemoryCache _memoryCache;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TestController(IMemoryCache _memoryCache) {
|
|
|
|
|
|
|
|
this._memoryCache= _memoryCache;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("GetPerson")]
|
|
|
|
[HttpGet("GetPerson")]
|
|
|
|
public Person GetPerson()
|
|
|
|
public Person GetPerson()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -61,9 +69,11 @@ namespace WebMVCApi.Controllers
|
|
|
|
return new { Id = classNom+6, schoolName=schoolName + "扛把子", };
|
|
|
|
return new { Id = classNom+6, schoolName=schoolName + "扛把子", };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[HttpPut("UpdatePerson")]
|
|
|
|
[HttpPut("UpdatePerson")]
|
|
|
|
public ActionResult<Object> UpdatePerson(int id, Person p1)
|
|
|
|
public async Task<Object> UpdatePerson(int id, Person p1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return $"id {id} 的用户{p1.Name}更新成功";
|
|
|
|
return _memoryCache.GetOrCreateAsync<String>("val", async (e)=>{
|
|
|
|
|
|
|
|
return $"id {id} 的用户{p1.Name}更新成功 {DateTime.Now}";
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|