1
This commit is contained in:
		
							parent
							
								
									d7fbbc77e0
								
							
						
					
					
						commit
						47af2cbfd0
					
				@ -164,7 +164,6 @@ namespace asg_form.Controllers.Team
 | 
			
		||||
 | 
			
		||||
        [Route("api/v2/form/all")]
 | 
			
		||||
        [HttpGet]
 | 
			
		||||
        [Authorize]
 | 
			
		||||
        public List<team> 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<string> roleId { get; set; }
 | 
			
		||||
            public long formId {  get; set; }
 | 
			
		||||
            public string teamName { get; set; }
 | 
			
		||||
            public List<string> roles { get; set; }
 | 
			
		||||
            public int voteOfLikes { get; set; }
 | 
			
		||||
            public List<string>? roleLin {  get; set; }
 | 
			
		||||
            public List<string>? commonRoles { get; set; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Route("api/v3/form/all")]
 | 
			
		||||
        [HttpGet]     
 | 
			
		||||
        [Authorize]
 | 
			
		||||
        public async Task<ActionResult<object>> GetFormById(short page, short limit, int sort, int eventId)
 | 
			
		||||
        {
 | 
			
		||||
            using (var db = new TestDbContext())
 | 
			
		||||
@ -228,9 +231,13 @@ 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)
 | 
			
		||||
                    {
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user