AppHomePageService.Search.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using Dapper;
  4. using Datory;
  5. using GxPress.Result.Navigation;
  6. namespace GxPress.Service.Implement.AppHomePage
  7. {
  8. public partial class AppHomePageService
  9. {
  10. /// <summary>
  11. /// 获取搜索作者
  12. /// </summary>
  13. /// <returns></returns>
  14. public async Task<IEnumerable<NavigationSearchTeacherResult>> GetNavigationSearchResultAysnc(int categoryId)
  15. {
  16. var result = new List<NavigationSearchTeacherResult>();
  17. var database = new Database(DatabaseType.MySql, Common.Tools.ConfigHelper.GetValue("Database:ConnectionString"));
  18. var connection = database.GetConnection();
  19. var sql = $"SELECT TeacherId,Author,count(1) as Count FROM tede_media where id in(select MediaId from tede_system_lable_media where TypeValue=1) and Author is not null group by Author,TeacherId";
  20. if (categoryId > 0)
  21. sql = $"SELECT TeacherId,Author,count(1) as Count FROM tede_media where id in(select MediaId from tede_system_lable_media where TypeValue=1 and lableId={categoryId}) and Author is not null group by Author,TeacherId";
  22. return await connection.QueryAsync<NavigationSearchTeacherResult>(sql);
  23. }
  24. /// <summary>
  25. /// 获取出版社
  26. /// </summary>
  27. /// <param name="categoryId"></param>
  28. /// <returns></returns>
  29. public async Task<IEnumerable<string>> GetNavigationPressAsync(int categoryId)
  30. {
  31. var sql = "SELECT Press FROM tede_media where id in(select MediaId from tede_system_lable_media where TypeValue=1) and Press is not null group by Press";
  32. if (categoryId > 0)
  33. sql = "SELECT Press FROM tede_media where id in(select MediaId from tede_system_lable_media where TypeValue=1 and lableId={categoryId}) and Press is not null group by Press";
  34. var result = new List<NavigationSearchTeacherResult>();
  35. var database = new Database(DatabaseType.MySql, Common.Tools.ConfigHelper.GetValue("Database:ConnectionString"));
  36. var connection = database.GetConnection();
  37. return await connection.QueryAsync<string>(sql);
  38. }
  39. }
  40. }