This commit is contained in:
王炜翔 2024-10-19 21:53:56 +08:00
parent 814624c36f
commit 291bd4a49a

View File

@ -14,6 +14,11 @@ using System.Net.NetworkInformation;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
using NPOI.SS.Formula.Functions;
using Microsoft.EntityFrameworkCore;
using Flandre.Core.Models;
using Mirai.Net.Sessions.Http.Managers;
using Mirai.Net.Utils.Scaffolds;
using Flandre.Core.Messaging.Segments;
using Flandre.Core.Messaging;
namespace asg_form.Controllers
{
@ -44,6 +49,7 @@ namespace asg_form.Controllers
public string TaskName { get; set; }
public string TaskDescription { get; set; }
public long Money { get; set; }
public string? atuserqq { get; set; }
}
public class AssignmentController : ControllerBase
@ -68,6 +74,9 @@ namespace asg_form.Controllers
}
var dateString = DateTime.Now;
using (TestDbContext sub = new TestDbContext())
{
int wp = -2;
try
{
var task = new TaskDB
{
@ -85,8 +94,21 @@ namespace asg_form.Controllers
};
sub.T_Task.Add(task);
await sub.SaveChangesAsync();
wp = -1;
string msg = $"<ASG机器人通知> 尊敬的 {taskinfo.Chinaname}{taskinfo.CreatePerson}为您下了一个任务,请及时上后台查看!";
string qqgroup = "925510646";
wp = 0;
var message = new MessageBuilder().Add(new AtSegment(taskinfo.atuserqq)).Text(msg).Build();
await runbot.runbotr.SendMessageAsync(MessageEnvironment.Channel, qqgroup, null, message, qqgroup);
return Ok(new error_mb { code = 200, message = "新建任务成功" });
}
catch (Exception ex)
{
return Ok(new { code = 500, message = "服务器错误", details = ex ,wp});
}
}
}