This commit is contained in:
王炜翔 2024-11-12 21:57:32 +08:00
parent 8ba69aa37e
commit d8def7dd67

View File

@ -4,6 +4,9 @@ using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
using Manganese.Array;
using Microsoft.EntityFrameworkCore;
using AsmResolver.DotNet.Resources;
using SharpCompress.Archives;
using System.Management;
namespace asg_form.Controllers {
public class FileDB
@ -107,7 +110,7 @@ namespace asg_form.Controllers {
proj_no = auditinfo.projNo,
proj_name = auditinfo.projName,
budget_use = auditinfo.budgetUse,
status = "4",
status = auditinfo.status,
budget_name = auditinfo.budgetName,
biz_type = auditinfo.bizType,
budget_id = auditinfo.budgetId,
@ -188,5 +191,37 @@ namespace asg_form.Controllers {
}
}
/// <summary>
/// Id改status为4
/// </summary>
[Route("api/v1/admin/statusChange4")]
[HttpGet]
[Authorize]
public async Task<ActionResult<object>> statusChange4([FromQuery] string Id)
{
string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
var user = await userManager.FindByIdAsync(userId);
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
{
return Ok(new error_mb { code = 401, message = "无权访问" });
}
using (TestDbContext sub = new TestDbContext())
{
var query = sub.T_Audit.FirstOrDefault(n => n.id == Id);
try
{
if(query == null) return Ok(new error_mb { code = 404, message = "没有对应记录" });
query.status = "4";
await sub.SaveChangesAsync();
return Ok(new error_mb { code = 200, message = "对应的status已经更改" });
}
catch (Exception ex)
{
return Ok(new { code = 500, message = "服务器错误", ex });
}
}
}
}
}