Parking_space_ASPNET/Parking_spaces/Controllers/Park_spacesController.cs

81 lines
2.1 KiB
C#
Raw Normal View History

2024-02-01 11:37:15 +08:00
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
2024-08-14 16:11:56 +08:00
string apiUrl = "http://140.125.20.183:7700/Users/token";
2024-02-01 11:37:15 +08:00
// 调用需要身份验证的 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();
}
}
}