11
This commit is contained in:
		
							parent
							
								
									4eec251481
								
							
						
					
					
						commit
						1da5474826
					
				@ -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]
 | 
				
			||||||
 | 
				
			|||||||
@ -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