2024-10-01 02:34:26 +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-11-18 16:41:34 +08:00
|
|
|
|
string apiUrl = "http://localhost:7700/Users/token";
|
2024-10-01 02:34:26 +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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|