Backend/C_shape/WEBAPI/JWT/JWTdemo/Controllers/UserController.cs
Lin Weiting c07b6c1706 JWT
2024-05-06 14:09:39 +08:00

29 lines
739 B
C#

using JWTdemo.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using JWTdemo.Models;
using JWTdemo.Authorization;
namespace JWTdemo.Controllers
{
[Authorize] //有token才能使用class
[Route("api/[controller]")]
[ApiController]
public class UserController : ControllerBase
{
private readonly SqlContext _context;
public UserController(SqlContext context)
{
_context = context;
}
/// <summary>
/// 測試註解
/// </summary>
[HttpGet]
public async Task<ActionResult<IEnumerable<JWTdemo.Entities.User>>> Getuser()
{
return await _context.chatuser.ToListAsync();
}
}
}