MediaRepository.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  1. using System.Linq;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using AutoMapper;
  5. using Datory;
  6. using GxPress.Common.AppOptions;
  7. using GxPress.Common.Tools;
  8. using GxPress.Repository.Interface.Media;
  9. using GxPress.Result.Media;
  10. using Microsoft.Extensions.Options;
  11. using System.Transactions;
  12. using GxPress.Common.Exceptions;
  13. using GxPress.Common.Page;
  14. using GxPress.Request.Media;
  15. using System;
  16. using GxPress.EnumConst;
  17. using GxPress.Request.ArticleGroup;
  18. using Dapper;
  19. namespace GxPress.Repository.Implement.Media
  20. {
  21. public class MediaRepository : IMediaRepository
  22. {
  23. private readonly Repository<Entity.tede2.Media.Media> _repository;
  24. private readonly Repository<Entity.tede2.Media.MediaLibrary> mediaLibraryRepository;
  25. private readonly Repository<Entity.tede2.Media.MediaLable> mediaLableRepository;
  26. private readonly IMapper _mapper;
  27. private readonly string _connectionString;
  28. private readonly string _databaseTypestr;
  29. public MediaRepository(IOptionsMonitor<DatabaseOptions> dbOptionsAccessor, IMapper mapper)
  30. {
  31. _databaseTypestr = dbOptionsAccessor.CurrentValue.DatabaseType;
  32. _connectionString = dbOptionsAccessor.CurrentValue.ConnectionString;
  33. var databaseType =
  34. StringUtils.ToEnum<DatabaseType>(dbOptionsAccessor.CurrentValue.DatabaseType, DatabaseType.MySql);
  35. var database = new Database(databaseType, dbOptionsAccessor.CurrentValue.ConnectionString);
  36. _repository = new Repository<Entity.tede2.Media.Media>(database);
  37. mediaLibraryRepository = new Repository<Entity.tede2.Media.MediaLibrary>(database);
  38. mediaLableRepository = new Repository<Entity.tede2.Media.MediaLable>(database);
  39. _mapper = mapper;
  40. }
  41. public IDatabase Database => _repository.Database;
  42. public string TableName => _repository.TableName;
  43. public List<TableColumn> TableColumns => _repository.TableColumns;
  44. public async Task<MediaResult> GetAsync(int id)
  45. {
  46. var result = new MediaResult();
  47. //获取媒体
  48. var media = await _repository.GetAsync(id);
  49. result = _mapper.Map<MediaResult>(media);
  50. result.ImageUrls = StringUtils.AddDomain(result.ImageUrls);
  51. result.CategoryId = StringUtils.StringCollectionToStringList(media.CategoryId).ToList();
  52. result.CategoryName = StringUtils.StringCollectionToStringList(media.CategoryName).ToList();
  53. result.FullCategoryId = StringUtils.StringCollectionToStringList(media.FullCategoryId).ToList();
  54. //获取媒体库资源
  55. var mediaLibrarys = await mediaLibraryRepository.GetAllAsync(Q.Where(nameof(Entity.tede2.Media.MediaLibrary.MediaId), id));
  56. result.MediaLibraryResults = mediaLibrarys.ToList().Select(n => _mapper.Map<MediaLibraryResult>(n)).ToList();
  57. foreach (var item in result.MediaLibraryResults)
  58. {
  59. item.FileUrl = StringUtils.AddDomain(item.FileUrl);
  60. }
  61. //获取媒体标签
  62. var mediaLables = await mediaLableRepository.GetAllAsync(Q.Where(nameof(Entity.tede2.Media.MediaLable.MediaId), id));
  63. result.MediaLableResults = mediaLables.Select(n => _mapper.Map<MediaLableResult>(n)).ToList();
  64. return result;
  65. }
  66. /// <summary>
  67. /// 删除媒体
  68. /// </summary>
  69. /// <param name="id"></param>
  70. /// <returns></returns>
  71. public async Task<bool> DeleteAsync(int id)
  72. {
  73. try
  74. {
  75. using (var transactionScope = new TransactionScope())
  76. {
  77. // //删除媒体库
  78. // await mediaLibraryRepository.DeleteAsync(Q.Where(nameof(Entity.tede2.Media.MediaLibrary.MediaId), id));
  79. // //删除媒体标签
  80. // await mediaLableRepository.DeleteAsync(Q.Where(nameof(Entity.tede2.Media.MediaLable.MediaId), id));
  81. await _repository.UpdateAsync(Q.Where(nameof(Entity.tede2.Media.Media.Id), id).Set(nameof(Entity.tede2.Media.Media.IsDelete), true));
  82. transactionScope.Complete();
  83. }
  84. }
  85. catch (System.Exception ex)
  86. {
  87. throw new BusinessException(ex.Message);
  88. }
  89. return true;
  90. }
  91. /// <summary>
  92. /// 添加媒体
  93. /// </summary>
  94. /// <param name="result"></param>
  95. /// <returns></returns>
  96. public async Task<bool> InsertAsync(MediaResult result)
  97. {
  98. var model = _mapper.Map<Entity.tede2.Media.Media>(result);
  99. model.ImageUrls = StringUtils.RemoveDomain(result.ImageUrls);
  100. try
  101. {
  102. using (var transactionScope = new TransactionScope())
  103. {
  104. model.AutoNumber = SnowflakeHelper.MakeSnowflake();
  105. var categoryId = "";
  106. foreach (var item in result.CategoryId)
  107. {
  108. categoryId += item.Split(",")[item.Split(",").Length - 1] + ",";
  109. }
  110. categoryId = categoryId.Remove(categoryId.Length - 1, 1);
  111. model.CategoryId = categoryId;
  112. model.FullCategoryId = StringUtils.ObjectCollectionToString(result.CategoryId);
  113. var categoryName = "";
  114. foreach (var item in result.CategoryName)
  115. {
  116. categoryName += item.Split(",")[item.Split(",").Length - 1] + ",";
  117. }
  118. categoryName = categoryName.Remove(categoryName.Length - 1, 1);
  119. model.CategoryName = categoryName;
  120. model.IsLibrary = result.MediaLibraryResults.Count > 0;
  121. var id = await _repository.InsertAsync(model);
  122. if (id > 0)
  123. {
  124. foreach (var item in result.MediaLibraryResults)
  125. {
  126. var mediaLibrary = _mapper.Map<Entity.tede2.Media.MediaLibrary>(item);
  127. mediaLibrary.MediaId = id;
  128. mediaLibrary.FileUrl = StringUtils.RemoveDomain(item.FileUrl);
  129. await mediaLibraryRepository.InsertAsync(mediaLibrary);
  130. }
  131. }
  132. //添加标签
  133. foreach (var item in result.MediaLableResults)
  134. {
  135. var mediaLable = _mapper.Map<Entity.tede2.Media.MediaLable>(item);
  136. mediaLable.MediaId = id;
  137. await mediaLableRepository.InsertAsync(mediaLable);
  138. }
  139. if (result.Id == 0 && result.TeacherId == 0 && !string.IsNullOrEmpty(result.Author))
  140. {
  141. //新增名师
  142. }
  143. //提交事务
  144. transactionScope.Complete();
  145. }
  146. }
  147. catch (System.Exception ex)
  148. {
  149. throw new Common.Exceptions.BusinessException(ex.Message);
  150. }
  151. return true;
  152. }
  153. /// <summary>
  154. /// 获取媒体
  155. /// </summary>
  156. /// <param name="query"></param>
  157. /// <returns></returns>
  158. public async Task<MediaNoteResult> GetAsync(SqlKata.Query query)
  159. {
  160. query.Select(nameof(Entity.tede2.Media.Media.Id));
  161. query.Select(nameof(Entity.tede2.Media.Media.Title));
  162. query.Select(nameof(Entity.tede2.Media.Media.Author));
  163. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  164. return await _repository.GetAsync<MediaNoteResult>(query);
  165. }
  166. public async Task<bool> UpdateAsync(Entity.tede2.Media.Media note)
  167. {
  168. return await _repository.UpdateAsync(note);
  169. }
  170. public async Task<bool> UpdateAsync(SqlKata.Query query)
  171. {
  172. return await _repository.UpdateAsync(query) > 0;
  173. }
  174. /// <summary>
  175. /// 查询
  176. /// </summary>
  177. /// <param name="request"></param>
  178. /// <returns></returns>
  179. public async Task<PagedList<Entity.tede2.Media.Media>> GetAllAsync(MediaSearchRequest request)
  180. {
  181. var result = new PagedList<Entity.tede2.Media.Media>();
  182. var query = Q.NewQuery();
  183. if (!string.IsNullOrEmpty(request.KeyWord))
  184. {
  185. query.OrWhereLike(nameof(Entity.tede2.Media.Media.Title), $"%{request.KeyWord}%");
  186. query.OrWhereLike(nameof(Entity.tede2.Media.Media.Creator), $"%{request.KeyWord}%");
  187. }
  188. if (request.IsDelete > 0)
  189. query.Where(nameof(Entity.tede2.Media.Media.IsDelete), request.IsDelete == 1);
  190. if (request.MediaType > 0)
  191. query.Where(nameof(Entity.tede2.Media.Media.MediaType), request.MediaType);
  192. if (request.LibraryType > 0)
  193. query.Where(nameof(Entity.tede2.Media.Media.IsLibrary), request.LibraryType == 1);
  194. if (!string.IsNullOrEmpty(request.BeginTime) && !string.IsNullOrEmpty(request.EndTime))
  195. {
  196. if (DateTime.TryParse(request.BeginTime, out var beginTime) && DateTime.TryParse(request.EndTime, out var endTime))
  197. {
  198. query.WhereDate(nameof(Entity.tede2.Media.Media.CreatedDate), ">=", beginTime);
  199. query.WhereDate(nameof(Entity.tede2.Media.Media.CreatedDate), "<=", endTime);
  200. }
  201. }
  202. if (request.IsChecked > 0)
  203. query.Where(nameof(Entity.tede2.Media.Media.IsChecked), request.IsChecked == 1);
  204. result.Total = await _repository.CountAsync(query);
  205. //排序
  206. if (string.IsNullOrEmpty(request.Sort))
  207. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
  208. else if (request.Sort.Equals("SellAmount"))
  209. query.OrderByDesc(nameof(Entity.tede2.Media.Media.SellAmount));
  210. else if (request.Sort.Equals("ReadCount"))
  211. query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
  212. var item = await _repository.GetAllAsync(query.ForPage(request.Page, request.PerPage));
  213. result.Items = item;
  214. return result;
  215. }
  216. /// <summary>
  217. /// 根据IDs
  218. /// </summary>
  219. /// <returns></returns>
  220. public async Task<IEnumerable<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request)
  221. {
  222. if (request.Ids.Count > 0)
  223. {
  224. var str = "";
  225. foreach (var item in request.Ids)
  226. str += item + ",";
  227. str = str.Remove(str.Length - 1, 1);
  228. var sql = $@"SELECT
  229. Id,ImageUrls,Title,Author,MediaType,ReadCount,CreatedDate
  230. FROM
  231. tede_media
  232. WHERE
  233. id IN ({str})
  234. ORDER BY RAND() LIMIT {request.Limit}";
  235. var databaseType = _databaseTypestr.ToEnum<DatabaseType>(DatabaseType.MySql);
  236. var database = new Database(databaseType, _connectionString);
  237. var connection = database.GetConnection();
  238. var result = await connection.QueryAsync<MediaCathedraResult>(sql);
  239. foreach (var item in result)
  240. {
  241. item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
  242. }
  243. return result;
  244. }
  245. return null;
  246. }
  247. /// <summary>
  248. /// 根据IDs
  249. /// </summary>
  250. /// <returns></returns>
  251. public async Task<PagedList<MediaCathedraResult>> GetMediaByLableIdAsync(MediaLableIdRequest request)
  252. {
  253. var result = new PagedList<MediaCathedraResult>();
  254. if (request.Ids.Count > 0)
  255. {
  256. var str = "";
  257. foreach (var item in request.Ids)
  258. str += item + ",";
  259. str = str.Remove(str.Length - 1, 1);
  260. var sql = $@"SELECT
  261. Id,ImageUrls,Title,Author,MediaType,ReadCount,CreatedDate
  262. FROM
  263. tede_media
  264. WHERE
  265. id IN ({str})
  266. ORDER BY CreatedDate desc LIMIT {(request.Page - 1) * request.PerPage},{request.PerPage}";
  267. var databaseType = _databaseTypestr.ToEnum<DatabaseType>(DatabaseType.MySql);
  268. var database = new Database(databaseType, _connectionString);
  269. var connection = database.GetConnection();
  270. result.Items = await connection.QueryAsync<MediaCathedraResult>(sql);
  271. sql = $@"SELECT count(1) FROM tede_media WHERE id IN ({str})";
  272. result.Total = await connection.ExecuteScalarAsync<int>(sql);
  273. }
  274. foreach (var item in result.Items)
  275. {
  276. item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
  277. }
  278. return result;
  279. }
  280. public async Task<bool> UpdateAsync(MediaResult result)
  281. {
  282. //var model = _mapper.Map<Entity.tede2.Media.Media>(result);
  283. try
  284. {
  285. using (var transactionScope = new TransactionScope())
  286. {
  287. var model = await _repository.GetAsync(result.Id);
  288. if (result.CategoryId != null && result.CategoryId.Count > 0)
  289. {
  290. var categoryId = "";
  291. foreach (var item in result.CategoryId)
  292. categoryId += item.Split(",")[item.Split(",").Length - 1] + ",";
  293. categoryId = categoryId.Remove(categoryId.Length - 1, 1);
  294. model.CategoryId = categoryId;
  295. model.FullCategoryId = StringUtils.ObjectCollectionToString(result.CategoryId);
  296. }
  297. if (result.CategoryName != null && result.CategoryName.Count > 0)
  298. {
  299. var categoryName = "";
  300. foreach (var item in result.CategoryName)
  301. categoryName += item.Split(",")[item.Split(",").Length - 1] + ",";
  302. categoryName = categoryName.Remove(categoryName.Length - 1, 1);
  303. model.CategoryName = categoryName;
  304. }
  305. if (result.AdminId > 0)
  306. model.AdminId = result.AdminId;
  307. if (!string.IsNullOrEmpty(result.Creator))
  308. model.Creator = result.Creator;
  309. if (result.MediaType > 0)
  310. model.MediaType = result.MediaType;
  311. if (!string.IsNullOrEmpty(result.Title))
  312. model.Title = result.Title;
  313. if (!string.IsNullOrEmpty(result.ImageUrls))
  314. model.ImageUrls = result.ImageUrls;
  315. if (!string.IsNullOrEmpty(result.Summary))
  316. model.Summary = result.Summary;
  317. if (!string.IsNullOrEmpty(result.Author))
  318. model.Author = result.Author;
  319. if (result.TeacherId > 0)
  320. model.TeacherId = result.TeacherId;
  321. if (!string.IsNullOrEmpty(result.Source))
  322. model.Source = result.Source;
  323. if (!string.IsNullOrEmpty(result.Blocks))
  324. model.Blocks = result.Blocks;
  325. if (result.IsChecked > 0)
  326. model.IsChecked = result.IsChecked == 1;
  327. if (!string.IsNullOrEmpty(result.AddDate))
  328. model.AddDate = Convert.ToDateTime(result.AddDate);
  329. if (model.Sort > 0)
  330. model.Sort = result.Sort;
  331. if (model.ReadCount > 0)
  332. model.ReadCount = result.ReadCount;
  333. if (result.IsTop > 0)
  334. model.IsTop = result.IsTop == 1;
  335. if (result.LableId > 0)
  336. model.LableId = result.LableId;
  337. if (result.IsRecommend > 0)
  338. model.IsRecommend = result.IsRecommend == 1;
  339. if (!string.IsNullOrEmpty(result.Press))
  340. model.Press = result.Press;
  341. if (!string.IsNullOrEmpty(result.PublishTime))
  342. model.PublishTime = result.PublishTime;
  343. if (result.IosDiscountPrice > 0)
  344. model.IosDiscountPrice = result.IosDiscountPrice;
  345. if (result.IosPrice > 0)
  346. model.IosPrice = result.IosPrice;
  347. if (result.OtherDiscountPrice > 0)
  348. model.OtherDiscountPrice = result.OtherDiscountPrice;
  349. if (result.OtherPrice > 0)
  350. model.OtherPrice = result.OtherPrice;
  351. if (result.FreeProportion > 0)
  352. model.FreeProportion = result.FreeProportion;
  353. if (result.AttachType > 0)
  354. model.AttachType = result.AttachType;
  355. if (result.AttachId > 0)
  356. model.AttachId = result.AttachId;
  357. if (result.MediaId > 0)
  358. model.MediaId = result.MediaId;
  359. if (!string.IsNullOrEmpty(result.MediaTitle))
  360. model.MediaTitle = result.MediaTitle;
  361. if (!string.IsNullOrEmpty(result.JournalsYear))
  362. model.JournalsYear = result.JournalsYear;
  363. if (result.JournalsCategory > 0)
  364. model.JournalsCategory = result.JournalsCategory;
  365. if (result.IsExercises > 0)
  366. model.IsExercises = result.IsExercises == 1;
  367. if (result.AppCategoryId > 0)
  368. model.AppCategoryId = result.AppCategoryId;
  369. await _repository.UpdateAsync(model);
  370. if (result.MediaLibraryResults != null && result.MediaLibraryResults.Count > 0)
  371. {
  372. model.IsLibrary = result.MediaLibraryResults.Count > 0;
  373. //删除媒体库
  374. await mediaLibraryRepository.DeleteAsync(Q.Where(nameof(Entity.tede2.Media.MediaLibrary.MediaId), result.Id));
  375. foreach (var item in result.MediaLibraryResults)
  376. {
  377. var mediaLibrary = _mapper.Map<Entity.tede2.Media.MediaLibrary>(item);
  378. mediaLibrary.MediaId = result.Id;
  379. mediaLibrary.FileUrl = StringUtils.RemoveDomain(mediaLibrary.FileUrl);
  380. await mediaLibraryRepository.InsertAsync(mediaLibrary);
  381. }
  382. }
  383. if (result.MediaLableResults != null && result.MediaLableResults.Count > 0)
  384. {
  385. //删除媒体标签
  386. await mediaLableRepository.DeleteAsync(Q.Where(nameof(Entity.tede2.Media.MediaLable.MediaId), result.Id));
  387. //添加标签
  388. foreach (var item in result.MediaLableResults)
  389. {
  390. var mediaLable = _mapper.Map<Entity.tede2.Media.MediaLable>(item);
  391. mediaLable.MediaId = result.Id;
  392. await mediaLableRepository.InsertAsync(mediaLable);
  393. }
  394. }
  395. //提交事务
  396. transactionScope.Complete();
  397. }
  398. }
  399. catch (System.Exception ex)
  400. {
  401. throw new Common.Exceptions.BusinessException(ex.Message);
  402. }
  403. return true;
  404. }
  405. public async Task<int> CountAsync(string beginTime, string endTime)
  406. {
  407. return await _repository.CountAsync(Q.WhereDate(nameof(Entity.tede2.Media.Media.CreatedDate), ">=", beginTime).WhereDate(nameof(Entity.tede2.Media.Media.CreatedDate), "<=", endTime));
  408. }
  409. public async Task<int> CountAsync(SqlKata.Query query)
  410. {
  411. return await _repository.CountAsync(query);
  412. }
  413. public async Task<Entity.tede2.Media.Media> GetAsync(string autoNumber)
  414. {
  415. return await _repository.GetAsync(Q.Where(nameof(Entity.tede2.Media.Media.AutoNumber), autoNumber));
  416. }
  417. /// <summary>
  418. /// 获取书籍
  419. /// </summary>
  420. /// <param name="mediaId"></param>
  421. /// <returns></returns>
  422. public async Task<BookMediaResult> GetBookMediaResultAsync(int mediaId)
  423. {
  424. var result = await _repository.GetAsync(Q.Where(nameof(Entity.tede2.Media.Media.Id), mediaId).Where(nameof(Entity.tede2.Media.Media.IsChecked), true).Where(nameof(Entity.tede2.Media.Media.IsDelete), false));
  425. return _mapper.Map<BookMediaResult>(result);
  426. }
  427. /// <summary>
  428. /// 获取视频
  429. /// </summary>
  430. /// <param name="mediaId"></param>
  431. /// <returns></returns>
  432. public async Task<VideoMediaResult> GetVideoMediaResultAsync(int mediaId)
  433. {
  434. var result = await _repository.GetAsync(Q.Where(nameof(Entity.tede2.Media.Media.Id), mediaId).Where(nameof(Entity.tede2.Media.Media.IsChecked), true).Where(nameof(Entity.tede2.Media.Media.IsDelete), false));
  435. return _mapper.Map<VideoMediaResult>(result);
  436. }
  437. /// <summary>
  438. /// 根据
  439. /// </summary>
  440. /// <param name="mediaIds"></param>
  441. /// <returns></returns>
  442. public async Task<IEnumerable<NavigationMediaResult>> GetNavigationMediaResults(IEnumerable<int> mediaIds, int page = 1, int pageSize = 10)
  443. {
  444. //获取媒体
  445. var query = Q.NewQuery();
  446. query.Select(nameof(Entity.tede2.Media.Media.Id));
  447. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  448. query.Select(nameof(Entity.tede2.Media.Media.Title));
  449. query.Select(nameof(Entity.tede2.Media.Media.Summary));
  450. query.Select(nameof(Entity.tede2.Media.Media.TeacherId));
  451. query.Select(nameof(Entity.tede2.Media.Media.AutoNumber));
  452. query.Select(nameof(Entity.tede2.Media.Media.Author));
  453. query.Select(nameof(Entity.tede2.Media.Media.MediaType));
  454. query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
  455. query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
  456. query.Select(nameof(Entity.tede2.Media.Media.CollectCount));
  457. query.WhereIn(nameof(Entity.tede2.Media.Media.Id), mediaIds);
  458. query.Where(nameof(Entity.tede2.Media.Media.IsChecked), true);
  459. query.Where(nameof(Entity.tede2.Media.Media.IsDelete), false);
  460. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  461. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  462. query.OrderByDesc(nameof(Entity.tede2.Media.Media.LastModifiedDate));
  463. query.ForPage(page, pageSize);
  464. return await _repository.GetAllAsync<NavigationMediaResult>(query);
  465. }
  466. /// <summary>
  467. /// 猜你喜欢
  468. /// </summary>
  469. /// <param name="mediaIds"></param>
  470. /// <returns></returns>
  471. public async Task<IEnumerable<NavigationMediaResult>> GetlikeMediaResults()
  472. {
  473. //获取媒体
  474. var query = Q.NewQuery();
  475. query.Select(nameof(Entity.tede2.Media.Media.Id));
  476. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  477. query.Select(nameof(Entity.tede2.Media.Media.Title));
  478. query.Select(nameof(Entity.tede2.Media.Media.Summary));
  479. query.Select(nameof(Entity.tede2.Media.Media.TeacherId));
  480. query.Select(nameof(Entity.tede2.Media.Media.AutoNumber));
  481. query.Select(nameof(Entity.tede2.Media.Media.Author));
  482. query.Select(nameof(Entity.tede2.Media.Media.MediaType));
  483. query.Where(nameof(Entity.tede2.Media.Media.IsTop), true);
  484. query.Where(nameof(Entity.tede2.Media.Media.IsChecked), true);
  485. query.Where(nameof(Entity.tede2.Media.Media.IsDelete), false);
  486. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  487. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  488. query.ForPage(1, 10);
  489. return await _repository.GetAllAsync<NavigationMediaResult>(query);
  490. }
  491. /// <summary>
  492. /// 推荐
  493. /// </summary>
  494. /// <param name="mediaIds"></param>
  495. /// <returns></returns>
  496. public async Task<IEnumerable<NavigationMediaResult>> GetRecommendMediaResults()
  497. {
  498. //获取媒体
  499. var query = Q.NewQuery();
  500. query.Select(nameof(Entity.tede2.Media.Media.Id));
  501. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  502. query.Select(nameof(Entity.tede2.Media.Media.Title));
  503. query.Select(nameof(Entity.tede2.Media.Media.Summary));
  504. query.Select(nameof(Entity.tede2.Media.Media.TeacherId));
  505. query.Select(nameof(Entity.tede2.Media.Media.AutoNumber));
  506. query.Select(nameof(Entity.tede2.Media.Media.Author));
  507. query.Select(nameof(Entity.tede2.Media.Media.MediaType));
  508. query.Where(nameof(Entity.tede2.Media.Media.IsRecommend), true);
  509. query.Where(nameof(Entity.tede2.Media.Media.IsChecked), true);
  510. query.Where(nameof(Entity.tede2.Media.Media.IsDelete), false);
  511. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  512. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  513. query.ForPage(1, 10);
  514. return await _repository.GetAllAsync<NavigationMediaResult>(query);
  515. }
  516. /// <summary>
  517. /// 排行榜
  518. /// </summary>
  519. /// <param name="request"></param>
  520. /// <returns></returns>
  521. public async Task<IEnumerable<RankingListResult>> GetRankingListResults(RankingListRequest request)
  522. {
  523. //获取媒体
  524. var query = Q.NewQuery();
  525. query.Select(nameof(Entity.tede2.Media.Media.Id));
  526. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  527. query.Select(nameof(Entity.tede2.Media.Media.Title));
  528. query.Select(nameof(Entity.tede2.Media.Media.Summary));
  529. query.Select(nameof(Entity.tede2.Media.Media.TeacherId));
  530. query.Select(nameof(Entity.tede2.Media.Media.AutoNumber));
  531. query.Select(nameof(Entity.tede2.Media.Media.Author));
  532. query.Select(nameof(Entity.tede2.Media.Media.MediaType));
  533. query.Select(nameof(Entity.tede2.Media.Media.Summary));
  534. query.Select(nameof(Entity.tede2.Media.Media.CommentScore));
  535. query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
  536. query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
  537. //1 热搜 2热书榜 3 课程榜 4Top 100 新书 5文献头条 6试听榜 7大众热评 8Top 100 专著
  538. if (request.DataTypeValue > 0)
  539. {
  540. //1 热搜
  541. if (request.DataTypeValue == RankingListConst.HotSearch.GetHashCode())
  542. query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
  543. //2热书榜
  544. if (request.DataTypeValue == RankingListConst.ReadBook.GetHashCode())
  545. {
  546. query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Book.GetHashCode());
  547. query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
  548. }
  549. //3 课程榜
  550. if (request.DataTypeValue == RankingListConst.Article.GetHashCode())
  551. {
  552. query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Article.GetHashCode());
  553. query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
  554. }
  555. //Top 100 新书
  556. if (request.DataTypeValue == RankingListConst.NewBook.GetHashCode())
  557. {
  558. query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Book.GetHashCode());
  559. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
  560. }
  561. //文献头条
  562. if (request.DataTypeValue == RankingListConst.ArticleTop.GetHashCode())
  563. {
  564. query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Article.GetHashCode());
  565. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  566. }
  567. if (request.DataTypeValue == RankingListConst.Audio.GetHashCode())
  568. {
  569. query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Audio.GetHashCode());
  570. query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
  571. }
  572. if (request.DataTypeValue == RankingListConst.HotComment.GetHashCode())
  573. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CommentScore));
  574. if (request.DataTypeValue == RankingListConst.CollectionBook.GetHashCode())
  575. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CollectCount));
  576. }
  577. query.Where(nameof(Entity.tede2.Media.Media.IsChecked), true);
  578. query.Where(nameof(Entity.tede2.Media.Media.IsDelete), false);
  579. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  580. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  581. query.ForPage(request.Page, request.PerPage);
  582. var result = await _repository.GetAllAsync<RankingListResult>(query);
  583. foreach (var item in result)
  584. item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
  585. return result;
  586. }
  587. /// <summary>
  588. /// 排行榜分页
  589. /// </summary>
  590. /// <param name="request"></param>
  591. /// <returns></returns>
  592. public async Task<PagedList<RankingListResult>> GetRankingPageListResults(RankingListRequest request)
  593. {
  594. var result = new PagedList<RankingListResult>();
  595. //获取媒体
  596. var query = Q.NewQuery();
  597. query.Select(nameof(Entity.tede2.Media.Media.Id));
  598. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  599. query.Select(nameof(Entity.tede2.Media.Media.Title));
  600. query.Select(nameof(Entity.tede2.Media.Media.Summary));
  601. query.Select(nameof(Entity.tede2.Media.Media.TeacherId));
  602. query.Select(nameof(Entity.tede2.Media.Media.AutoNumber));
  603. query.Select(nameof(Entity.tede2.Media.Media.Author));
  604. query.Select(nameof(Entity.tede2.Media.Media.MediaType));
  605. query.Select(nameof(Entity.tede2.Media.Media.Summary));
  606. query.Select(nameof(Entity.tede2.Media.Media.CommentScore));
  607. query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
  608. query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
  609. if (!string.IsNullOrEmpty(request.KeyWord))
  610. query.WhereLike(nameof(Entity.tede2.Media.Media.Title), $"%{request.KeyWord}%");
  611. //1 热搜 2热书榜 3 课程榜 4Top 100 新书 5文献头条 6试听榜 7大众热评 8Top 100 专著
  612. if (request.DataTypeValue > 0)
  613. {
  614. //1 热搜
  615. if (request.DataTypeValue == RankingListConst.HotSearch.GetHashCode())
  616. query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
  617. //2热书榜
  618. if (request.DataTypeValue == RankingListConst.ReadBook.GetHashCode())
  619. {
  620. query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Book.GetHashCode());
  621. query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
  622. }
  623. //3 课程榜
  624. if (request.DataTypeValue == RankingListConst.Article.GetHashCode())
  625. {
  626. query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Article.GetHashCode());
  627. query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
  628. }
  629. //Top 100 新书
  630. if (request.DataTypeValue == RankingListConst.NewBook.GetHashCode())
  631. {
  632. query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Book.GetHashCode());
  633. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
  634. }
  635. //文献头条
  636. if (request.DataTypeValue == RankingListConst.ArticleTop.GetHashCode())
  637. {
  638. query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Article.GetHashCode());
  639. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  640. }
  641. if (request.DataTypeValue == RankingListConst.Audio.GetHashCode())
  642. {
  643. query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Audio.GetHashCode());
  644. query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
  645. }
  646. if (request.DataTypeValue == RankingListConst.HotComment.GetHashCode())
  647. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CommentScore));
  648. if (request.DataTypeValue == RankingListConst.CollectionBook.GetHashCode())
  649. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CollectCount));
  650. }
  651. query.Where(nameof(Entity.tede2.Media.Media.IsChecked), true);
  652. query.Where(nameof(Entity.tede2.Media.Media.IsDelete), false);
  653. result.Total = await _repository.CountAsync(query);
  654. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  655. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  656. query.ForPage(request.Page, request.PerPage);
  657. result.Items = await _repository.GetAllAsync<RankingListResult>(query);
  658. foreach (var item in result.Items)
  659. item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
  660. return result;
  661. }
  662. /// <summary>
  663. /// 大咖讲座
  664. /// </summary>
  665. /// <returns></returns>
  666. public async Task<IEnumerable<MediaCathedraResult>> GetMediasByTeacherAsync(ArticleGroupRequest request)
  667. {
  668. var query = Q.NewQuery();
  669. query.Select(nameof(Entity.tede2.Media.Media.Id));
  670. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  671. query.Select(nameof(Entity.tede2.Media.Media.Title));
  672. query.Select(nameof(Entity.tede2.Media.Media.Author));
  673. query.Select(nameof(Entity.tede2.Media.Media.MediaType));
  674. query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
  675. query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
  676. query.Where(nameof(Entity.tede2.Media.Media.TeacherId), ">", 0);
  677. query.Where(nameof(Entity.tede2.Media.Media.MediaType), GxPress.EnumConst.AllTypeConst.Video.GetHashCode());
  678. if (!string.IsNullOrEmpty(request.Sort))
  679. {
  680. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  681. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  682. }
  683. else
  684. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
  685. query.ForPage(request.Page, request.PerPage);
  686. return await _repository.GetAllAsync<MediaCathedraResult>(query);
  687. }
  688. /// <summary>
  689. /// 大咖讲座
  690. /// </summary>
  691. /// <returns></returns>
  692. public async Task<int> GetMediasByTeacherCountAsync(ArticleGroupRequest request)
  693. {
  694. var query = Q.NewQuery();
  695. query.Where(nameof(Entity.tede2.Media.Media.TeacherId), ">", 0);
  696. query.Where(nameof(Entity.tede2.Media.Media.MediaType), GxPress.EnumConst.AllTypeConst.Video.GetHashCode());
  697. return await _repository.CountAsync(query);
  698. }
  699. /// <summary>
  700. /// 每日技能分页
  701. /// </summary>
  702. /// <returns></returns>
  703. public async Task<PagedList<MediaCathedraResult>> GetDaySkillsAsync(MediaDayWeBookRequest request)
  704. {
  705. var resut = new PagedList<MediaCathedraResult>();
  706. var query = Q.NewQuery();
  707. query.Select(nameof(Entity.tede2.Media.Media.Id));
  708. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  709. query.Select(nameof(Entity.tede2.Media.Media.Title));
  710. query.Select(nameof(Entity.tede2.Media.Media.Author));
  711. query.Select(nameof(Entity.tede2.Media.Media.MediaType));
  712. query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
  713. query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
  714. query.Where(nameof(Entity.tede2.Media.Media.IsExercises), true);
  715. query.Where(nameof(Entity.tede2.Media.Media.MediaType), request.TypeValue);
  716. resut.Total = await _repository.CountAsync(query);
  717. if (!string.IsNullOrEmpty(request.Sort))
  718. {
  719. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  720. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  721. }
  722. else
  723. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
  724. query.ForPage(request.Page, request.PerPage);
  725. resut.Items = await _repository.GetAllAsync<MediaCathedraResult>(query);
  726. return resut;
  727. }
  728. /// <summary>
  729. /// 每日技能
  730. /// </summary>
  731. /// <returns></returns>
  732. public async Task<SkillInfo> GetRandomDaySkillAsync()
  733. {
  734. var sql = $@"SELECT
  735. Id,Blocks,MediaType
  736. FROM
  737. tede_media where IsExercises=1 and MediaType={AllTypeConst.Article.GetHashCode()}
  738. ORDER BY RAND() LIMIT 1";
  739. var databaseType = _databaseTypestr.ToEnum<DatabaseType>(DatabaseType.MySql);
  740. var database = new Database(databaseType, _connectionString);
  741. var connection = database.GetConnection();
  742. return await connection.QueryFirstOrDefaultAsync<SkillInfo>(sql);
  743. }
  744. /// <summary>
  745. /// 猜你喜欢
  746. /// </summary>
  747. /// <returns></returns>
  748. public async Task<IEnumerable<MediaCathedraResult>> GetUserLikeAsync()
  749. {
  750. var sql = $@"SELECT
  751. Id,ImageUrls,Title,Author,MediaType,ReadCount,CreatedDate
  752. FROM
  753. tede_media where IsChecked=1 and MediaType={AllTypeConst.Book.GetHashCode()}
  754. ORDER BY RAND() LIMIT 3";
  755. var databaseType = _databaseTypestr.ToEnum<DatabaseType>(DatabaseType.MySql);
  756. var database = new Database(databaseType, _connectionString);
  757. var connection = database.GetConnection();
  758. return await connection.QueryAsync<MediaCathedraResult>(sql);
  759. }
  760. /// <summary>
  761. /// 导航内容
  762. /// </summary>
  763. /// <returns></returns>
  764. public async Task<PagedList<MediaCathedraResult>> GetContentNavigationAsync(MediaContentNavigationRequest request)
  765. {
  766. var resut = new PagedList<MediaCathedraResult>();
  767. var query = Q.NewQuery();
  768. query.Select(nameof(Entity.tede2.Media.Media.Id));
  769. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  770. query.Select(nameof(Entity.tede2.Media.Media.Title));
  771. query.Select(nameof(Entity.tede2.Media.Media.Author));
  772. query.Select(nameof(Entity.tede2.Media.Media.MediaType));
  773. query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
  774. query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
  775. query.Select(nameof(Entity.tede2.Media.Media.Summary));
  776. if (request.MediaIds.Count() > 0)
  777. query.WhereIn(nameof(Entity.tede2.Media.Media.Id), request.MediaIds);
  778. if (request.TeacherId != null && request.TeacherId.Count > 0)
  779. query.WhereIn(nameof(Entity.tede2.Media.Media.TeacherId), request.TeacherId);
  780. resut.Total = await _repository.CountAsync(query);
  781. if (!string.IsNullOrEmpty(request.BeginTime) && !string.IsNullOrEmpty(request.EndTime))
  782. {
  783. query.Where(nameof(Entity.tede2.Media.Media.AddDate), ">=", request.BeginTime);
  784. query.Where(nameof(Entity.tede2.Media.Media.AddDate), "<=", request.EndTime);
  785. }
  786. if (request.Press != null && request.Press.Count > 0)
  787. {
  788. query.OrWhereIn(nameof(Entity.tede2.Media.Media.Press), request.Press);
  789. }
  790. if (!string.IsNullOrEmpty(request.Sort))
  791. {
  792. if (request.Sort.Equals("0"))
  793. {
  794. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  795. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  796. }
  797. if (request.Sort.Equals("1"))
  798. {
  799. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  800. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  801. }
  802. if (request.Sort.Equals("2"))
  803. {
  804. query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
  805. }
  806. if (request.Sort.Equals("3"))
  807. {
  808. query.OrderByDesc(nameof(Entity.tede2.Media.Media.AddDate));
  809. }
  810. if (request.Sort.Equals("4"))
  811. {
  812. query.OrderBy(nameof(Entity.tede2.Media.Media.AddDate));
  813. }
  814. }
  815. else
  816. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
  817. query.ForPage(request.Page, request.PerPage);
  818. resut.Items = await _repository.GetAllAsync<MediaCathedraResult>(query);
  819. foreach (var item in resut.Items)
  820. {
  821. item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
  822. }
  823. return resut;
  824. }
  825. /// <summary>
  826. /// 明栏分页
  827. /// </summary>
  828. /// <returns></returns>
  829. public async Task<PagedList<MediaCathedraResult>> GetStarLablePageAsync(MediaStarLableRequest request)
  830. {
  831. var resut = new PagedList<MediaCathedraResult>();
  832. var query = Q.NewQuery();
  833. query.Select(nameof(Entity.tede2.Media.Media.Id));
  834. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  835. query.Select(nameof(Entity.tede2.Media.Media.Title));
  836. query.Select(nameof(Entity.tede2.Media.Media.Author));
  837. query.Select(nameof(Entity.tede2.Media.Media.MediaType));
  838. query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
  839. query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
  840. if (!string.IsNullOrEmpty(request.KeyWord))
  841. query.WhereLike(nameof(Entity.tede2.Media.Media.Title), $"%{request.KeyWord}%");
  842. query.WhereIn(nameof(Entity.tede2.Media.Media.Id), request.MediaIds);
  843. resut.Total = await _repository.CountAsync(query);
  844. if (!string.IsNullOrEmpty(request.Sort))
  845. {
  846. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  847. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  848. }
  849. else
  850. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
  851. query.ForPage(request.Page, request.PerPage);
  852. resut.Items = await _repository.GetAllAsync<MediaCathedraResult>(query);
  853. foreach (var item in resut.Items)
  854. {
  855. item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
  856. }
  857. return resut;
  858. }
  859. /// <summary>
  860. /// 明栏
  861. /// </summary>
  862. /// <returns></returns>
  863. public async Task<IEnumerable<MediaCathedraResult>> GetStarLablesAsync(MediaStarLableRequest request)
  864. {
  865. var query = Q.NewQuery();
  866. query.Select(nameof(Entity.tede2.Media.Media.Id));
  867. query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
  868. query.Select(nameof(Entity.tede2.Media.Media.Title));
  869. query.Select(nameof(Entity.tede2.Media.Media.Author));
  870. query.Select(nameof(Entity.tede2.Media.Media.MediaType));
  871. query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
  872. query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
  873. query.Select(nameof(Entity.tede2.Media.Media.Summary));
  874. if (!string.IsNullOrEmpty(request.KeyWord))
  875. query.WhereLike(nameof(Entity.tede2.Media.Media.Title), $"%{request.KeyWord}%");
  876. query.WhereIn(nameof(Entity.tede2.Media.Media.Id), request.MediaIds);
  877. if (!string.IsNullOrEmpty(request.Sort))
  878. {
  879. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
  880. query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
  881. }
  882. else
  883. query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
  884. query.ForPage(request.Page, request.PerPage);
  885. var reuslt = await _repository.GetAllAsync<MediaCathedraResult>(query);
  886. foreach (var item in reuslt)
  887. {
  888. item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
  889. }
  890. return reuslt;
  891. }
  892. }
  893. }