From 291bd4a49aec6e74fe1d00d5df1b98fa4fd74a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=82=9C=E7=BF=94?= <2307953404@qq.com> Date: Sat, 19 Oct 2024 21:53:56 +0800 Subject: [PATCH] 1 --- asg_form/Controllers/AssignmentController.cs | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/asg_form/Controllers/AssignmentController.cs b/asg_form/Controllers/AssignmentController.cs index 195c6e8..54b1251 100644 --- a/asg_form/Controllers/AssignmentController.cs +++ b/asg_form/Controllers/AssignmentController.cs @@ -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 @@ -69,6 +75,9 @@ namespace asg_form.Controllers var dateString = DateTime.Now; using (TestDbContext sub = new TestDbContext()) { + int wp = -2; + try + { var task = new TaskDB { chinaname = taskinfo.Chinaname, @@ -85,7 +94,20 @@ namespace asg_form.Controllers }; sub.T_Task.Add(task); await sub.SaveChangesAsync(); - return Ok(new error_mb { code = 200, message = "新建任务成功" }); + wp = -1; + string msg = $" 尊敬的 {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}); + } + } }