diff --git a/asg_form/Controllers/BlackController.cs b/asg_form/Controllers/BlackController.cs index 811bc41..42f8fc6 100644 --- a/asg_form/Controllers/BlackController.cs +++ b/asg_form/Controllers/BlackController.cs @@ -8,23 +8,107 @@ namespace asg_form.Controllers { public class BlackDB { - public int id { get; set; } - public string user_name { get; set; } - //..... + 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 { - [Route("api/v1/blackTable")] - [HttpGet] - public async Task> blackAdd ([FromQuery] string userName) + + /// + /// 增加信息 + /// + /// + /// + [Route("api/v1/blackTable/Add")] + [HttpPost] + public async Task> 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); + } + } + } + + /// + /// 更新信息 + /// + /// + /// + [Route("api/v1/blackTable/Update")] + [HttpPost] + public async Task> 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 = "" }); + } + + /// + /// 删除信息 + /// + /// + /// + [Route("api/v1/blackTable/Del")] + [HttpGet] + public async Task> 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 = "" }); diff --git a/asg_form/Controllers/excel.cs b/asg_form/Controllers/excel.cs index 5b4c285..659b821 100644 --- a/asg_form/Controllers/excel.cs +++ b/asg_form/Controllers/excel.cs @@ -14,7 +14,7 @@ namespace asg_form.Controllers { - [ApiController] + public class excel : ControllerBase {