新增找尋進出校園的位置

This commit is contained in:
leo 2024-02-21 15:29:01 +08:00
parent cd0b1ed9fa
commit 1563577166
2 changed files with 36 additions and 15 deletions

View File

@ -218,6 +218,27 @@ namespace WebApi_data_value.Controllers
} }
#endregion #endregion
#region
///<summary>
///尋找所有進出校園的地點
/// </summary>
/// <returns></returns>
[HttpGet("location_name")]
public async Task<IEnumerable<object>> Get_in_Yuntech_location_name()
{
var location_name_table = await _context.yuntech_in_car_table
.GroupBy(c=>c.location)
.Select(group => new
{
location_name = group.Key,
})
.ToListAsync();
return location_name_table;
}
#endregion
#region #region
/// <summary> /// <summary>

View File

@ -17,8 +17,8 @@ builder.Services.AddCors();
builder.Services.AddControllers(); builder.Services.AddControllers();
// 連線PostgreSQL資料庫 // 連線PostgreSQL資料庫
//var connectionString = "Server=140.125.20.183;UserID=postgres;password=EL404el404;Database=postgres;port=5432;Search Path=public;CommandTimeout=1800"; var connectionString = "Server=140.125.20.183;UserID=postgres;password=EL404el404;Database=postgres;port=5432;Search Path=public;CommandTimeout=1800";
var connectionString = "Server=127.0.0.1;UserID=postgres;password=EL404el404;Database=postgres;port=5432;Search Path=public;CommandTimeout=1800"; //var connectionString = "Server=127.0.0.1;UserID=postgres;password=EL404el404;Database=postgres;port=5432;Search Path=public;CommandTimeout=1800";
builder.Services.AddDbContext<SqlContext>(opt => opt.UseNpgsql(connectionString)); builder.Services.AddDbContext<SqlContext>(opt => opt.UseNpgsql(connectionString));