1234
This commit is contained in:
parent
7cfcedd5f5
commit
6fb8f536d7
@ -79,12 +79,12 @@ namespace asg_form.Controllers.Budget
|
||||
budget_used = msg.budgetUsed,
|
||||
source_event_name = msg.sourceEventName,
|
||||
source_event_id = msg.sourceEventId,
|
||||
change_time = dateString,
|
||||
|
||||
used_event_name = msg.usedEventName,
|
||||
used_event_id = msg.usedEventId,
|
||||
use_status = "0",
|
||||
update_person = msg.updatePerson,
|
||||
update_time = null,
|
||||
update_time = dateString,
|
||||
};
|
||||
sub.budgetDetails.Add(budget);
|
||||
await sub.SaveChangesAsync();
|
||||
@ -123,7 +123,7 @@ namespace asg_form.Controllers.Budget
|
||||
budget.used_event_name = msg.usedEventName;
|
||||
budget.used_event_id = msg.usedEventId;
|
||||
budget.update_person = msg.updatePerson;
|
||||
budget.update_time = currentTime.ToString();
|
||||
budget.change_time = currentTime.ToString();
|
||||
await sub.SaveChangesAsync();
|
||||
return Ok(new error_mb { code = 200, message = "更新预算成功" });
|
||||
}
|
||||
@ -178,7 +178,7 @@ namespace asg_form.Controllers.Budget
|
||||
budget.use_status = "1";
|
||||
budget.use_person = request.UsePerson;
|
||||
budget.use_person_id = request.UsePersonId;
|
||||
budget.update_time = DateTime.Now.ToString();
|
||||
budget.change_time = DateTime.Now.ToString();
|
||||
await db.SaveChangesAsync();
|
||||
return Ok(new { code = 200, message = "更新使用情况成功" });
|
||||
}
|
||||
@ -238,5 +238,31 @@ namespace asg_form.Controllers.Budget
|
||||
}
|
||||
}
|
||||
|
||||
[Route("api/v1/admin/DelBg")]
|
||||
[HttpDelete]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<object>> DelBg([FromQuery] int id)
|
||||
{
|
||||
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
||||
{
|
||||
return Ok(new error_mb { code = 401, message = "无权访问" });
|
||||
}
|
||||
try
|
||||
{
|
||||
using (TestDbContext sub = new TestDbContext())
|
||||
{
|
||||
var f = sub.budgetDetails.FindAsync(id);
|
||||
if (f == null ) return Ok(new error_mb { code = 404, message = "没有目标元素" });
|
||||
sub.budgetDetails.Remove(sub.budgetDetails.Find(id));
|
||||
await sub.SaveChangesAsync();
|
||||
return Ok(new error_mb { code = 200, message = "成功删除" });
|
||||
}
|
||||
}catch (Exception ex)
|
||||
{
|
||||
return Ok(new { code = 500, message="服务器错误", error = ex.Message });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace asg_form.Controllers;
|
||||
|
||||
@ -103,7 +105,7 @@ using(TestDbContext db=new TestDbContext()){
|
||||
[Route("api/v1/admin/config/all")]
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<object>> config_get_all(short page, short page_long = 10)
|
||||
public async Task<ActionResult<object>> config_get_all(short page, short limit = 10)
|
||||
{
|
||||
|
||||
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
||||
@ -112,14 +114,18 @@ using(TestDbContext db=new TestDbContext()){
|
||||
}
|
||||
using (TestDbContext db = new TestDbContext())
|
||||
{
|
||||
int a = db.T_config.Count();
|
||||
int b = page_long * page;
|
||||
if (page_long * page > a)
|
||||
var query = db.T_config.AsQueryable();
|
||||
var TotalRecords = await query.CountAsync();
|
||||
var config =await query
|
||||
.Skip((page - 1) * limit)
|
||||
.Take(limit)
|
||||
.ToListAsync();
|
||||
var result = new
|
||||
{
|
||||
b = a;
|
||||
}
|
||||
object config = db.T_config.Skip(page_long * page - page_long).Take(page_long).ToList();
|
||||
return Ok(config);
|
||||
rows = config,
|
||||
total = TotalRecords,
|
||||
};
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user