黑名单雏形

This commit is contained in:
王炜翔 2025-02-01 22:36:25 +08:00
parent fe94ebaadc
commit f40c0453eb
2 changed files with 91 additions and 7 deletions

View File

@ -8,23 +8,107 @@ namespace asg_form.Controllers
{ {
public class BlackDB public class BlackDB
{ {
public int id { get; set; } public string id { get; set; }
public string user_name { 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] [ApiController]
public class BlackController : ControllerBase public class BlackController : ControllerBase
{ {
[Route("api/v1/blackTable")]
[HttpGet] /// <summary>
public async Task<ActionResult<object>> blackAdd ([FromQuery] string userName) /// 增加信息
/// </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")) 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 = "无权访问" }); 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(); TestDbContext sub = new TestDbContext();
return Ok(new { code = 200, message = "" }); return Ok(new { code = 200, message = "" });

View File

@ -14,7 +14,7 @@ namespace asg_form.Controllers
{ {
[ApiController]
public class excel : ControllerBase public class excel : ControllerBase
{ {