using Edu.Common.Enum;
using Edu.Model.Entity.WeChat;
using Edu.Model.ViewModel.WeChat;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.WeChat
{
///
/// 投稿图文内容仓储层
///
public class RB_Contribute_InfoRepository : BaseRepository
{
///
/// 获取分页列表
///
///
///
///
///
///
public List GetPageList(int pageIndex,int pageSize,out long count, RB_Contribute_Info_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = $@" 1=1 and r.{nameof(RB_Contribute_Info_ViewModel.Status)} =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.CreateBy > 0)
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.CreateBy)} ={demodel.CreateBy}";
}
if (demodel.MediaState > 0)
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.MediaState)} ={demodel.MediaState}";
}
if (demodel.AuditState >= 0)
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.AuditState)} ={(int)demodel.AuditState}";
}
if (demodel.Type > 0)
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.Type)} ={(int)demodel.Type}";
}
if (!string.IsNullOrEmpty(demodel.Title))
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.Title)} like @Content";
parameters.Add("Content", "%" + demodel.Title + "%");
}
string sql = $@"
SELECT * From RB_Contribute_Info r
WHERE {where}
ORDER BY r.Id DESC ";
return GetPage(pageIndex, pageSize, out count, sql, parameters).ToList();
}
///
/// 获取列表
///
///
///
public List GetList(RB_Contribute_Info_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = $@" 1=1 and r.{nameof(RB_Contribute_Info_ViewModel.Status)} =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.MediaState > 0)
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.MediaState)} ={demodel.MediaState}";
}
if (demodel.AuditState >= 0)
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.AuditState)} ={(int)demodel.AuditState}";
}
if (demodel.Type > 0)
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.Type)} ={(int)demodel.Type}";
}
if (!string.IsNullOrEmpty(demodel.Q_ContributeIds))
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.Id)} in({demodel.Q_ContributeIds})";
}
if (!string.IsNullOrEmpty(demodel.Title))
{
where += $@" and r.{nameof(RB_Contribute_Info_ViewModel.Title)} like @Content";
parameters.Add("Content", "%" + demodel.Title + "%");
}
string sql = $@"
SELECT * From RB_Contribute_Info r
WHERE {where}
ORDER BY r.Id DESC ";
return Get(sql, parameters).ToList();
}
///
/// 获取可发放提成的投稿列表
///
///
///
///
public List GetCanSendCommissionList(int group_Id, string eDate)
{
string sql = $@"SELECT * FROM rb_contribute_info WHERE `Status` =0 and Group_Id ={group_Id}
and AuditState =2 and PublishDate <='{eDate} 23:59:59' and IFNULL(IsSendCommission,0) <>1";
return Get(sql).ToList();
}
}
}