29 lines
739 B
C#
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();
|
|
}
|
|
}
|
|
}
|