NewsBLL.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using Interface;
  2. using Models;
  3. using Models.Entity.LottomatBaseDB;
  4. using Services;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Web;
  9. namespace Business.ZX
  10. {
  11. public static class NewsBLL
  12. {
  13. private static ZXInterface services;
  14. static NewsBLL()
  15. {
  16. services = new ZXServic();
  17. }
  18. public static List<Base_News> GetPageList(int page, int rows, Dictionary<string, Object> queryParam, out int count, string order = null, bool isDesc = true)
  19. {
  20. List<EExpression> listexp = new List<EExpression>();
  21. if (queryParam!=null&&queryParam.Keys.Count > 0)
  22. {
  23. if (queryParam.ContainsKey("IsDelete"))
  24. {
  25. int IsDelete = int.Parse(queryParam["IsDelete"].ToString());
  26. listexp.Add(new EExpression("IsDelete", "=", IsDelete));
  27. }
  28. if (queryParam.ContainsKey("TypeId"))
  29. {
  30. int TypeId = (int)queryParam["TypeId"];
  31. listexp.Add(new EExpression("TypeId", "=", TypeId));
  32. }
  33. if (queryParam.ContainsKey("CategoryId"))
  34. {
  35. List<string> CategoryId = (List<string>)queryParam["CategoryId"];
  36. listexp.Add(new EExpression("CategoryId", EnumExpression.In, CategoryId));
  37. }
  38. if (queryParam.ContainsKey("CategoryId"))
  39. {
  40. List<string> CategoryId = (List<string>)queryParam["CategoryId"];
  41. listexp.Add(new EExpression("CategoryId", EnumExpression.In, CategoryId));
  42. }
  43. }
  44. var data = services.GetList<Base_News>(page, rows, order, listexp, isDesc);
  45. List<EExpression> countexp = new List<EExpression>(listexp);
  46. count = services.GetPageListCount<Base_News>(countexp);
  47. return data;
  48. }
  49. /// <summary>
  50. /// 查询咨询首页的分类下面最新的5条数据 详情看sql语句
  51. /// </summary>
  52. /// <returns></returns>
  53. public static List<Base_News> GetHomeNewsList(string code)
  54. {
  55. string strSql = @"select top 20 * from Base_News where CategoryId in( SELECT
  56. d.ItemDetailId
  57. FROM Base_DataItemDetail d
  58. LEFT JOIN Base_DataItem i ON i.ItemId = d.ItemId
  59. WHERE 1 = 1
  60. AND d.EnabledMark = 1
  61. AND d.DeleteMark = 0
  62. and i.ItemCode ='{0}'
  63. and d.ItemValue in('3DYC','P3YC','SSQYC','DLT')
  64. )
  65. AND
  66. IsDelete=0
  67. AND
  68. TypeId=1
  69. order by CreateDate desc";
  70. string sql = string.Format(strSql, code);
  71. return services.ExSqlGetList<Base_News>(sql);
  72. }
  73. public static Base_News GetItem(int NewsId)
  74. {
  75. return services.QueryItembyKey<Base_News>(NewsId);
  76. }
  77. /// <summary>
  78. /// 根据newsid查询实体并且前后三条
  79. /// </summary>
  80. /// <param name="NewsId"></param>
  81. /// <returns></returns>
  82. public static List<Base_News> GetGetNewsDetails(string NewsId)
  83. {
  84. string sql = @"declare @dd int=1
  85. set @dd=(SELECT PK
  86. FROM Base_News
  87. where NewsId='{0}')
  88. select * from Base_News
  89. where PK in ( @dd-1,@dd,@dd+1)";
  90. string strsql = string.Format(sql, NewsId);
  91. return services.ExSqlGetList<Base_News>(strsql);
  92. }
  93. public static List<Base_News> GetList(int page, int rows,List<EExpression> list,string order=null, bool isdesc = false)
  94. {
  95. return services.GetList<Base_News>(page, rows, order, list, isdesc);
  96. }
  97. }
  98. }