T
This commit is contained in:
parent
56322e39dc
commit
24fdc69a44
@ -23,7 +23,7 @@ namespace WebApi_data_value.Controllers
|
|||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
[AllowAnonymous]
|
||||||
#region 獲取停車場所有資料
|
#region 獲取停車場所有資料
|
||||||
// GET: api/Parking_spaces_total_table
|
// GET: api/Parking_spaces_total_table
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -40,6 +40,7 @@ namespace WebApi_data_value.Controllers
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
#region 獲取停車場單一資料
|
#region 獲取停車場單一資料
|
||||||
// GET: api/Parking_spaces_total_table/5
|
// GET: api/Parking_spaces_total_table/5
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
140
WebApi_data_value/Controllers/Yuntech_camController.cs
Normal file
140
WebApi_data_value/Controllers/Yuntech_camController.cs
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WebApi_data_value.Models;
|
||||||
|
using WebApi_data_value.Authorization;
|
||||||
|
using WebApi_data_value.Services;
|
||||||
|
|
||||||
|
namespace WebApi_data_value.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class Yuntech_camController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly SqlContext _context;
|
||||||
|
|
||||||
|
public Yuntech_camController(SqlContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: api/Yuntech_cam
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<Yuntech_cam>>> Getyuntech_cam()
|
||||||
|
{
|
||||||
|
if (_context.yuntech_cam == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
return await _context.yuntech_cam.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: api/Yuntech_cam/5
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public async Task<ActionResult<Yuntech_cam>> GetYuntech_cam(string id)
|
||||||
|
{
|
||||||
|
if (_context.yuntech_cam == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
var yuntech_cam = await _context.yuntech_cam.FindAsync(id);
|
||||||
|
|
||||||
|
if (yuntech_cam == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return yuntech_cam;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUT: api/Yuntech_cam/5
|
||||||
|
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||||
|
[HttpPut("{id}")]
|
||||||
|
public async Task<IActionResult> PutYuntech_cam(string id, Yuntech_cam yuntech_cam)
|
||||||
|
{
|
||||||
|
if (id != yuntech_cam.ip)
|
||||||
|
{
|
||||||
|
return BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
_context.Entry(yuntech_cam).State = EntityState.Modified;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch (DbUpdateConcurrencyException)
|
||||||
|
{
|
||||||
|
if (!Yuntech_camExists(id))
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: api/Yuntech_cam
|
||||||
|
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<Yuntech_cam>> PostYuntech_cam(Yuntech_cam yuntech_cam)
|
||||||
|
{
|
||||||
|
if (_context.yuntech_cam == null)
|
||||||
|
{
|
||||||
|
return Problem("Entity set 'SqlContext.yuntech_cam' is null.");
|
||||||
|
}
|
||||||
|
_context.yuntech_cam.Add(yuntech_cam);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch (DbUpdateException)
|
||||||
|
{
|
||||||
|
if (Yuntech_camExists(yuntech_cam.ip))
|
||||||
|
{
|
||||||
|
return Conflict();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CreatedAtAction("GetYuntech_cam", new { id = yuntech_cam.ip }, yuntech_cam);
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE: api/Yuntech_cam/5
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public async Task<IActionResult> DeleteYuntech_cam(string id)
|
||||||
|
{
|
||||||
|
if (_context.yuntech_cam == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
var yuntech_cam = await _context.yuntech_cam.FindAsync(id);
|
||||||
|
if (yuntech_cam == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
_context.yuntech_cam.Remove(yuntech_cam);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Yuntech_camExists(string id)
|
||||||
|
{
|
||||||
|
return (_context.yuntech_cam?.Any(e => e.ip == id)).GetValueOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,140 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WebApi_data_value.Models;
|
||||||
|
using WebApi_data_value.Authorization;
|
||||||
|
using WebApi_data_value.Services;
|
||||||
|
|
||||||
|
namespace WebApi_data_value.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class Yuntech_cam_total_tableController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly SqlContext _context;
|
||||||
|
|
||||||
|
public Yuntech_cam_total_tableController(SqlContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: api/Yuntech_cam_total_table
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<IEnumerable<Yuntech_cam_total_table>>> Getyuntech_cam_total_table()
|
||||||
|
{
|
||||||
|
if (_context.yuntech_cam_total_table == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
return await _context.yuntech_cam_total_table.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: api/Yuntech_cam_total_table/5
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public async Task<ActionResult<Yuntech_cam_total_table>> GetYuntech_cam_total_table(string id)
|
||||||
|
{
|
||||||
|
if (_context.yuntech_cam_total_table == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
var yuntech_cam_total_table = await _context.yuntech_cam_total_table.FindAsync(id);
|
||||||
|
|
||||||
|
if (yuntech_cam_total_table == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return yuntech_cam_total_table;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUT: api/Yuntech_cam_total_table/5
|
||||||
|
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||||
|
[HttpPut("{id}")]
|
||||||
|
public async Task<IActionResult> PutYuntech_cam_total_table(string id, Yuntech_cam_total_table yuntech_cam_total_table)
|
||||||
|
{
|
||||||
|
if (id != yuntech_cam_total_table.location_name)
|
||||||
|
{
|
||||||
|
return BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
_context.Entry(yuntech_cam_total_table).State = EntityState.Modified;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch (DbUpdateConcurrencyException)
|
||||||
|
{
|
||||||
|
if (!Yuntech_cam_total_tableExists(id))
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: api/Yuntech_cam_total_table
|
||||||
|
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<Yuntech_cam_total_table>> PostYuntech_cam_total_table(Yuntech_cam_total_table yuntech_cam_total_table)
|
||||||
|
{
|
||||||
|
if (_context.yuntech_cam_total_table == null)
|
||||||
|
{
|
||||||
|
return Problem("Entity set 'SqlContext.yuntech_cam_total_table' is null.");
|
||||||
|
}
|
||||||
|
_context.yuntech_cam_total_table.Add(yuntech_cam_total_table);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch (DbUpdateException)
|
||||||
|
{
|
||||||
|
if (Yuntech_cam_total_tableExists(yuntech_cam_total_table.location_name))
|
||||||
|
{
|
||||||
|
return Conflict();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CreatedAtAction("GetYuntech_cam_total_table", new { id = yuntech_cam_total_table.location_name }, yuntech_cam_total_table);
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE: api/Yuntech_cam_total_table/5
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public async Task<IActionResult> DeleteYuntech_cam_total_table(string id)
|
||||||
|
{
|
||||||
|
if (_context.yuntech_cam_total_table == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
var yuntech_cam_total_table = await _context.yuntech_cam_total_table.FindAsync(id);
|
||||||
|
if (yuntech_cam_total_table == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
_context.yuntech_cam_total_table.Remove(yuntech_cam_total_table);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Yuntech_cam_total_tableExists(string id)
|
||||||
|
{
|
||||||
|
return (_context.yuntech_cam_total_table?.Any(e => e.location_name == id)).GetValueOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
WebApi_data_value/Models/Yuntech_cam.cs
Normal file
9
WebApi_data_value/Models/Yuntech_cam.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace WebApi_data_value.Models
|
||||||
|
{
|
||||||
|
public class Yuntech_cam
|
||||||
|
{
|
||||||
|
public string? location_name { get; set; }
|
||||||
|
public string? ip { get; set; }
|
||||||
|
public string? url { get; set; }
|
||||||
|
}
|
||||||
|
}
|
9
WebApi_data_value/Models/Yuntech_cam_total_table.cs
Normal file
9
WebApi_data_value/Models/Yuntech_cam_total_table.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace WebApi_data_value.Models
|
||||||
|
{
|
||||||
|
public class Yuntech_cam_total_table
|
||||||
|
{
|
||||||
|
public string? location_name { get; set; }
|
||||||
|
public string? longitude { get; set; }
|
||||||
|
public string? latitude { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -49,6 +49,11 @@ namespace WebApi_data_value.Services
|
|||||||
//大門口
|
//大門口
|
||||||
public DbSet<Yuntech_in_car_table> yuntech_in_car_table { get; set; } = null!;
|
public DbSet<Yuntech_in_car_table> yuntech_in_car_table { get; set; } = null!;
|
||||||
|
|
||||||
|
//雲科校內相機
|
||||||
|
public DbSet<Yuntech_cam_total_table> yuntech_cam_total_table { get; set; } = null!;
|
||||||
|
public DbSet<Yuntech_cam> yuntech_cam { get; set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
@ -75,6 +80,9 @@ namespace WebApi_data_value.Services
|
|||||||
builder.Entity<Parking_space_algorithm>().HasKey(o => new { o.algorithm_serial_num }); //Primary Key
|
builder.Entity<Parking_space_algorithm>().HasKey(o => new { o.algorithm_serial_num }); //Primary Key
|
||||||
|
|
||||||
builder.Entity<Yuntech_in_car_table>().HasKey(o => new { o.in_time }); //Primary Key
|
builder.Entity<Yuntech_in_car_table>().HasKey(o => new { o.in_time }); //Primary Key
|
||||||
|
|
||||||
|
builder.Entity<Yuntech_cam_total_table>().HasKey(o => new { o.location_name }); //Primary Key
|
||||||
|
builder.Entity<Yuntech_cam>().HasKey(o => new { o.ip }); //Primary Key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<PackageReference Include="JWT" Version="10.0.2" />
|
<PackageReference Include="JWT" Version="10.0.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.7" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.7" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="6.0.7" />
|
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="6.0.7" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.26" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.27" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
Loading…
Reference in New Issue
Block a user