Added some folders.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-11-25 22:40:17 +10:00
parent 50a3c94af8
commit a4b72664fd
13 changed files with 53 additions and 50 deletions

View File

@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Mvc;
using NeDvachAPI.DBControllers;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class DeletePostController : ControllerBase
{
[HttpDelete("{id}")]
public JsonResult Get(string id)
{
DBchat.DeletePost(id);
return new JsonResult("Deleted Successfully!");
}
}
}

View File

@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Mvc;
using NeDvachAPI.BufferControllers;
using System.Text.Json;
using System.Web.Http;
using HttpGetAttribute = Microsoft.AspNetCore.Mvc.HttpGetAttribute;
using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class ListController : ControllerBase
{
[HttpGet(Name = "GetPosts")]
public string Get([FromUri] string board, int thread)
{
string postsJson = JsonSerializer.Serialize(APIThreadBuffer.GetThread(thread));
return postsJson ;
}
}
}

View File

@@ -0,0 +1,39 @@
using Microsoft.AspNetCore.Mvc;
using NeDvachAPI.DBControllers;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class UploadPic : ControllerBase
{
[HttpPost(Name = "UploadPicture")]
public async Task<JsonResult> ReceivePost([FromForm] IFormFile PostPicture)
{
var supportedTypes = new[] { "jpg", "png" };
string receivedFileName = PostPicture.FileName;
string fileExt = receivedFileName.Substring((receivedFileName.Length) - 3, 3);
if (supportedTypes.Contains(fileExt)) //file type check
{
///Local Buffer File Part
string filePath;
filePath = Directory.GetCurrentDirectory() + "\\Buffer\\" + receivedFileName;
Stream picBuffer = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
PostPicture.CopyTo(picBuffer);
picBuffer.Close();
///MinIo part
JsonResult picAdress = new(await MinIOchat.PictureUpload(filePath, receivedFileName));
Console.WriteLine("Загружен файл:" + "http://static.vdk2ch.ru:15555/thread-pics/" + receivedFileName);
return picAdress;
}
else return new JsonResult("Неверный тип файла");
}
}
}

View File

@@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Mvc;
using NeDvachAPI.BufferControllers;
using NeDvachAPI.DBControllers;
using NeDvachAPI.Models;
using System.Text.Json;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class PostToController : ControllerBase
{
[HttpPost(Name = "PostPosts")]
public JsonResult ReceivePost([FromBody] Post ReceivedPost)
{
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
ReceivedPost.Ip = ipAddress;
try
{
DBchat.SendPost(ReceivedPost);
APIThreadBuffer.RefreshThread(ReceivedPost.Thread_Id);
return new JsonResult("Сообщение успешно добавлено.");
}
catch
{
return new JsonResult("Произошла ошибка постинга");
}
}
}
}

View File

@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Mvc;
using NeDvachAPI.BufferControllers;
using System.Text.Json;
using System.Web.Http;
using HttpGetAttribute = Microsoft.AspNetCore.Mvc.HttpGetAttribute;
using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class ThreadsController : ControllerBase
{
[HttpGet(Name = "GetThreads")]
public string Get([FromUri] string board)
{
string postsJson = JsonSerializer.Serialize(APIThreadBuffer.GetThreadPreviews());
return postsJson;
}
}
}

View File

@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Text.Json;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class TestPostingController : ControllerBase
{
[HttpPost]
public int Area([FromForm] int height , int altitude)
{
//DBchat.SendPost(ReceivedPost);
Console.WriteLine("Received! " + height + " " + altitude );
return 200;
}
}
}