足力健后端,使用.netcore版本,合并1个项目使用

Cus_VIPInfoRepository.cs 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using SqlSugar;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Common;
  5. using System.Data;
  6. using System.IRepositories;
  7. using System.Linq.Expressions;
  8. using System.Model;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace System.Repositories
  12. {
  13. public class Cus_VipInfoRepository : BaseRepository<T_Cus_VipInfo>, ICus_VipInfoRepository
  14. {
  15. public async Task<PageData<V_Cus_VipInfo>> GetListViewByPage(List<IConditionalModel> conModels, MyPageModel pagemodel, string orderby)
  16. {
  17. var list = await Db.SqlQueryable<V_Cus_VipInfo>("select * from T_Cus_VipInfo ").With(SqlWith.NoLock).Where(conModels).OrderBy(orderby).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
  18. var newlist = new List<V_Cus_VipInfo>();
  19. foreach (var item in list)
  20. {
  21. var newmodel = item;
  22. if (item.F_Birthday != null)
  23. newmodel.Birthday = item.F_Birthday.Value.ToString("yyyy-MM-dd");
  24. newmodel.F_Contact = 0;
  25. newlist.Add(newmodel);
  26. }
  27. PageData<V_Cus_VipInfo> pd = new PageData<V_Cus_VipInfo>();
  28. pd.Rows = newlist;
  29. pd.Totals = pagemodel.PageCount;
  30. return pd;
  31. }
  32. public async Task<V_Cus_VipInfo> GetSingleV(Expression<Func<V_Cus_VipInfo, bool>> whereExpression)
  33. {
  34. var model= await Db.SqlQueryable<V_Cus_VipInfo>("select * from T_Cus_VipInfo ").With(SqlWith.NoLock).Where(whereExpression).SingleAsync();
  35. if(model.F_Birthday!=null)
  36. model.Birthday=model.F_Birthday.Value.ToString("yyyy-MM-dd");
  37. return model;
  38. //return CurrentDb.GetSingle(whereExpression);
  39. }
  40. public async Task<int> GetVCount(string Tel,string whereExpression)
  41. {
  42. string sql = "SELECT COUNT(1) FROM T_Cus_VipInfo where F_State=1 ";
  43. sql += $" AND (F_Phone in ({Tel} )or F_Mobile in ( {Tel} )";
  44. if (!string .IsNullOrEmpty (whereExpression))
  45. {
  46. sql += $" { whereExpression} )";
  47. }
  48. else
  49. {
  50. sql += ")";
  51. }
  52. List<SugarParameter> sugarParameter = new List<SugarParameter>()
  53. {
  54. };
  55. DataTable dt = await GetTableSugar(sql);
  56. if (dt != null && dt.Rows.Count > 0)
  57. {
  58. return dt.Rows[0][0].ObjToInt();
  59. }
  60. return 0;
  61. }
  62. public async Task<T_Cus_VipInfo> GetListVipInfo(string where)
  63. {
  64. var list = await Db.SqlQueryable<T_Cus_VipInfo>("select * from T_Cus_VipInfo where "+ where).ToListAsync();
  65. T_Cus_VipInfo pd = new T_Cus_VipInfo();
  66. if (list != null && list.Count > 0)
  67. pd = list[0];
  68. return pd;
  69. }
  70. }
  71. }