isRuleChange

This commit is contained in:
王炜翔 2025-02-09 20:59:04 +08:00
parent 3a94e926c7
commit c2908c982b

View File

@ -74,7 +74,7 @@ namespace asg_form.Controllers
[Authorize]
[Route("api/v1/admin/Events")]
[HttpPut]
public async Task<ActionResult<List<T_events>>> putevent(int eventId, [FromBody] T_events_debug events)
public async Task<ActionResult<List<T_events>>> putevent(int eventId, string isRuleChange="0", [FromBody] T_events_debug events)
{
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
@ -90,6 +90,8 @@ namespace asg_form.Controllers
eve.status = events.status;
eve.config = events.config;
if (isRuleChange == "1")
{
if (!string.IsNullOrEmpty(events.rule_markdown))
{
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "doc", "rule", $"{eve.name}.md");
@ -120,6 +122,7 @@ namespace asg_form.Controllers
await testDb.SaveChangesAsync();
return Ok(eve);
}
}
return Ok(new error_mb { code = 401, message = "无权访问" });
}