|
@@ -15,6 +15,7 @@ using GxPress.Request.Media;
|
|
|
using System;
|
|
|
using GxPress.EnumConst;
|
|
|
using GxPress.Request.ArticleGroup;
|
|
|
+using Dapper;
|
|
|
|
|
|
namespace GxPress.Repository.Implement.Media
|
|
|
{
|
|
@@ -224,29 +225,28 @@ namespace GxPress.Repository.Implement.Media
|
|
|
/// 根据IDs
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<PagedList<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request)
|
|
|
+ public async Task<IEnumerable<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request)
|
|
|
{
|
|
|
- var result = 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.WhereIn(nameof(Entity.tede2.Media.Media.Id), request.Ids);
|
|
|
- result.Total = await _repository.CountAsync(query);
|
|
|
- if (!string.IsNullOrEmpty(request.Sort))
|
|
|
+ if (request.Ids.Count > 0)
|
|
|
{
|
|
|
- query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
|
|
|
- query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
|
|
|
+ var str = "";
|
|
|
+ foreach (var item in request.Ids)
|
|
|
+ str += item + ",";
|
|
|
+ str = str.Remove(str.Length - 1, 1);
|
|
|
+ var sql = $@"SELECT
|
|
|
+ Id,ImageUrls,Title,Author,MediaType,ReadCount,CreatedDate
|
|
|
+ FROM
|
|
|
+ tede_media
|
|
|
+ WHERE
|
|
|
+ id IN ({str})
|
|
|
+ ORDER BY RAND() LIMIT {request.Limit}";
|
|
|
+
|
|
|
+ var databaseType = _databaseTypestr.ToEnum<DatabaseType>(DatabaseType.MySql);
|
|
|
+ var database = new Database(databaseType, _connectionString);
|
|
|
+ var connection = database.GetConnection();
|
|
|
+ return await connection.QueryAsync<MediaCathedraResult>(sql);
|
|
|
}
|
|
|
- else
|
|
|
- query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
|
|
|
- query.ForPage(request.Page, request.PerPage);
|
|
|
- result.Items = await _repository.GetAllAsync<MediaCathedraResult>(query);
|
|
|
- return result;
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
public async Task<bool> UpdateAsync(MediaResult result)
|