1
This commit is contained in:
parent
ca580b86e8
commit
91cede6f49
@ -290,6 +290,7 @@ namespace asg_form.Controllers
|
||||
public DbSet<menuDB> mainMenu { get; set; }
|
||||
public DbSet<capData> T_captcha_check { get; set; }
|
||||
public DbSet<BlackDB> T_blacks { get; set; }
|
||||
public DbSet<FileDB> T_Audit { get; set; }
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
string connStr = @"Host=localhost;Port=2345;Database=asg;Username=postgres;Password=luolan12323;";
|
||||
|
176
asg_form/Controllers/auditAndFilingController.cs
Normal file
176
asg_form/Controllers/auditAndFilingController.cs
Normal file
@ -0,0 +1,176 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
|
||||
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 biz_type { get; set; }
|
||||
public int budget_id { get; set; }
|
||||
public string start_time { get; set; }
|
||||
public decimal budget_money { 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; }
|
||||
public string description { get; set; }
|
||||
public string reason { get; set; }
|
||||
public string supplementary_info { get; set; }
|
||||
public string status { get; set; }
|
||||
}
|
||||
|
||||
public class FileFront
|
||||
{
|
||||
public string projName { get; set; }
|
||||
public string projNo { get; set; }
|
||||
public string budgetUse { get; set; }
|
||||
public string budgetName { get; set; }
|
||||
public string bizType { get; set; }
|
||||
public int budgetId { get; set; }
|
||||
public string startTime { get; set; }
|
||||
public decimal budgetMoney { get; set; }
|
||||
public string startPerson { get; set; }
|
||||
public string nowAuthPerson { get; set; }
|
||||
public int nowAuthPersonId { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string description { get; set; }
|
||||
public string reason { get; set; }
|
||||
public string supplementaryInfo { get; set; }
|
||||
public string status { get; set; }
|
||||
|
||||
}
|
||||
public class auditAndFilingController : ControllerBase
|
||||
{
|
||||
private readonly RoleManager<Role> roleManager;
|
||||
private readonly UserManager<User> userManager;
|
||||
public auditAndFilingController(
|
||||
RoleManager<Role> roleManager, UserManager<User> userManager)
|
||||
{
|
||||
this.roleManager = roleManager;
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增/修改审批
|
||||
/// </summary>
|
||||
/// <param name="auditinfo"></param>
|
||||
/// <returns></returns>
|
||||
[Route("api/v1/admin/AuditPost")]
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<object>> auditPost([FromBody] FileFront auditinfo)
|
||||
{
|
||||
|
||||
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.AsQueryable();
|
||||
if (query.Any(n => n.id == auditinfo.Id))
|
||||
{
|
||||
var au = query.FirstOrDefault(n => n.id == auditinfo.Id);
|
||||
au.proj_no = auditinfo.projNo;
|
||||
au.proj_name = auditinfo.projName;
|
||||
au.budget_use = auditinfo.budgetUse;
|
||||
au.status = auditinfo.status;
|
||||
au.budget_name = auditinfo.budgetName;
|
||||
au.biz_type = auditinfo.bizType;
|
||||
au.budget_id = auditinfo.budgetId;
|
||||
au.start_time = auditinfo.startTime;
|
||||
au.budget_money = auditinfo.budgetMoney;
|
||||
au.now_auth_person = auditinfo.nowAuthPerson;
|
||||
au.now_auth_person_id = auditinfo.nowAuthPersonId;
|
||||
au.supplementary_info = auditinfo.supplementaryInfo;
|
||||
au.description = auditinfo.description;
|
||||
au.reason = auditinfo.reason;
|
||||
sub.SaveChanges();
|
||||
return Ok(new { code = 200, message = "成功修改" });
|
||||
}
|
||||
else
|
||||
{
|
||||
var newAudit = new FileDB
|
||||
{
|
||||
id = auditinfo.Id,
|
||||
proj_no = auditinfo.projNo,
|
||||
proj_name = auditinfo.projName,
|
||||
budget_use = auditinfo.budgetUse,
|
||||
status = auditinfo.status,
|
||||
budget_name = auditinfo.budgetName,
|
||||
biz_type = auditinfo.bizType,
|
||||
budget_id = auditinfo.budgetId,
|
||||
start_time = auditinfo.startTime,
|
||||
budget_money = auditinfo.budgetMoney,
|
||||
now_auth_person = auditinfo.nowAuthPerson,
|
||||
now_auth_person_id = auditinfo.nowAuthPersonId,
|
||||
supplementary_info = auditinfo.supplementaryInfo,
|
||||
description = auditinfo.description,
|
||||
reason = auditinfo.reason
|
||||
};
|
||||
|
||||
sub.T_Audit.Add(newAudit);
|
||||
sub.SaveChanges();
|
||||
return Ok(new { code = 200, message = "成功新增" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询审批
|
||||
/// </summary>
|
||||
[Route("api/v1/admin/AuditFind")]
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<object>> 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);
|
||||
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
|
||||
.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));
|
||||
if (archive == "1")
|
||||
{
|
||||
var rows = query
|
||||
.Skip((page - 1) * limit)
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
int total = query.Count();
|
||||
var data = new
|
||||
{
|
||||
rows = query,
|
||||
total = total,
|
||||
};
|
||||
return Ok(new { code = 200, message = "", data });
|
||||
}
|
||||
else
|
||||
{
|
||||
var rows = query
|
||||
.Where(n => n.now_auth_person_id == (int)(user.Id))
|
||||
.Skip((page - 1) * limit)
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
int total = query.Count();
|
||||
var data = new
|
||||
{
|
||||
rows = query,
|
||||
total = total,
|
||||
};
|
||||
return Ok(new { code = 200, message = "", data });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -70,7 +70,7 @@ namespace asg_form.Controllers
|
||||
query = query.Where(n => n.Type == type);
|
||||
}
|
||||
|
||||
return query.OrderByDescending(a => a.Id).ToList();
|
||||
return query.OrderBy(a => a.Id).ToList();
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user