This commit is contained in:
王炜翔 2024-11-11 08:58:59 +08:00
parent e0d60f249e
commit ca580b86e8
2 changed files with 19 additions and 6 deletions

View File

@ -104,7 +104,6 @@ using(TestDbContext db=new TestDbContext()){
[Route("api/v1/admin/config/all")]
[HttpGet]
[Authorize]
public async Task<ActionResult<object>> config_get_all(string msg="null",short page=1, short limit = 10)
{

View File

@ -117,12 +117,19 @@ namespace asg_form.Controllers
bool a = await userManager.IsInRoleAsync(user, "admin");
if (a)
{
try
{
TestDbContext ctx = new TestDbContext();
await ctx.news.AddAsync(new T_news { Title = req_News.Title, msg = req_News.msg,Type=req_News.Type, FormName = user.UserName ,time=DateTime.Now});
await ctx.SaveChangesAsync();
ctx.news.Add(new T_news { Title = req_News.Title, msg = req_News.msg,Type=req_News.Type, FormName = user.UserName ,time=DateTime.Now.ToString()});
ctx.SaveChanges();
return "ok!";
}
catch (Exception ex)
{
return Ok(new { code = 500, message = "服务器错误", ex });
}
}
else
{
return "无权访问";
@ -149,6 +156,8 @@ namespace asg_form.Controllers
if (a)
{
using (TestDbContext ctx = new TestDbContext())
{
try
{
var qwq= await ctx.news.FindAsync(newsid);
if (qwq == null)
@ -159,7 +168,12 @@ namespace asg_form.Controllers
qwq.Title=req_News.Title;
qwq.FormName = user.UserName;
qwq.Type = req_News.Type;
await ctx.SaveChangesAsync();
ctx.SaveChanges();
}
catch (Exception ex)
{
return Ok(new { code = 500, message = "服务器错误", ex });
}
}
@ -184,7 +198,7 @@ public class T_news
public long Id { get; set; }
public string Title { get; set; }
public string FormName { get; set; }
public DateTime? time { get; set; }
public string? time { get; set; }
public string msg { get; set; }
public string Type { get; set; }