parking-html/Parking_spaces/Controllers/Park_spacesController.cs
2024-09-13 23:32:32 +08:00

81 lines
2.1 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Parking_spaces.Authorization;
using Parking_spaces.Helpers;
using System.Net.Http.Headers;
namespace Parking_spaces.Controllers
{
public class Park_spacesController : Controller
{
private readonly HttpClient _httpClient;
public Park_spacesController(HttpClient httpClient, IConfiguration configuration)
{
_httpClient = httpClient;
}
//[Authorize]
/*
public async Task<IActionResult> Parking_spaces_total_table(string id)
{
if (id != null)
{
// 获取身份验证令牌
string token = id;
// 设置 HttpClient 的默认请求头
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token);
// 构建 API 请求的 URL
string apiUrl = "http://localhost:7700/Users/token";
// 调用需要身份验证的 API
HttpResponseMessage response = await _httpClient.GetAsync(apiUrl);
if (response.ReasonPhrase == "OK")
{
ViewBag.token_check = "true";
ViewBag.token = token;
return View();
}
else
{
ViewBag.token_check = "false";
return View();
}
}
else {
ViewBag.token_check = "false";
return View();
//return RedirectToAction("Login", "Home");
}
}*/
public IActionResult Parking_spaces_total_table()
{
return View();
}
//[Authorize]
public IActionResult Single_parking_spaces_detail(string id)
{
ViewBag.name = id;
return View();
}
public IActionResult Single_parking_spaces_map(string id)
{
ViewBag.name = id;
return View();
}
public IActionResult Parking_spaces_history(string id)
{
return View();
}
}
}