public ContentResult listevent(EventAdminQueryRequest request) { var data = _eventService.AdminEventList(request); var res = new ResultDto <EventResponse> { page = request.PageIndex, total = request.Total, records = request.Records, rows = data }; return(Content(res.Serialize())); }
//管理平台赛事列表 public List <EventResponse> AdminEventList(EventAdminQueryRequest request) { List <EventResponse> list = new List <EventResponse>(); try { StringBuilder join = new StringBuilder(); if (request.KeyValue.IsNotEmpty()) { request.KeyValue = $"%{request.KeyValue}%"; join.Append(" and (code like @KeyValue or name like @KeyValue)"); } if (request.EventStatus.HasValue && request.EventStatus > 0) { join.Append(" and eventStatus = @EventStatus"); } if (request.EventType.HasValue && request.EventType > 0) { join.Append(" and eventType = @EventType"); } if (request.EventStartDate.HasValue) { join.Append(" and starteventdate >= @EventStartDate"); } if (request.EventEndDate.HasValue) { request.EventEndDate = request.EventEndDate.Value.AddDays(1).AddSeconds(-1); join.Append(" and starteventdate <= @EventEndDate"); } var sql = $@"select * from t_event where isdelete=0 {join.ToString()} order by createtime desc"; int totalCount = 0; list = _dbContext.Page <EventResponse>(sql, out totalCount, request.PageIndex, request.PageSize, request); request.Records = totalCount; if (list != null && list.Count > 0) { foreach (var item in list) { //计算报名人数或者队伍 if (item.EventStatus != EventStatusEm.审核中 && item.EventStatus != EventStatusEm.拒绝) { item.SignUpCount = _dbContext.ExecuteScalar($"select count(distinct(groupnum)) from t_event_player_signup where isdelete=0 and signUpStatus in ({ParamsConfig._signup_in}) and eventId={item.Id}").ToObjInt(); } } } } catch (Exception ex) { LogUtils.LogError("EventService.AdminEventList", ex); } return(list); }