From 47af2cbfd0b3a58b7b30a49a2d9775476d600fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=82=9C=E7=BF=94?= <2307953404@qq.com> Date: Sat, 26 Oct 2024 22:19:56 +0800 Subject: [PATCH] 1 --- asg_form/Controllers/Team/Team_http.cs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/asg_form/Controllers/Team/Team_http.cs b/asg_form/Controllers/Team/Team_http.cs index b84b69e..f806323 100644 --- a/asg_form/Controllers/Team/Team_http.cs +++ b/asg_form/Controllers/Team/Team_http.cs @@ -164,7 +164,6 @@ namespace asg_form.Controllers.Team [Route("api/v2/form/all")] [HttpGet] - [Authorize] public List Getform(short page, short page_long, string sort, string eventsname) { using (TestDbContext ctx = new TestDbContext()) @@ -209,13 +208,17 @@ namespace asg_form.Controllers.Team public class TeamFind { + public List roleId { get; set; } + public long formId { get; set; } public string teamName { get; set; } public List roles { get; set; } + public int voteOfLikes { get; set; } + public List? roleLin { get; set; } + public List? commonRoles { get; set; } } [Route("api/v3/form/all")] - [HttpGet] - [Authorize] + [HttpGet] public async Task> GetFormById(short page, short limit, int sort, int eventId) { using (var db = new TestDbContext()) @@ -228,11 +231,15 @@ namespace asg_form.Controllers.Team select new { m.team_name, + r.role_id, r.role_name, + r.role_lin, + r.Common_Roles, m.piaoshu, - m.time + m.time, + m.Id }; - switch (sort) + switch (sort) { case 0: query = query.OrderByDescending(m => m.piaoshu).ThenByDescending(m => m.time); @@ -253,11 +260,16 @@ namespace asg_form.Controllers.Team break; } var results = await query - .GroupBy(m => new { m.team_name, m.piaoshu, m.time }) + .GroupBy(m => new { m.team_name, m.Id,m.piaoshu, m.time }) .Select(g => new TeamFind { + formId = g.Key.Id, teamName = g.Key.team_name, - roles = g.Select(x => x.role_name).ToList() + roles = g.Select(x => x.role_name).ToList(), + voteOfLikes = g.Key.piaoshu, + roleLin = g.Select(x => x.role_lin).ToList(), // 选择第一个roleLin + commonRoles = g.Select(x => x.Common_Roles).ToList(), // 选择第一个commonRoles + roleId = g.Select(x => x.role_id).ToList(), // 选择第一个roleId }) .Skip((page - 1) * limit) .Take(limit)