diff --git a/asg_form/Controllers/auditAndFilingController.cs b/asg_form/Controllers/auditAndFilingController.cs index 7b483cd..edc0394 100644 --- a/asg_form/Controllers/auditAndFilingController.cs +++ b/asg_form/Controllers/auditAndFilingController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using System.Security.Claims; using Manganese.Array; +using Microsoft.EntityFrameworkCore; namespace asg_form.Controllers { public class FileDB @@ -15,8 +16,8 @@ namespace asg_form.Controllers { 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 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; } public string id { get; set; } @@ -36,8 +37,8 @@ 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 int? startPersonId { get; set; } + public string? startPerson { get; set; } public string nowAuthPerson { get; set; } public int nowAuthPersonId { get; set; } public string Id { get; set; } @@ -94,6 +95,7 @@ namespace asg_form.Controllers { au.description = auditinfo.description; au.reason = auditinfo.reason; au.start_person_id = auditinfo.startPersonId; + au.start_person = auditinfo.startPerson; sub.SaveChanges(); return Ok(new { code = 200, message = "成功修改" }); } @@ -117,6 +119,7 @@ namespace asg_form.Controllers { description = auditinfo.description, reason = auditinfo.reason, start_person_id = auditinfo.startPersonId, + start_person = auditinfo.startPerson, }; sub.T_Audit.Add(newAudit); @@ -132,7 +135,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=null,string projName = null, string projNo = null, string bizType = null, string startPerson = null, string budgetUse = null, short page = 1, short limit = 10) { string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; var user = await userManager.FindByIdAsync(userId); @@ -143,39 +146,39 @@ 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)).AsQueryable(); - + .Where(n => (n.proj_name.Contains(projName)||projName==null) && (n.proj_no.Contains(projNo) || projNo == null) && (n.biz_type.Contains(bizType) || bizType == null) && (n.start_person.Contains(startPerson)|| startPerson == null) && (n.budget_use.Contains(budgetUse)|| budgetUse == null)) + .AsQueryable(); + try + { if (archive == "1") { - var rows = query + var rows = await query .Skip((page - 1) * limit) .Take(limit) - .ToList(); - int total = query.Count(); + .ToListAsync(); + int total = await query.CountAsync(); var data = new { rows, total, }; - return Ok(new { code = 200, message = "", data }); + return Ok(new { code = 200, message = "", data , archive }); } else { - var rows = query - .Where(n =>n.now_auth_person_id ==(int)user.Id) + var rows =await query + .Where(n => n.now_auth_person_id ==(int)user.Id ) .Skip((page - 1) * limit) .Take(limit) - .ToList(); - int total = query.Count(); + .ToListAsync(); + int total = await query.Where(n => n.now_auth_person_id == (int)user.Id).CountAsync(); var data = new { rows, total, }; - return Ok(new { code = 200, message = "", data }); + return Ok(new { code = 200, message = "", data , archive }); } } catch (Exception ex) diff --git a/asg_form/Controllers/schedule.cs b/asg_form/Controllers/schedule.cs index 83026bf..5a2fa24 100644 --- a/asg_form/Controllers/schedule.cs +++ b/asg_form/Controllers/schedule.cs @@ -383,12 +383,13 @@ namespace asg_form.Controllers string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; TestDbContext test = new TestDbContext(); - var team = test.schlogs.Include(a=>a.team).Where(a=>a.userid==id).ToList(); + var team = test.schlogs.Include(a=>a.team).Where(a=>a.userid==id).Take(5).ToList(); foreach(var team_game in team) { team_game.team.logs = null; } - return team; + + return team ; }