|
@@ -618,5 +618,52 @@ namespace GxPress.Repository.Implement.Media
|
|
|
query.Where(nameof(Entity.tede2.Media.Media.MediaType), GxPress.EnumConst.AllTypeConst.Video.GetHashCode());
|
|
|
return await _repository.CountAsync(query);
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 每日技能分页
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<PagedList<MediaCathedraResult>> GetDaySkillsAsync(Common.Page.PageParameter request)
|
|
|
+ {
|
|
|
+ var resut = new PagedList<MediaCathedraResult>();
|
|
|
+ var query = Q.NewQuery();
|
|
|
+ query.Select(nameof(Entity.tede2.Media.Media.Id));
|
|
|
+ query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
|
|
|
+ query.Select(nameof(Entity.tede2.Media.Media.Title));
|
|
|
+ query.Select(nameof(Entity.tede2.Media.Media.Author));
|
|
|
+ query.Select(nameof(Entity.tede2.Media.Media.MediaType));
|
|
|
+ query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
|
|
|
+ query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
|
|
|
+ query.Where(nameof(Entity.tede2.Media.Media.IsExercises), true);
|
|
|
+ query.Where(nameof(Entity.tede2.Media.Media.MediaType), AllTypeConst.Article.GetHashCode());
|
|
|
+ resut.Total = await _repository.CountAsync(query);
|
|
|
+ if (!string.IsNullOrEmpty(request.Sort))
|
|
|
+ {
|
|
|
+ query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
|
|
|
+ query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
|
|
|
+ query.ForPage(request.Page, request.PerPage);
|
|
|
+ resut.Items = await _repository.GetAllAsync<MediaCathedraResult>(query);
|
|
|
+ return resut;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 每日技能
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<MediaCathedraResult> GetRandomDaySkillAsync()
|
|
|
+ {
|
|
|
+ var sql = $@"SELECT
|
|
|
+ Id,ImageUrls,Title,Author,MediaType,ReadCount,CreatedDate
|
|
|
+ FROM
|
|
|
+ tede_media IsExercises=1 and MediaType={AllTypeConst.Article.GetHashCode()}
|
|
|
+ ORDER BY RAND() LIMIT 1";
|
|
|
+ var databaseType = _databaseTypestr.ToEnum<DatabaseType>(DatabaseType.MySql);
|
|
|
+ var database = new Database(databaseType, _connectionString);
|
|
|
+ var connection = database.GetConnection();
|
|
|
+ return await connection.QueryFirstAsync<MediaCathedraResult>(sql);
|
|
|
+ }
|
|
|
}
|
|
|
}
|