diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 25f43e7..0bfc8aa 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -19,7 +19,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/asg_form/Controllers/Champion.cs b/asg_form/Controllers/Champion.cs index 1f7acfc..7b5dc4c 100644 --- a/asg_form/Controllers/Champion.cs +++ b/asg_form/Controllers/Champion.cs @@ -1,5 +1,4 @@ -using asg_form.Model; -using Manganese.Array; +using Manganese.Array; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -111,7 +110,7 @@ namespace asg_form.Controllers { public long Id { get; set; } public form form { get; set; } - public T_events events { get; set; } + public Events.T_events events { get; set; } public string msg { get; set; } } diff --git a/asg_form/Controllers/Com.cs b/asg_form/Controllers/Com.cs index 09981f5..126017b 100644 --- a/asg_form/Controllers/Com.cs +++ b/asg_form/Controllers/Com.cs @@ -1,4 +1,5 @@ using asg_form.Migrations; +using Manganese.Text; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -36,7 +37,7 @@ namespace asg_form.Controllers { TestDbContext testDb = new TestDbContext(); string chinaname = user.chinaname; - var teamgame = testDb.team_Games.Where(a => a.commentary.IndexOf(chinaname) >= 0).Select(a => new { a.id, a.team1_name, a.team2_name, a.bilibiliuri, a.commentary, a.referee ,a.opentime,a.team1_piaoshu,a.team2_piaoshu}).OrderByDescending(a => a.opentime).ToList(); + var teamgame = testDb.team_Games.Where(a => a.commentary.IndexOf(chinaname) >= 0).Select(a => new { a.id, a.team1_name, a.team2_name, a.bilibiliuri, a.commentary, a.referee ,a.opentime}).ToList(); return JsonConvert.SerializeObject(teamgame); } @@ -55,25 +56,16 @@ namespace asg_form.Controllers var user = await userManager.FindByIdAsync(id); if (user.officium == "Commentator") { + TestDbContext testDb = new TestDbContext(); string chinaname = user.chinaname; var teamgame = await testDb.team_Games.FirstAsync(a => a.id == gameid); - if (teamgame.commentary == "待公布") - { - List strings = new List - { - chinaname - }; - teamgame.commentary = string.Join(",", strings.ToArray()); - await testDb.SaveChangesAsync(); - } - else - { - var team_game = teamgame.commentary.Split(",").ToList(); - team_game.Add(chinaname); - teamgame.commentary = string.Join(",", team_game.ToArray()); - await testDb.SaveChangesAsync(); - } + var com = JsonConvert.DeserializeObject>(teamgame.commentary); + com.Add(new com_json { id = id.ToInt32(), chinaname = chinaname }); + teamgame.commentary = JsonConvert.SerializeObject(com); + await testDb.SaveChangesAsync(); + user.Integral = user.Integral+10; + await userManager.UpdateAsync(user); try { await MessageManager.SendGroupMessageAsync("870248618", $"解说:\r\n{chinaname}\r\n选择了比赛:\r\n{teamgame.team1_name} VS {teamgame.team2_name}"); @@ -87,6 +79,21 @@ namespace asg_form.Controllers return BadRequest(new error_mb { code = 400, message = $"你是{user.officium},你不是解说,无法操作" }); } + public class com_json + { + /// + /// + /// + public int id { get; set; } + /// + /// 老恐龙 + /// + public string chinaname { get; set; } + } + + + + /// /// 取消选班 @@ -105,14 +112,17 @@ namespace asg_form.Controllers TestDbContext testDb = new TestDbContext(); string chinaname = user.chinaname; var teamgame = await testDb.team_Games.FirstAsync(a => a.id == gameid); - var team_game = teamgame.commentary.Split(",").ToList(); - team_game.Remove(chinaname); - teamgame.commentary = string.Join(",", team_game.ToArray()); - if (teamgame.commentary=="") - { - teamgame.commentary = "待公布"; + var com = JsonConvert.DeserializeObject>(teamgame.commentary); + com.Remove(com.First(a => a.id == id.ToInt32())); + try{ + user.Integral = cut_value((long)user.Integral); + await userManager.UpdateAsync(user); } - + catch{ + return BadRequest(new error_mb { code = 400, message = $"你的金钱无法满足你完成以下操作" }); + + } + teamgame.commentary = JsonConvert.SerializeObject(com); await testDb.SaveChangesAsync(); return "成功"; } @@ -125,12 +135,34 @@ namespace asg_form.Controllers public async Task> Search() { TestDbContext testDb = new TestDbContext(); - var team= await testDb.team_Games.Select(a => new {a.id,a.commentary,a.opentime,a.team1_name,a.team2_name,a.belong}).ToListAsync(); + var team = await testDb.team_Games.Select(a => new { a.id, a.commentary, a.opentime, a.team1_name, a.team2_name, a.belong }).ToListAsync(); var team1 = team.Where(a => a.commentary.Split(",").Length <= 1); - return JsonConvert.SerializeObject(team1); + return JsonConvert.SerializeObject(team1); } + [Route("api/v1/com/Integral/ranking")] + [HttpPost] + [Authorize] + [ResponseCache(Duration = 60)] + public async Task> ranking() + { + object user= await userManager.Users.OrderByDescending(a => a.Integral).Select(a=>new{a.Id,a.chinaname,a.Integral}).Take(10).ToListAsync(); + return user; + } + + public long cut_value(long value) + { + long _value = value; + value = value - 10; + if (value < 0) + { + throw new ArgumentException("你已经没钱啦!"); + + } + return value; + } + [Route("api/v1/com/")] [HttpGet] [Authorize] @@ -141,8 +173,8 @@ namespace asg_form.Controllers if (user.officium == "Commentator") { var chinaname = user.chinaname; - TestDbContext testDb=new TestDbContext(); - int a= await testDb.team_Games.CountAsync(a => a.commentary.IndexOf(chinaname) >= 0); + TestDbContext testDb = new TestDbContext(); + int a = await testDb.team_Games.CountAsync(a => a.commentary.IndexOf(id) >= 0); return a; } return BadRequest(new error_mb { code = 400, message = $"你是{user.officium},你不是解说,无法操作" }); @@ -150,5 +182,5 @@ namespace asg_form.Controllers } } - + diff --git a/asg_form/Controllers/Dbset.cs b/asg_form/Controllers/Dbset.cs index 90436c5..022cff8 100644 --- a/asg_form/Controllers/Dbset.cs +++ b/asg_form/Controllers/Dbset.cs @@ -1,5 +1,5 @@  -using asg_form.Model; +using asg_form.Controllers.Store; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.DataEncryption; @@ -35,7 +35,7 @@ namespace asg_form.Controllers builder.Property(e => e.team_password).IsRequired(); builder.Property(e => e.time).IsRequired(); builder.Property(e => e.piaoshu).IsRequired(); - builder.HasOne(c => c.events).WithMany(a => a.forms).IsRequired(); + builder.HasOne(c => c.events).WithMany(a => a.forms).IsRequired(); } } @@ -52,7 +52,32 @@ namespace asg_form.Controllers } } - + public static class QueryableExtensions + { + public static IQueryable Paginate(this IQueryable query, int pageIndex, int pageSize) + { + return query.Skip(pageIndex * pageSize).Take(pageSize); + } + } + class STOREConfig : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("T_Storeinfo"); + builder.HasOne(c => c.Store).WithMany(a => a.buyer).IsRequired(); + + } + } + class STORConfig : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("T_Store"); + + + } + } + class newsConfig : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) @@ -103,9 +128,9 @@ namespace asg_form.Controllers builder.HasOne(e => e.team).WithMany(o=>o.logs).IsRequired(); } } - class EventsConfig : IEntityTypeConfiguration + class EventsConfig : IEntityTypeConfiguration { - public void Configure(EntityTypeBuilder builder) + public void Configure(EntityTypeBuilder builder) { builder.ToTable("F_events"); builder.Property(e => e.Id).IsRequired(); @@ -145,10 +170,22 @@ namespace asg_form.Controllers } } + class configConfig : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("T_Config"); + builder.Property(e => e.Id).IsRequired(); + builder.Property(a => a.Title); + builder.Property(a => a.msg); + builder.Property(e => e.Substance); + + + } + } - class TestDbContext : DbContext { @@ -159,11 +196,15 @@ namespace asg_form.Controllers public DbSet blogs { get; set; } public DbSet schlogs { get; set; } public DbSet team_Games { get; set; } - public DbSet events { get; set; } + public DbSet events { get; set; } public DbSet Champions { get; set; } public DbSet com_Forms { get; set; } public DbSet T_Friends { get; set; } - + public DbSet T_Store { get; set; } + public DbSet T_Storeinfo { get; set; } + public DbSet T_config { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { string connStr = @"Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;TrustServerCertificate=true"; @@ -178,6 +219,7 @@ namespace asg_form.Controllers } + public class IDBcontext : IdentityDbContext { public DbSet users { get; set; } diff --git a/asg_form/Controllers/Events.cs b/asg_form/Controllers/Events.cs index 32dfe37..32d533b 100644 --- a/asg_form/Controllers/Events.cs +++ b/asg_form/Controllers/Events.cs @@ -1,5 +1,4 @@ -using asg_form.Model; -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using System.Security.Claims; @@ -7,8 +6,7 @@ using static asg_form.Controllers.excel; namespace asg_form.Controllers { - - public class Events:ControllerBase + public class Events : ControllerBase { private readonly RoleManager roleManager; private readonly UserManager userManager; @@ -25,16 +23,26 @@ namespace asg_form.Controllers /// /// // [Authorize] - + [Route("api/v1/Events")] [HttpGet] - // [ResponseCache(Duration = 260)] - public async Task>> Getallevent() + // [ResponseCache(Duration = 260)] + public async Task> Getallevent(bool get_poem = false) { TestDbContext testDbContext = new TestDbContext(); - var Event= testDbContext.events.ToList(); - return Event; - + object Event = new object(); + if (get_poem) + { + Event = testDbContext.events.Select(a => new { a.Id, a.is_over, a.opentime, a.name, a.promChart }).ToList(); + + } + else + { + Event = testDbContext.events.Select(a => new { a.Id, a.is_over, a.opentime, a.name }).ToList(); + + } + return Event; + } /// /// 发布新赛事 @@ -43,16 +51,16 @@ namespace asg_form.Controllers [Authorize] [Route("api/v1/admin/Events")] [HttpPost] - public async Task>> Postevent(T_events events, [FromBody]string rule_markdown) + public async Task>> Postevent([FromBody] events_get events) { TestDbContext testDbContext = new TestDbContext(); - await testDbContext.events.AddAsync(new T_events { name = events.name, is_over = events.is_over, opentime = events.opentime ,events_rule_uri= new Uri($"https://124.223.35.239/doc/rule/{events.name}.md") }); + await testDbContext.events.AddAsync(new T_events { name = events.name, is_over = events.is_over, opentime = events.opentime, events_rule_uri = new Uri($"https://124.223.35.239/doc/rule/{events.name}.md") }); System.IO.Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + $"loge/{events.name}"); - System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory+ $"doc/rule/{events.name}.md", rule_markdown); + System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + $"doc/rule/{events.name}.md", events.rule_markdown); await testDbContext.SaveChangesAsync(); - + return Ok("添加成功!"); - + } /// @@ -62,40 +70,40 @@ namespace asg_form.Controllers [Authorize] [Route("api/v1/admin/Events")] [HttpPut] - public async Task>> putevent(string event_name, [FromBody]T_events events) + public async Task>> putevent(string event_name, [FromBody] T_events events) { if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) - { - - TestDbContext testDb=new TestDbContext(); - var eve= testDb.events.FirstOrDefault(a => a.name == event_name); - eve.name=events.name; - eve.opentime=events.opentime; - eve.is_over=events.is_over; + { + + TestDbContext testDb = new TestDbContext(); + var eve = testDb.events.FirstOrDefault(a => a.name == event_name); + eve.name = events.name; + eve.opentime = events.opentime; + eve.is_over = events.is_over; await testDb.SaveChangesAsync(); return Ok(eve); } return BadRequest(new error_mb { code = 400, message = "没管理员改个P!" }); - } + } - /// - /// 删除新赛事 - /// - /// - [Authorize] + /// + /// 删除新赛事 + /// + /// + [Authorize] [Route("api/v1/admin/Events")] [HttpDelete] public async Task>> Delevent(string event_name) { if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) { - TestDbContext test=new TestDbContext(); - var evernt= test.events.FirstOrDefault(a => a.name == event_name); + TestDbContext test = new TestDbContext(); + var evernt = test.events.FirstOrDefault(a => a.name == event_name); test.Remove(evernt); - await test.SaveChangesAsync(); + await test.SaveChangesAsync(); return Ok("删掉了呢"); } else @@ -103,7 +111,7 @@ namespace asg_form.Controllers return BadRequest(new error_mb { code = 400, message = "没P管理员隔着装尼玛呢" }); } - } + } /// /// 修改赛事 @@ -112,7 +120,7 @@ namespace asg_form.Controllers [Authorize] [Route("api/v1/admin/Events_rule")] [HttpDelete] - public async Task>> event_rule(string event_name, [FromBody]string rule_markdown) + public async Task>> event_rule(string event_name, [FromBody] string rule_markdown) { if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) { @@ -129,7 +137,50 @@ namespace asg_form.Controllers } + /// + /// 修改赛程图 + /// + /// + [Authorize] + [Route("api/v1/admin/poem")] + [HttpPost] + public async Task>> event_poem(string event_name, [FromBody] string poem_json) + { + if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + TestDbContext test = new TestDbContext(); + var evernt = test.events.FirstOrDefault(a => a.name == event_name); + evernt.promChart = poem_json; + await test.SaveChangesAsync(); + return Ok("修改了呢"); + } + else + { + return BadRequest(new error_mb { code = 400, message = "没P管理员隔着装尼玛呢" }); + } - - } + } + + + public class T_events + { + public int Id { get; set; } + public string? name { get; set; } + public bool? is_over { get; set; } + public DateTime? opentime { get; set; } + public List
? forms { get; set; } + public Uri? events_rule_uri { get; set; } + public string? promChart { get; set; } + + } + public class events_get + { + public int Id { get; set; } + public string? name { get; set; } + public bool? is_over { get; set; } + public DateTime? opentime { get; set; } + public string rule_markdown { get; set; } + + } + } } diff --git a/asg_form/Controllers/Store/StoreDB.cs b/asg_form/Controllers/Store/StoreDB.cs new file mode 100644 index 0000000..0962414 --- /dev/null +++ b/asg_form/Controllers/Store/StoreDB.cs @@ -0,0 +1,25 @@ +namespace asg_form.Controllers.Store +{ + public class StoreDB + { + public long id { get; set; } + public string Name { get; set; } + public long Price { get; set; } + + public string description { get; set; } + + public string information { get; set; } + public string Type { get; set; } + public List? buyer { get; set; }=new List(); + } + public class StoreinfoDB + { + public long id { get; set; } + public long buyerid { get; set; } + public StoreDB Store { get; set; } + + public bool isVerification { get; set; } + + + } +} diff --git a/asg_form/Controllers/Store/Storehttp.cs b/asg_form/Controllers/Store/Storehttp.cs new file mode 100644 index 0000000..86eb0b4 --- /dev/null +++ b/asg_form/Controllers/Store/Storehttp.cs @@ -0,0 +1,214 @@ +using Masuit.Tools; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using System.Security.Claims; + +namespace asg_form.Controllers.Store +{ + public class Storehttp : ControllerBase + { + private readonly RoleManager roleManager; + private readonly UserManager userManager; + public Storehttp( + RoleManager roleManager, UserManager userManager) + { + + this.roleManager = roleManager; + this.userManager = userManager; + } + + + + [Route("api/v1/admin/Store")] + [HttpPost] + [Authorize] + public async Task> AddStore([FromBody]StoreDB storeinfo) + { + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return BadRequest(new error_mb { code = 400, message = "无权访问" }); + } + using (TestDbContext sb = new TestDbContext()) { + sb.T_Store.Add(storeinfo); + await sb.SaveChangesAsync(); + return Ok(storeinfo); + } + } + [Route("api/v1/admin/Store")] + [HttpDelete] + [Authorize] + public async Task> DelStore(long id) + { + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return BadRequest(new error_mb { code = 400, message = "无权访问" }); + } + using (TestDbContext sb = new TestDbContext()) + { + sb.T_Store.Remove(sb.T_Store.Find(id)); + await sb.SaveChangesAsync(); + return Ok("ok"); + } + } + [Route("api/v1/admin/Store")] + [HttpPut] + [Authorize] + public async Task> putStore([FromBody] StoreDB storeinfo) + { + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return BadRequest(new error_mb { code = 400, message = "无权访问" }); + } + using (TestDbContext sb = new TestDbContext()) + { + var a= await sb.T_Store.FindAsync(storeinfo.id); + a.Name=storeinfo.Name; + a.description=storeinfo.description; + a.information=storeinfo.information; + a.Price=storeinfo.Price; + await sb.SaveChangesAsync(); + return Ok(storeinfo); + } + } + public long cut_value(long value,long money) + { + long _value = value; + value = value - money; + if (value < 0) + { + throw new ArgumentException("你已经没钱啦!"); + + } + return value; + } + [Route("api/v1/Store")] + [HttpGet] + [Authorize] + public async Task> GetStore() + { + + using (TestDbContext sb = new TestDbContext()) + { + var a= sb.T_Store.ToList(); + return Ok(a); + } + } + + [Route("api/v1/Store/Verification")] + [HttpGet] + [Authorize] + public async Task> Verification(long storeinfoid) + { + + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return BadRequest(new error_mb { code = 400, message = "无权访问" }); + } + using (TestDbContext sb = new TestDbContext()) + { + var a = sb.T_Storeinfo.Find(storeinfoid); + a.isVerification = true; + await sb.SaveChangesAsync(); + return Ok(a); + } + } + + + + + /// + /// + /// + /// + /// + /// + /// 是否展示以及核销过的 + /// + [Route("api/v1/admin/Storeinfo")] + [HttpGet] + [Authorize] + public async Task> GetStoreinfo(bool showVerification,long? search_id,int pageindex=0,int pagesize=10) + { + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return BadRequest(new error_mb { code = 400, message = "无权访问" }); + } + using (TestDbContext sb = new TestDbContext()) + { + var a = new all_record(); + IQueryable b; + if (showVerification) + { + b = sb.T_Storeinfo.Include(a=>a.Store); + } + else + { + b = sb.T_Storeinfo.Include(a => a.Store).Where(a => a.isVerification == false); + } + if (search_id == null) + { + a.cout = b.Count(); + a.msg = await b.Paginate(pageindex, pagesize).Select(a => new { a.id, a.buyerid, a.Store.Price, a.Store.description, a.isVerification, a.Store.information, a.Store.Name }).ToListAsync(); + + } + else + { + a.cout = b.Where(a => a.buyerid == search_id).Count(); + a.msg = await b.Where(a => a.buyerid == search_id).Paginate(pageindex, pagesize).Select(a => new { a.id, a.buyerid, a.Store.Price, a.Store.description, a.isVerification, a.Store.information, a.Store.Name }).ToListAsync(); + } + + return Ok(a); + } + } + public record buyreq_record(bool iserror, string msg); + + + public record all_record() + { + public long? cout { get; set; } + public object msg { get; set; } + } + [Route("api/v1/Store/Buy")] + [HttpPost] + [Authorize] + public async Task> BuyStore([FromBody]long[] storeid) + { + string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; + var user = await userManager.FindByIdAsync(id); + + if (user.officium != "Commentator") + { + return BadRequest(new error_mb { code = 400, message = $"你是{user.officium},你不是解说,无法操作" }); + + } + + using (TestDbContext sb = new TestDbContext()) + { + List bureq = new List(); + foreach (var item in storeid) + { + var stort = await sb.T_Store.FindAsync(item); + try + { + user.Integral = cut_value((long)user.Integral, stort.Price); + await userManager.UpdateAsync(user); + await sb.T_Storeinfo.AddAsync(new StoreinfoDB { buyerid = id.ToInt64(), Store = stort }); + await sb.SaveChangesAsync(); + bureq.Add(new buyreq_record(false, $"购买{stort.Name}成功")); + + } + catch + { + bureq.Add(new buyreq_record(true, $"购买失败,因为余额不足")); + + + } + } + + return Ok(bureq); + } + } + } +} diff --git a/asg_form/Controllers/admin.cs b/asg_form/Controllers/admin.cs index 28f7e0d..b0d3372 100644 --- a/asg_form/Controllers/admin.cs +++ b/asg_form/Controllers/admin.cs @@ -21,6 +21,9 @@ using MimeKit; using MailKit.Net.Smtp; using Mirai.Net.Utils.Scaffolds; using Mirai.Net.Sessions.Http.Managers; +using asg_form.Controllers.Store; +using NPOI.SS.Formula.Functions; +using static asg_form.Controllers.Store.Storehttp; namespace asg_form.Controllers { @@ -90,7 +93,17 @@ namespace asg_form.Controllers return Ok("Image file uploaded successfully."); } + [Route("api/v1/admin/dbgu")] + [HttpPost] + public async Task> dbgu() + { + using(TestDbContext db=new TestDbContext()) + { + await db.Database.MigrateAsync(); + } + return Ok("successfully."); + } [Route("api/v1/admin/Privacy_Policy")] [HttpPost] @@ -205,11 +218,24 @@ else{ } - + [Route("api/v1/admin/userfind/{userid}")] + [HttpGet] + [Authorize] + public async Task> getuser(long userid) + { + + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return BadRequest(new error_mb { code = 400, message = "无权访问" }); + } + return await userManager.Users.Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium }).FirstAsync(a=>a.Id==userid); + } + + /// /// 获取所有用户-支持分页(整合api:allperson_c) @@ -221,55 +247,24 @@ else{ [Route("api/v2/admin/allperson")] [HttpGet] [Authorize] - public async Task> getalladmin_v2(string? keyword, short page, short page_long = 10) + public async Task> getalladmin_v2(string? keyword, short pageindex=1, short pagesize = 10) { if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) { - List users = new List(); - post_user_v2 user = new post_user_v2(); + var a = new all_record(); if (keyword == null) { - int a = userManager.Users.Count(); - user.Count = a; - int b = page_long * page; - if (page_long * page > a) - { - b = a; - } - users = userManager.Users.Skip(page_long * page - page_long).Take(page_long).ToList(); + a.cout = userManager.Users.Count(); + a.msg = await userManager.Users.Paginate(pageindex, pagesize).Select(a => new {a.Id,a.Email,a.chinaname,a.UserName,a.Integral,a.officium}).ToListAsync(); } else { - int a = userManager.Users.Where(a => a.UserName.IndexOf(keyword) >= 0 || a.chinaname.IndexOf(keyword) >= 0 || a.Email.IndexOf(keyword) >= 0).Count(); - user.Count = a; - int b = page_long * page; - if (page_long * page > a) - { - b = a; - } - users = userManager.Users.Where(a => a.UserName.IndexOf(keyword) >= 0 || a.chinaname.IndexOf(keyword) >= 0 || a.Email.IndexOf(keyword) >= 0).Skip(page_long * page - page_long).Take(page_long).ToList(); - + + a.cout = userManager.Users.Where(a=>a.chinaname==keyword||a.UserName==keyword||a.Email==keyword).Count(); + a.msg = await userManager.Users.Where(a => a.chinaname == keyword || a.UserName == keyword || a.Email == keyword).Paginate(pageindex, pagesize).Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium }).ToListAsync(); } - - - foreach (var auser in users) - { - bool isadmin = await userManager.IsInRoleAsync(auser, "admin"); - var roles = await userManager.GetRolesAsync(auser); - try - { - // user.user.Add(new post_user { id = auser.Id, chinaname = auser.chinaname, name = auser.UserName, isadmin = isadmin, email = auser.Email, Roles = (List)roles, officium = auser.officium, Integral = auser.Integral }); - - } - catch - { - - } - - } - return user; - + return Ok(a); } else diff --git a/asg_form/Controllers/config.cs b/asg_form/Controllers/config.cs new file mode 100644 index 0000000..3dee4fc --- /dev/null +++ b/asg_form/Controllers/config.cs @@ -0,0 +1,129 @@ +using System.Security.Claims; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace asg_form.Controllers; + +public class T_config +{ + public int Id { set; get; } + public string Title{ set; get; } + public string Substance{ set; get;} + public string? msg{ set; get; } + + +} + + + +[ApiController] +[Route("api/[controller]")] +public class config : ControllerBase +{ + [Route("api/v1/admin/config")] + [HttpPost] + [Authorize] + public async Task> config_post([FromBody] T_config config) + { + + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return BadRequest(new error_mb { code = 400, message = "无权访问" }); + } +using(TestDbContext db=new TestDbContext()){ + var config__ = db.T_config.FirstOrDefault(a => a.Id == config.Id); + if (config__==null) + { + db.T_config.Add(config); + await db.SaveChangesAsync(); + } + else + { + var config_ = db.T_config.FirstOrDefault(a => a.Id == config.Id); + + config_.msg=config.msg; + config_.Substance = config.Substance; + config_.Title = config.Title; + await db.SaveChangesAsync(); + } + +} + + + return Ok("添加成功!"); + + } + + + + + + + + [Route("api/v1/admin/config/byTitle")] + [HttpPost] + [Authorize] + public async Task> config_get_title([FromBody] string title) + { + + + + using (TestDbContext db = new TestDbContext()) + { + var config = db.T_config.FirstOrDefault(a => a.Title == title); + return Ok(config.Substance); + } + + } + + [Route("api/v1/admin/config")] + [HttpDelete] + [Authorize] + public async Task> config_get_title(int Id) + { + + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return BadRequest(new error_mb { code = 400, message = "无权访问" }); + } + using (TestDbContext db = new TestDbContext()) + { + var config = db.T_config.FirstOrDefault(a => a.Id==Id); + db.Remove(config); + await db.SaveChangesAsync(); + return Ok("成功!"); + } + + } + + + + + + [Route("api/v1/admin/config/all")] + [HttpGet] + [Authorize] + public async Task> config_get_all(short page, short page_long = 10) + { + + if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) + { + return BadRequest(new error_mb { code = 400, message = "无权访问" }); + } + using (TestDbContext db = new TestDbContext()) + { + int a = db.T_config.Count(); + int b = page_long * page; + if (page_long * page > a) + { + b = a; + } + object config = db.T_config.Skip(page_long * page - page_long).Take(page_long).ToList(); + return Ok(config); + } + + } + + + +} diff --git a/asg_form/Controllers/form_cs.cs b/asg_form/Controllers/form_cs.cs index 697c062..77f2e9b 100644 --- a/asg_form/Controllers/form_cs.cs +++ b/asg_form/Controllers/form_cs.cs @@ -1,6 +1,7 @@ +using System.Security.Cryptography; +using System.Runtime.InteropServices.ComTypes; using asg_form.Controllers.Hubs; -using asg_form.Model; using Manganese.Text; using Masuit.Tools; using Masuit.Tools.Win32.AntiVirus; @@ -21,6 +22,7 @@ using System.Text; using System.Web; using static asg_form.Controllers.excel; using static ж; +using Manganese.Array; namespace asg_form.Controllers { @@ -162,7 +164,7 @@ namespace asg_form.Controllers } - /// + /// /// ύ /// /// Ϣ @@ -244,6 +246,81 @@ namespace asg_form.Controllers + /// + /// ύ + /// + /// + /// Ϣ + /// ȸ˻֤֤ + /// + [Route("api/v2/form/")] + [HttpPost] + public async Task> PostAsync(IFormFile imageFile,[FromForm] form_get_new for1) + { + + TestDbContext ctx = new TestDbContext(); + + + if (ctx.Forms.Include(a=>a.events).Where(a=>a.events.name==for1.events_name).Any(e => e.team_name == for1.team_name)) + { + return BadRequest(new error_mb { code = 400, message = "" }); + } + else + { + if (imageFile == null || imageFile.Length == 0) + return BadRequest("Invalid image file."); + // ļ浽 + var filePath = Path.Combine(Directory.GetCurrentDirectory(), $"loge/{for1.events_name}/", $"{imageFile.FileName}"); + using (var stream = new FileStream(filePath, FileMode.Create)) + { + await imageFile.CopyToAsync(stream); + } // سɹӦ + // base64toimg(for1.logo_base64, $@"{AppDomain.CurrentDomain.BaseDirectory}loge\{for1.events_name}\{for1.team_name}.png"); + var events= await ctx.events.FirstAsync(ctx => ctx.name == for1.events_name); + + + form form1 = new form(); + form1.logo_uri = $"https://124.223.35.239/loge/{for1.events_name}/{for1.team_name}.png"; + form1.team_name = for1.team_name; + form1.team_password = for1.team_password; + form1.team_tel = for1.team_tel; + form1.events = events; + + List role = new List(); + foreach (role_get a in for1.role_get) + { + role.Add(new role { role_id = a.role_id, role_lin = a.role_lin, role_name = a.role_name,Common_Roles=a.Common_Roles,Historical_Ranks=a.Historical_Ranks,Id_Card=a.Id_Card,Game_Name=a.Game_Name,Phone_Number=a.Phone_Number,Id_Card_Name=a.Id_Card_Name }); + } + form1.role = role; + + ctx.Forms.Add(form1); + await ctx.SaveChangesAsync(); + int nownumber = ctx.Forms.Count(); + //ChatRoomHub chat = new ChatRoomHub(); + // await chat.formok(nownumber, for1.team_name); + try + { + await hubContext.Clients.All.SendAsync("formok", $"{for1.team_name}Ѿɹʣ{ctx.Forms.Count()}/32"); + + } + catch + { + + + } + logger.Info($"¶鱨ƣ{for1.team_name} "); + } + + + return "ok!"; + + + + } + + + + public void base64toimg(string base64,string path) { @@ -394,6 +471,7 @@ namespace asg_form.Controllers public async Task>> search_name(string team_name,string events_name) { var ctx = new TestDbContext(); + var data = ctx.Forms.Where(a => a.team_name.IndexOf(team_name) >= 0&&a.events.name==events_name).Select(a => a.team_name).ToList(); return data; } @@ -440,7 +518,8 @@ namespace asg_form.Controllers public string team_password { get; set; } public string team_tel { get; set; } public string logo_uri { get; set; } - public T_events events { get; set; } + public Events.T_events events { get; set; } + // public string? belong { get; set; } public List role { get; set; } = new List(); } @@ -448,11 +527,24 @@ namespace asg_form.Controllers public class form_get { + // public DateTime time { get; set; } = DateTime.Now; + public string team_name { get; set; } + public string team_password { get; set; } + public string team_tel { get; set; } + public string logo_base64 { get; set; } + public string events_name { get; set; } + // public string? belong { get; set; } + public List role_get { get; set; } + } + + public class form_get_new + { + public DateTime time { get; set; } = DateTime.Now; public string team_name { get; set; } public string team_password { get; set; } public string team_tel { get; set; } - public string logo_base64 { get; set; } + // public string logo_base64 { get; set; } public string events_name { get; set; } // public string? belong { get; set; } public List role_get { get; set; } @@ -465,7 +557,7 @@ namespace asg_form.Controllers { public long Id { get; set; } - public string team_name { get; set; } + public string Team_name { get; set; } public string team_password { get; set; } public string team_tel { get; set; } diff --git a/asg_form/Controllers/login.cs b/asg_form/Controllers/login.cs index ee6797d..82beb8f 100644 --- a/asg_form/Controllers/login.cs +++ b/asg_form/Controllers/login.cs @@ -259,13 +259,20 @@ namespace asg_form.Controllers [Authorize] [Route("api/v1/user/")] [HttpGet] - public async Task> getuser() + public async Task> getuser(bool showbase64=true) { string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; var user = await userManager.FindByIdAsync(id); var isadmin = await userManager.IsInRoleAsync(user, "admin"); List roles = (List)await userManager.GetRolesAsync(user); - return new post_user { id = id.ToInt64(), Base64 = user.UserBase64, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium }; + if (showbase64) { + return new post_user { id = id.ToInt64(), money = user.Integral, Base64 = user.UserBase64, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium }; + } + else + { + return new post_user { id = id.ToInt64(), money = user.Integral, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium }; + + } } @@ -279,6 +286,7 @@ namespace asg_form.Controllers public string? email { get; set; } public bool isadmin { get; set; } public string? officium { get; set; } + public long? money { get; set; } public List? Roles { get; set; } diff --git a/asg_form/Controllers/news.cs b/asg_form/Controllers/news.cs index a60da7c..a421958 100644 --- a/asg_form/Controllers/news.cs +++ b/asg_form/Controllers/news.cs @@ -120,9 +120,51 @@ namespace asg_form.Controllers } + /// + /// 修改新闻 + /// + /// 新闻内容 + /// + [Authorize] + [Route("api/v1/admin/news/")] + [HttpPut] + public async Task> Put([FromBody] req_news req_News,long newsid) + { + string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; + var user = await userManager.FindByIdAsync(id); + + + + bool a = await userManager.IsInRoleAsync(user, "admin"); + if (a) + { + using (TestDbContext ctx = new TestDbContext()) + { + var qwq= await ctx.news.FindAsync(newsid); + qwq.msg=req_News.msg; + qwq.Title=req_News.Title; + qwq.FormName = user.UserName; + await ctx.SaveChangesAsync(); + + } + + return "ok!"; + } + else + { + return "无权访问"; + } + + } + } - public class T_news + +} + + + +public class T_news { public long Id { get; set; } public string Title { get; set; } @@ -144,4 +186,3 @@ namespace asg_form.Controllers } -} \ No newline at end of file diff --git a/asg_form/Migrations/20240810113800_stort.Designer.cs b/asg_form/Migrations/20240810113800_stort.Designer.cs new file mode 100644 index 0000000..b2be802 --- /dev/null +++ b/asg_form/Migrations/20240810113800_stort.Designer.cs @@ -0,0 +1,818 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using asg_form.Controllers; + +#nullable disable + +namespace asg_form.Migrations +{ + [DbContext(typeof(IDBcontext))] + [Migration("20240810113800_stort")] + partial class stort + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.Champion+T_Champion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("eventsId") + .HasColumnType("int"); + + b.Property("formId") + .HasColumnType("bigint"); + + b.Property("msg") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("eventsId"); + + b.HasIndex("formId"); + + b.ToTable("F_Champion", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.Store.StoreDB", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("information") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("id"); + + b.ToTable("StoreDB"); + }); + + modelBuilder.Entity("asg_form.Controllers.Store.StoreinfoDB", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Storeid") + .HasColumnType("bigint"); + + b.Property("buyerid") + .HasColumnType("bigint"); + + b.Property("isVerification") + .HasColumnType("bit"); + + b.HasKey("id"); + + b.HasIndex("Storeid"); + + b.ToTable("F_Store", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.T_Friend", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("account") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("comMsg") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("comTime") + .HasColumnType("datetime2"); + + b.Property("comType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("degree") + .HasColumnType("int"); + + b.Property("headName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("headTel") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("orgName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("id"); + + b.ToTable("F_Friend", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.T_news", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FormName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("msg") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("time") + .IsRequired() + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("F_news", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.comform+com_form", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Com_Cocial_media") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Com_Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Com_qq") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("idv_id") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("introduction") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("F_ComForm", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.form", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("eventsId") + .HasColumnType("int"); + + b.Property("logo_uri") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("piaoshu") + .HasColumnType("int"); + + b.Property("team_name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("team_password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("team_tel") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("time") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("eventsId"); + + b.ToTable("F_form", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Common_Roles") + .HasColumnType("nvarchar(max)"); + + b.Property("Game_Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Historical_Ranks") + .HasColumnType("int"); + + b.Property("Id_Card") + .HasColumnType("nvarchar(max)"); + + b.Property("Id_Card_Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone_Number") + .HasColumnType("nvarchar(max)"); + + b.Property("formId") + .HasColumnType("bigint"); + + b.Property("role_id") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("role_lin") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("role_name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("formId"); + + b.ToTable("F_role", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.schedule+schedule_log", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("chickteam") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("teamid") + .HasColumnType("bigint"); + + b.Property("userid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("win") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("teamid"); + + b.ToTable("F_achlog", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.schedule+team_game", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("belong") + .HasColumnType("nvarchar(max)"); + + b.Property("bilibiliuri") + .HasColumnType("nvarchar(max)"); + + b.Property("commentary") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("opentime") + .HasColumnType("datetime2"); + + b.Property("referee") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("tag") + .HasColumnType("nvarchar(max)"); + + b.Property("team1_name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("team1_piaoshu") + .HasColumnType("int"); + + b.Property("team2_name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("team2_piaoshu") + .HasColumnType("int"); + + b.Property("winteam") + .HasColumnType("nvarchar(max)"); + + b.HasKey("id"); + + b.ToTable("F_game", (string)null); + }); + + modelBuilder.Entity("asg_form.Model.T_events", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("events_rule_uri") + .HasColumnType("nvarchar(max)"); + + b.Property("is_over") + .HasColumnType("bit"); + + b.Property("name") + .HasColumnType("nvarchar(max)"); + + b.Property("opentime") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("F_events", (string)null); + }); + + modelBuilder.Entity("asg_form.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("msg") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("asg_form.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("CreationTime") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("Integral") + .HasColumnType("bigint"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserBase64") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("chinaname") + .HasColumnType("nvarchar(max)"); + + b.Property("haveformId") + .HasColumnType("bigint"); + + b.Property("isbooking") + .HasColumnType("bit"); + + b.Property("officium") + .HasColumnType("nvarchar(max)"); + + b.Property("point") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("haveformId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("asg_form.blog+blog_db", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("formuser") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("msg") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("pushtime") + .HasColumnType("datetime2"); + + b.Property("title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ID"); + + b.ToTable("F_blog", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("asg_form.Role", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("asg_form.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("asg_form.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("asg_form.Role", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("asg_form.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("asg_form.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("asg_form.Controllers.Champion+T_Champion", b => + { + b.HasOne("asg_form.Model.T_events", "events") + .WithMany() + .HasForeignKey("eventsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("asg_form.Controllers.form", "form") + .WithMany() + .HasForeignKey("formId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("events"); + + b.Navigation("form"); + }); + + modelBuilder.Entity("asg_form.Controllers.Store.StoreinfoDB", b => + { + b.HasOne("asg_form.Controllers.Store.StoreDB", "Store") + .WithMany("buyer") + .HasForeignKey("Storeid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Store"); + }); + + modelBuilder.Entity("asg_form.Controllers.form", b => + { + b.HasOne("asg_form.Model.T_events", "events") + .WithMany("forms") + .HasForeignKey("eventsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("events"); + }); + + modelBuilder.Entity("asg_form.Controllers.role", b => + { + b.HasOne("asg_form.Controllers.form", "form") + .WithMany("role") + .HasForeignKey("formId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("form"); + }); + + modelBuilder.Entity("asg_form.Controllers.schedule+schedule_log", b => + { + b.HasOne("asg_form.Controllers.schedule+team_game", "team") + .WithMany("logs") + .HasForeignKey("teamid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("team"); + }); + + modelBuilder.Entity("asg_form.User", b => + { + b.HasOne("asg_form.Controllers.form", "haveform") + .WithMany() + .HasForeignKey("haveformId"); + + b.Navigation("haveform"); + }); + + modelBuilder.Entity("asg_form.Controllers.Store.StoreDB", b => + { + b.Navigation("buyer"); + }); + + modelBuilder.Entity("asg_form.Controllers.form", b => + { + b.Navigation("role"); + }); + + modelBuilder.Entity("asg_form.Controllers.schedule+team_game", b => + { + b.Navigation("logs"); + }); + + modelBuilder.Entity("asg_form.Model.T_events", b => + { + b.Navigation("forms"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/asg_form/Migrations/20240810113800_stort.cs b/asg_form/Migrations/20240810113800_stort.cs new file mode 100644 index 0000000..49096d4 --- /dev/null +++ b/asg_form/Migrations/20240810113800_stort.cs @@ -0,0 +1,88 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace asg_form.Migrations +{ + /// + public partial class stort : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Integral", + table: "AspNetUsers", + type: "bigint", + nullable: true); + + migrationBuilder.AddColumn( + name: "point", + table: "AspNetUsers", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "StoreDB", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "bigint", nullable: false), + description = table.Column(type: "nvarchar(max)", nullable: false), + information = table.Column(type: "nvarchar(max)", nullable: false), + Type = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_StoreDB", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "F_Store", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + buyerid = table.Column(type: "bigint", nullable: false), + Storeid = table.Column(type: "bigint", nullable: false), + isVerification = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_F_Store", x => x.id); + table.ForeignKey( + name: "FK_F_Store_StoreDB_Storeid", + column: x => x.Storeid, + principalTable: "StoreDB", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_F_Store_Storeid", + table: "F_Store", + column: "Storeid"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "F_Store"); + + migrationBuilder.DropTable( + name: "StoreDB"); + + migrationBuilder.DropColumn( + name: "Integral", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "point", + table: "AspNetUsers"); + } + } +} diff --git a/asg_form/Migrations/20240810122803_newstore.Designer.cs b/asg_form/Migrations/20240810122803_newstore.Designer.cs new file mode 100644 index 0000000..839eb97 --- /dev/null +++ b/asg_form/Migrations/20240810122803_newstore.Designer.cs @@ -0,0 +1,818 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using asg_form.Controllers; + +#nullable disable + +namespace asg_form.Migrations +{ + [DbContext(typeof(IDBcontext))] + [Migration("20240810122803_newstore")] + partial class newstore + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.Champion+T_Champion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("eventsId") + .HasColumnType("int"); + + b.Property("formId") + .HasColumnType("bigint"); + + b.Property("msg") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("eventsId"); + + b.HasIndex("formId"); + + b.ToTable("F_Champion", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.Store.StoreDB", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("information") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("id"); + + b.ToTable("T_Store", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.Store.StoreinfoDB", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Storeid") + .HasColumnType("bigint"); + + b.Property("buyerid") + .HasColumnType("bigint"); + + b.Property("isVerification") + .HasColumnType("bit"); + + b.HasKey("id"); + + b.HasIndex("Storeid"); + + b.ToTable("T_Storeinfo", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.T_Friend", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("account") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("comMsg") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("comTime") + .HasColumnType("datetime2"); + + b.Property("comType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("degree") + .HasColumnType("int"); + + b.Property("headName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("headTel") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("orgName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("id"); + + b.ToTable("F_Friend", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.T_news", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FormName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("msg") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("time") + .IsRequired() + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("F_news", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.comform+com_form", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Com_Cocial_media") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Com_Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Com_qq") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("idv_id") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("introduction") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("F_ComForm", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.form", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("eventsId") + .HasColumnType("int"); + + b.Property("logo_uri") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("piaoshu") + .HasColumnType("int"); + + b.Property("team_name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("team_password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("team_tel") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("time") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("eventsId"); + + b.ToTable("F_form", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Common_Roles") + .HasColumnType("nvarchar(max)"); + + b.Property("Game_Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Historical_Ranks") + .HasColumnType("int"); + + b.Property("Id_Card") + .HasColumnType("nvarchar(max)"); + + b.Property("Id_Card_Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Phone_Number") + .HasColumnType("nvarchar(max)"); + + b.Property("formId") + .HasColumnType("bigint"); + + b.Property("role_id") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("role_lin") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("role_name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("formId"); + + b.ToTable("F_role", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.schedule+schedule_log", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("chickteam") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("teamid") + .HasColumnType("bigint"); + + b.Property("userid") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("win") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("teamid"); + + b.ToTable("F_achlog", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.schedule+team_game", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("belong") + .HasColumnType("nvarchar(max)"); + + b.Property("bilibiliuri") + .HasColumnType("nvarchar(max)"); + + b.Property("commentary") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("opentime") + .HasColumnType("datetime2"); + + b.Property("referee") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("tag") + .HasColumnType("nvarchar(max)"); + + b.Property("team1_name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("team1_piaoshu") + .HasColumnType("int"); + + b.Property("team2_name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("team2_piaoshu") + .HasColumnType("int"); + + b.Property("winteam") + .HasColumnType("nvarchar(max)"); + + b.HasKey("id"); + + b.ToTable("F_game", (string)null); + }); + + modelBuilder.Entity("asg_form.Model.T_events", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("events_rule_uri") + .HasColumnType("nvarchar(max)"); + + b.Property("is_over") + .HasColumnType("bit"); + + b.Property("name") + .HasColumnType("nvarchar(max)"); + + b.Property("opentime") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("F_events", (string)null); + }); + + modelBuilder.Entity("asg_form.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("msg") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("asg_form.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("CreationTime") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("Integral") + .HasColumnType("bigint"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserBase64") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("chinaname") + .HasColumnType("nvarchar(max)"); + + b.Property("haveformId") + .HasColumnType("bigint"); + + b.Property("isbooking") + .HasColumnType("bit"); + + b.Property("officium") + .HasColumnType("nvarchar(max)"); + + b.Property("point") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("haveformId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("asg_form.blog+blog_db", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("formuser") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("msg") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("pushtime") + .HasColumnType("datetime2"); + + b.Property("title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ID"); + + b.ToTable("F_blog", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("asg_form.Role", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("asg_form.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("asg_form.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("asg_form.Role", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("asg_form.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("asg_form.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("asg_form.Controllers.Champion+T_Champion", b => + { + b.HasOne("asg_form.Model.T_events", "events") + .WithMany() + .HasForeignKey("eventsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("asg_form.Controllers.form", "form") + .WithMany() + .HasForeignKey("formId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("events"); + + b.Navigation("form"); + }); + + modelBuilder.Entity("asg_form.Controllers.Store.StoreinfoDB", b => + { + b.HasOne("asg_form.Controllers.Store.StoreDB", "Store") + .WithMany("buyer") + .HasForeignKey("Storeid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Store"); + }); + + modelBuilder.Entity("asg_form.Controllers.form", b => + { + b.HasOne("asg_form.Model.T_events", "events") + .WithMany("forms") + .HasForeignKey("eventsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("events"); + }); + + modelBuilder.Entity("asg_form.Controllers.role", b => + { + b.HasOne("asg_form.Controllers.form", "form") + .WithMany("role") + .HasForeignKey("formId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("form"); + }); + + modelBuilder.Entity("asg_form.Controllers.schedule+schedule_log", b => + { + b.HasOne("asg_form.Controllers.schedule+team_game", "team") + .WithMany("logs") + .HasForeignKey("teamid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("team"); + }); + + modelBuilder.Entity("asg_form.User", b => + { + b.HasOne("asg_form.Controllers.form", "haveform") + .WithMany() + .HasForeignKey("haveformId"); + + b.Navigation("haveform"); + }); + + modelBuilder.Entity("asg_form.Controllers.Store.StoreDB", b => + { + b.Navigation("buyer"); + }); + + modelBuilder.Entity("asg_form.Controllers.form", b => + { + b.Navigation("role"); + }); + + modelBuilder.Entity("asg_form.Controllers.schedule+team_game", b => + { + b.Navigation("logs"); + }); + + modelBuilder.Entity("asg_form.Model.T_events", b => + { + b.Navigation("forms"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/asg_form/Migrations/20240810122803_newstore.cs b/asg_form/Migrations/20240810122803_newstore.cs new file mode 100644 index 0000000..b61042b --- /dev/null +++ b/asg_form/Migrations/20240810122803_newstore.cs @@ -0,0 +1,104 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace asg_form.Migrations +{ + /// + public partial class newstore : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_F_Store_StoreDB_Storeid", + table: "F_Store"); + + migrationBuilder.DropPrimaryKey( + name: "PK_StoreDB", + table: "StoreDB"); + + migrationBuilder.DropPrimaryKey( + name: "PK_F_Store", + table: "F_Store"); + + migrationBuilder.RenameTable( + name: "StoreDB", + newName: "T_Store"); + + migrationBuilder.RenameTable( + name: "F_Store", + newName: "T_Storeinfo"); + + migrationBuilder.RenameIndex( + name: "IX_F_Store_Storeid", + table: "T_Storeinfo", + newName: "IX_T_Storeinfo_Storeid"); + + migrationBuilder.AddPrimaryKey( + name: "PK_T_Store", + table: "T_Store", + column: "id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_T_Storeinfo", + table: "T_Storeinfo", + column: "id"); + + migrationBuilder.AddForeignKey( + name: "FK_T_Storeinfo_T_Store_Storeid", + table: "T_Storeinfo", + column: "Storeid", + principalTable: "T_Store", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_T_Storeinfo_T_Store_Storeid", + table: "T_Storeinfo"); + + migrationBuilder.DropPrimaryKey( + name: "PK_T_Storeinfo", + table: "T_Storeinfo"); + + migrationBuilder.DropPrimaryKey( + name: "PK_T_Store", + table: "T_Store"); + + migrationBuilder.RenameTable( + name: "T_Storeinfo", + newName: "F_Store"); + + migrationBuilder.RenameTable( + name: "T_Store", + newName: "StoreDB"); + + migrationBuilder.RenameIndex( + name: "IX_T_Storeinfo_Storeid", + table: "F_Store", + newName: "IX_F_Store_Storeid"); + + migrationBuilder.AddPrimaryKey( + name: "PK_F_Store", + table: "F_Store", + column: "id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_StoreDB", + table: "StoreDB", + column: "id"); + + migrationBuilder.AddForeignKey( + name: "FK_F_Store_StoreDB_Storeid", + table: "F_Store", + column: "Storeid", + principalTable: "StoreDB", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/asg_form/Migrations/IDBcontextModelSnapshot.cs b/asg_form/Migrations/IDBcontextModelSnapshot.cs index 6483773..7ba0339 100644 --- a/asg_form/Migrations/IDBcontextModelSnapshot.cs +++ b/asg_form/Migrations/IDBcontextModelSnapshot.cs @@ -152,29 +152,60 @@ namespace asg_form.Migrations b.ToTable("F_Champion", (string)null); }); - modelBuilder.Entity("asg_form.Controllers.Events+T_events", b => + modelBuilder.Entity("asg_form.Controllers.Store.StoreDB", b => { - b.Property("Id") + b.Property("id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); - b.Property("events_rule_uri") + b.Property("Name") + .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("is_over") + b.Property("Price") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("information") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("id"); + + b.ToTable("T_Store", (string)null); + }); + + modelBuilder.Entity("asg_form.Controllers.Store.StoreinfoDB", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Storeid") + .HasColumnType("bigint"); + + b.Property("buyerid") + .HasColumnType("bigint"); + + b.Property("isVerification") .HasColumnType("bit"); - b.Property("name") - .HasColumnType("nvarchar(max)"); + b.HasKey("id"); - b.Property("opentime") - .HasColumnType("datetime2"); + b.HasIndex("Storeid"); - b.HasKey("Id"); - - b.ToTable("F_events", (string)null); + b.ToTable("T_Storeinfo", (string)null); }); modelBuilder.Entity("asg_form.Controllers.T_Friend", b => @@ -455,6 +486,31 @@ namespace asg_form.Migrations b.ToTable("F_game", (string)null); }); + modelBuilder.Entity("asg_form.Model.T_events", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("events_rule_uri") + .HasColumnType("nvarchar(max)"); + + b.Property("is_over") + .HasColumnType("bit"); + + b.Property("name") + .HasColumnType("nvarchar(max)"); + + b.Property("opentime") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("F_events", (string)null); + }); + modelBuilder.Entity("asg_form.Role", b => { b.Property("Id") @@ -514,6 +570,9 @@ namespace asg_form.Migrations b.Property("EmailConfirmed") .HasColumnType("bit"); + b.Property("Integral") + .HasColumnType("bigint"); + b.Property("LockoutEnabled") .HasColumnType("bit"); @@ -562,6 +621,9 @@ namespace asg_form.Migrations b.Property("officium") .HasColumnType("nvarchar(max)"); + b.Property("point") + .HasColumnType("int"); + b.HasKey("Id"); b.HasIndex("NormalizedEmail") @@ -658,7 +720,7 @@ namespace asg_form.Migrations modelBuilder.Entity("asg_form.Controllers.Champion+T_Champion", b => { - b.HasOne("asg_form.Controllers.Events+T_events", "events") + b.HasOne("asg_form.Model.T_events", "events") .WithMany() .HasForeignKey("eventsId") .OnDelete(DeleteBehavior.Cascade) @@ -675,9 +737,20 @@ namespace asg_form.Migrations b.Navigation("form"); }); + modelBuilder.Entity("asg_form.Controllers.Store.StoreinfoDB", b => + { + b.HasOne("asg_form.Controllers.Store.StoreDB", "Store") + .WithMany("buyer") + .HasForeignKey("Storeid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Store"); + }); + modelBuilder.Entity("asg_form.Controllers.form", b => { - b.HasOne("asg_form.Controllers.Events+T_events", "events") + b.HasOne("asg_form.Model.T_events", "events") .WithMany("forms") .HasForeignKey("eventsId") .OnDelete(DeleteBehavior.Cascade) @@ -717,9 +790,9 @@ namespace asg_form.Migrations b.Navigation("haveform"); }); - modelBuilder.Entity("asg_form.Controllers.Events+T_events", b => + modelBuilder.Entity("asg_form.Controllers.Store.StoreDB", b => { - b.Navigation("forms"); + b.Navigation("buyer"); }); modelBuilder.Entity("asg_form.Controllers.form", b => @@ -731,6 +804,11 @@ namespace asg_form.Migrations { b.Navigation("logs"); }); + + modelBuilder.Entity("asg_form.Model.T_events", b => + { + b.Navigation("forms"); + }); #pragma warning restore 612, 618 } } diff --git a/asg_form/Model/Event.cs b/asg_form/Model/Event.cs deleted file mode 100644 index f77c0f0..0000000 --- a/asg_form/Model/Event.cs +++ /dev/null @@ -1,16 +0,0 @@ -using asg_form.Controllers; - -namespace asg_form.Model -{ - public class T_events - { - public int Id { get; set; } - public string? name { get; set; } - public bool? is_over { get; set; } - public DateTime? opentime { get; set; } - - public List? forms { get; set; } - public Uri? events_rule_uri { get; set; } - - } -} diff --git a/asg_form/Program.cs b/asg_form/Program.cs index 72af29e..bd430fc 100644 --- a/asg_form/Program.cs +++ b/asg_form/Program.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Hosting; using Microsoft.IdentityModel.Tokens; using Microsoft.OpenApi.Models; using Mirai.Net.Sessions; @@ -21,7 +22,7 @@ using System.Text; Console.WriteLine("\n _____ _________ ________ \n / _ \\ / _____// _____/ \n / /_\\ \\ \\_____ \\/ \\ ___ \n/ | \\/ \\ \\_\\ \\\n\\____|__ /_______ /\\______ /\n \\/ \\/ \\/ \n__________ __ ___________ .___\n\\______ \\_____ ____ | | __\\_ _____/ ____ __| _/\n | | _/\\__ \\ _/ ___\\| |/ / | __)_ / \\ / __ | \n | | \\ / __ \\\\ \\___| < | \\ | \\/ /_/ | \n |______ /(____ /\\___ >__|_ \\/_______ /___| /\\____ | \n \\/ \\/ \\/ \\/ \\/ \\/ \\/ "); var builder = WebApplication.CreateBuilder(args); -//builder.AddServiceDefaults(); +builder.AddServiceDefaults(); // Add services to the container. diff --git a/asg_form/User.cs b/asg_form/User.cs index 0ff3dff..cf6410b 100644 --- a/asg_form/User.cs +++ b/asg_form/User.cs @@ -1,4 +1,5 @@  +using System.ComponentModel; using asg_form.Controllers; using Microsoft.AspNetCore.Identity; @@ -7,6 +8,9 @@ namespace asg_form public class User : IdentityUser { public string? UserBase64 { get; set; } + + [DefaultValue(0)] + public long? Integral { get; set; } public DateTime CreationTime { get; set; } public form? haveform { get; set; } @@ -14,7 +18,10 @@ namespace asg_form public bool? isbooking { get; set; } public string? chinaname { get; set; } -public string? officium { get; set; } + public string? officium { get; set; } + + public int point { get; set; } + } public class Role : IdentityRole diff --git a/asg_form/asg_form.csproj b/asg_form/asg_form.csproj index 88f2d2b..6e5e9de 100644 --- a/asg_form/asg_form.csproj +++ b/asg_form/asg_form.csproj @@ -51,6 +51,7 @@ + diff --git a/asg_form_houduan-main.zip b/asg_form_houduan-main.zip deleted file mode 100644 index 0e0261b..0000000 Binary files a/asg_form_houduan-main.zip and /dev/null differ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6d41783..67deca6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,7 +10,7 @@ pool: vmImage: 'windows-latest' variables: - solution: '**/*.sln' + solution: 'asg_form.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' @@ -21,14 +21,6 @@ steps: inputs: restoreSolution: '$(solution)' -- task: VSBuild@1 +- task: DotNetCoreCLI@2 inputs: - solution: '$(solution)' - msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"' - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' - -- task: VSTest@2 - inputs: - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' + command: 'build'