From b2ec2819a9bd51c70743e08c168612ae08f72217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=82=9C=E7=BF=94?= <2307953404@qq.com> Date: Mon, 11 Nov 2024 16:44:05 +0800 Subject: [PATCH] q --- .../Controllers/auditAndFilingController.cs | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/asg_form/Controllers/auditAndFilingController.cs b/asg_form/Controllers/auditAndFilingController.cs index c295d30..7b483cd 100644 --- a/asg_form/Controllers/auditAndFilingController.cs +++ b/asg_form/Controllers/auditAndFilingController.cs @@ -2,18 +2,20 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using System.Security.Claims; +using Manganese.Array; namespace asg_form.Controllers { public class FileDB { public string proj_name { get; set; } public string proj_no { get; set; } - public string budget_use { get; set; } - public string budget_name { get; set; } + public string? budget_use { get; set; } + public string? budget_name { get; set; } public string biz_type { get; set; } - public int budget_id { get; set; } + public int? budget_id { get; set; } public string start_time { get; set; } public decimal budget_money { get; set; } + public int start_person_id { get; set; } public string start_person { get; set; } public string now_auth_person { get; set; } public int now_auth_person_id { get; set; } @@ -34,6 +36,7 @@ namespace asg_form.Controllers { public int budgetId { get; set; } public string startTime { get; set; } public decimal budgetMoney { get; set; } + public int startPersonId { get; set; } public string startPerson { get; set; } public string nowAuthPerson { get; set; } public int nowAuthPersonId { get; set; } @@ -90,6 +93,7 @@ namespace asg_form.Controllers { au.supplementary_info = auditinfo.supplementaryInfo; au.description = auditinfo.description; au.reason = auditinfo.reason; + au.start_person_id = auditinfo.startPersonId; sub.SaveChanges(); return Ok(new { code = 200, message = "成功修改" }); } @@ -111,7 +115,8 @@ namespace asg_form.Controllers { now_auth_person_id = auditinfo.nowAuthPersonId, supplementary_info = auditinfo.supplementaryInfo, description = auditinfo.description, - reason = auditinfo.reason + reason = auditinfo.reason, + start_person_id = auditinfo.startPersonId, }; sub.T_Audit.Add(newAudit); @@ -127,7 +132,7 @@ namespace asg_form.Controllers { [Route("api/v1/admin/AuditFind")] [HttpGet] [Authorize] - public async Task> auditFind([FromQuery] string archive,string projName,string projNo,string bizType,string startPerson,string budgetUse, short page = 1, short limit = 10) + public async Task> auditFind([FromQuery] string archive="",string projName = "", string projNo = "", string bizType = "", string startPerson = "", string budgetUse = "", short page = 1, short limit = 10) { string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; var user = await userManager.FindByIdAsync(userId); @@ -138,8 +143,11 @@ namespace asg_form.Controllers { } using (TestDbContext sub = new TestDbContext()) { + try + { var query = sub.T_Audit - .Where(n => n.proj_name.Contains(projName) || n.proj_no.Contains(projNo) || n.biz_type.Contains(bizType) || n.start_person.Contains(startPerson) || n.budget_use.Contains(budgetUse)); + .Where(n => n.proj_name.Contains(projName) || n.proj_no.Contains(projNo) || n.biz_type.Contains(bizType) || n.start_person.Contains(startPerson) || n.budget_use.Contains(budgetUse)).AsQueryable(); + if (archive == "1") { var rows = query @@ -149,26 +157,31 @@ namespace asg_form.Controllers { int total = query.Count(); var data = new { - rows = query, - total = total, + rows, + total, }; return Ok(new { code = 200, message = "", data }); } else { var rows = query - .Where(n => n.now_auth_person_id == (int)(user.Id)) + .Where(n =>n.now_auth_person_id ==(int)user.Id) .Skip((page - 1) * limit) .Take(limit) .ToList(); - int total = query.Count(); + int total = query.Count(); var data = new { - rows = query, - total = total, + rows, + total, }; return Ok(new { code = 200, message = "", data }); } + } + catch (Exception ex) + { + return Ok(new { code = 500, message = "服务器错误", ex }); + } } }