118 lines
4.1 KiB
C#
118 lines
4.1 KiB
C#
using AsmResolver.PE.DotNet.Cil;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Security.Claims;
|
|
using static asg_form.Controllers.AssignmentController;
|
|
|
|
namespace asg_form.Controllers
|
|
{
|
|
public class BlackDB
|
|
{
|
|
public string id { get; set; }
|
|
public string record_name { get; set; }
|
|
public string violator { get; set; }
|
|
public string platform_record { get; set; }
|
|
public string offending_details { get; set; }
|
|
public string processing_result { get; set; }
|
|
public string feature_id { get; set; }
|
|
|
|
}
|
|
|
|
public class BlackFront
|
|
{
|
|
public string recordName { get; set; }
|
|
public string violator { get; set; }
|
|
public string platformRecord { get; set; }
|
|
public string offendingDetails { get; set; }
|
|
public string processingResult { get; set; }
|
|
public string featureId { get; set; }
|
|
}
|
|
|
|
[ApiController]
|
|
public class BlackController : ControllerBase
|
|
{
|
|
|
|
/// <summary>
|
|
/// 增加信息
|
|
/// </summary>
|
|
/// <param name="datas"></param>
|
|
/// <returns></returns>
|
|
[Route("api/v1/blackTable/Add")]
|
|
[HttpPost]
|
|
public async Task<ActionResult<object>> blackAdd ([FromBody] BlackFront datas)
|
|
{
|
|
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin")||!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
|
{
|
|
return Ok(new error_mb { code = 401, message = "无权访问" });
|
|
}
|
|
using (TestDbContext sub = new TestDbContext())
|
|
{
|
|
try
|
|
{
|
|
var blackp = new BlackDB
|
|
{
|
|
id = Guid.NewGuid().ToString(),
|
|
record_name = datas.recordName,
|
|
violator = datas.violator,
|
|
platform_record = datas.platformRecord,
|
|
offending_details = datas.offendingDetails,
|
|
processing_result = datas.processingResult,
|
|
feature_id = datas.featureId,
|
|
};
|
|
try
|
|
{
|
|
sub.T_blacks.Add(blackp);
|
|
await sub.SaveChangesAsync();
|
|
return Ok(new error_mb { code = 200, message = "添加黑名单人员成功!" });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return Ok(new { code = 500, message = "服务器错误", details = ex });
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return BadRequest(ex);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新信息
|
|
/// </summary>
|
|
/// <param name="datas"></param>
|
|
/// <returns></returns>
|
|
[Route("api/v1/blackTable/Update")]
|
|
[HttpPost]
|
|
public async Task<ActionResult<object>> blackUpd([FromBody] BlackFront datas)
|
|
{
|
|
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin") || !this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
|
{
|
|
return Ok(new error_mb { code = 401, message = "无权访问" });
|
|
}
|
|
TestDbContext sub = new TestDbContext();
|
|
|
|
return Ok(new { code = 200, message = "" });
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除信息
|
|
/// </summary>
|
|
/// <param name="idFind"></param>
|
|
/// <returns></returns>
|
|
[Route("api/v1/blackTable/Del")]
|
|
[HttpGet]
|
|
public async Task<ActionResult<object>> blackDel([FromQuery] string idFind)
|
|
{
|
|
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin") || !this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
|
{
|
|
return Ok(new error_mb { code = 401, message = "无权访问" });
|
|
}
|
|
TestDbContext sub = new TestDbContext();
|
|
|
|
return Ok(new { code = 200, message = "" });
|
|
}
|
|
}
|
|
}
|