Merge branch 'master' of https://dev.azure.com/luolan/ASG%E7%B3%BB%E7%BB%9F/_git/asg_backend
This commit is contained in:
		
						commit
						d7fbbc77e0
					
				@ -309,6 +309,34 @@ namespace asg_form.Controllers
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 设置管理员,需要superadmin
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="userid"></param>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        [Route("api/v1/admin/removeadmin")]
 | 
				
			||||||
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        [Authorize]
 | 
				
			||||||
 | 
					        public async Task<ActionResult<string>> removeadmin(string userid)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var ouser = await userManager.FindByIdAsync(userid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                await userManager.RemoveFromRoleAsync(ouser, "admin");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return Ok(new { message = "用户成功设置为管理员" });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return BadRequest(new error_mb { code = 400, message = "无权访问" });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //管理员设置用户的职位
 | 
					        //管理员设置用户的职位
 | 
				
			||||||
        [Route("api/v1/admin/setop")]
 | 
					        [Route("api/v1/admin/setop")]
 | 
				
			||||||
        [HttpPost]
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
				
			|||||||
@ -8,6 +8,10 @@ using NPOI.OpenXmlFormats.Spreadsheet;
 | 
				
			|||||||
using Castle.Components.DictionaryAdapter;
 | 
					using Castle.Components.DictionaryAdapter;
 | 
				
			||||||
using Flandre.Core.Messaging;
 | 
					using Flandre.Core.Messaging;
 | 
				
			||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
 | 
					using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
 | 
				
			||||||
 | 
					using Flandre.Core.Common;
 | 
				
			||||||
 | 
					using Flandre.Core.Messaging.Segments;
 | 
				
			||||||
 | 
					using static asg_form.Controllers.InviteReferee;
 | 
				
			||||||
 | 
					using Mirai.Net.Data.Shared;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace asg_form.Controllers
 | 
					namespace asg_form.Controllers
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -170,6 +174,21 @@ namespace asg_form.Controllers
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                await testDb.SaveChangesAsync();
 | 
					                await testDb.SaveChangesAsync();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    var message1 = new MessageBuilder().Image(GetPictureData($@"{AppDomain.CurrentDomain.BaseDirectory}loge\{game.belong}\{winteam}.png")).Text($"恭喜战队{winteam}获胜!").Build();
 | 
				
			||||||
 | 
					                    await runbot.runbotr.SendMessageAsync(MessageEnvironment.Channel, "456414070", null, message1, "456414070");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch 
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var message1 = new MessageBuilder().Text($"恭喜战队{winteam}获胜!").Build();
 | 
				
			||||||
 | 
					                    await runbot.runbotr.SendMessageAsync(MessageEnvironment.Channel, "456414070", null, message1, "456414070");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return "ok";
 | 
					                return "ok";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
@ -179,7 +198,14 @@ namespace asg_form.Controllers
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        public byte[] GetPictureData(string imagePath)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            FileStream fs = new FileStream(imagePath, FileMode.Open);
 | 
				
			||||||
 | 
					            byte[] byteData = new byte[fs.Length];
 | 
				
			||||||
 | 
					            fs.Read(byteData, 0, byteData.Length);
 | 
				
			||||||
 | 
					            fs.Close();
 | 
				
			||||||
 | 
					            return byteData;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 删除竞猜比赛
 | 
					        /// 删除竞猜比赛
 | 
				
			||||||
 | 
				
			|||||||
@ -98,30 +98,6 @@ namespace asg_form
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Command]
 | 
					 | 
				
			||||||
        public string 近期赛程1()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            try
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                TestDbContext testDb = new TestDbContext();
 | 
					 | 
				
			||||||
                int q = testDb.team_Games.Count();
 | 
					 | 
				
			||||||
                var t = (DateTime.Now);
 | 
					 | 
				
			||||||
                var a = testDb.team_Games.Where(a => string.Compare(a.opentime, t.ToString()) >= 0).Take(7);
 | 
					 | 
				
			||||||
                string msg = "";
 | 
					 | 
				
			||||||
                foreach (var b in a)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    msg = $"{msg}\r\n{b.team1_name} VS {b.team2_name}\r\n时间:{b.opentime.ToString()}";
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                return msg;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            catch
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                return "出现错误";
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Command]
 | 
					        [Command]
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										14
									
								
								asg_form/return.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								asg_form/return.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					namespace asg_form
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class TReturn
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public int Code {  get; set; }
 | 
				
			||||||
 | 
					        public object Msg {  get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public class TReturn_total
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public int Total { get; set; }
 | 
				
			||||||
 | 
					        public object Msg { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user