123
This commit is contained in:
parent
74cb8ff01e
commit
372b2760ce
@ -196,5 +196,46 @@ namespace asg_form.Controllers.Budget
|
||||
public int UsePersonId { get; set; }
|
||||
}
|
||||
|
||||
[Route("api/v1/admin/countBudgetTotal")]
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<object>> cntBg(int sourceEventId)
|
||||
{
|
||||
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
||||
{
|
||||
return Ok(new { code = 401, message = "您没有权限" });
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using (var db = new TestDbContext())
|
||||
{
|
||||
var budgetTotals = await db.budgetDetails
|
||||
.Where(b => b.source_event_id == sourceEventId)
|
||||
.GroupBy(b => new
|
||||
{
|
||||
b.source_event_id,
|
||||
b.source_event_name
|
||||
})
|
||||
.Select(g => new
|
||||
{
|
||||
sourceEventId = g.Key.source_event_id,
|
||||
sourceEventName = g.Key.source_event_name,
|
||||
budgetTotalMoney = g.Sum(b => b.budget_money)
|
||||
})
|
||||
.ToListAsync();
|
||||
return Ok(new
|
||||
{
|
||||
code = 200,
|
||||
data = budgetTotals
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Ok(new { code = 500, message = "服务器错误", details = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace asg_form.Controllers
|
||||
}
|
||||
|
||||
}
|
||||
return BadRequest(new error_mb { code = 400, message = "你没有管理员呢~" });
|
||||
return Ok(new error_mb { code = 400, message = "你没有管理员呢~" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -11,6 +11,7 @@ using Microsoft.EntityFrameworkCore.DataEncryption.Providers;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using static asg_form.Controllers.Budget.BgCountController;
|
||||
|
||||
namespace asg_form.Controllers
|
||||
{
|
||||
@ -243,6 +244,8 @@ namespace asg_form.Controllers
|
||||
public DbSet<ComformDB> T_Comform { get; set; }
|
||||
public DbSet<BgDB> budgetDetails { get; set; }
|
||||
|
||||
public DbSet<tBg> totBg { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
string connStr = @"Host=localhost;Port=2345;Database=asg;Username=postgres;Password=luolan12323;";
|
||||
|
Loading…
x
Reference in New Issue
Block a user