using Edu.Common.Enum;
using Edu.Model.Entity.WeChat;
using Edu.Model.ViewModel.WeChat;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.WeChat
{
///
/// 企业微信客户标签仓储层
///
public class RB_WeChat_LableRepository : BaseRepository
{
///
/// 获取分页列表
///
///
///
///
///
///
public List GetPageList(int pageIndex, int pageSize, out long count, RB_WeChat_Lable_ViewModel demodel)
{
string where = $@" 1=1 and r.{nameof(RB_WeChat_Lable_ViewModel.Status)} =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_WeChat_Lable_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.SelectType > 0)
{
if (demodel.SelectType == 1)
{
where += $@" and r.{nameof(RB_WeChat_Lable_ViewModel.ParentId)} =0";
}
else if (demodel.SelectType == 2) {
where += $@" and r.{nameof(RB_WeChat_Lable_ViewModel.ParentId)} >0";
}
}
if (!string.IsNullOrEmpty(demodel.ParentIds))
{
where += $@" and r.{nameof(RB_WeChat_Lable_ViewModel.ParentId)} in({demodel.ParentIds})";
}
string sql = $@"
SELECT * From RB_WeChat_Lable r
WHERE {where}
ORDER BY r.Id asc ";
return GetPage(pageIndex, pageSize, out count, sql).ToList();
}
///
/// 获取列表
///
///
///
public List GetList(RB_WeChat_Lable_ViewModel demodel)
{
string where = $@" 1=1 and r.{nameof(RB_WeChat_Lable_ViewModel.Status)} =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_WeChat_Lable_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.SelectType > 0)
{
if (demodel.SelectType == 1)
{
where += $@" and r.{nameof(RB_WeChat_Lable_ViewModel.ParentId)} =0";
}
else if (demodel.SelectType == 2)
{
where += $@" and r.{nameof(RB_WeChat_Lable_ViewModel.ParentId)} >0";
}
}
if (!string.IsNullOrEmpty(demodel.ParentIds))
{
where += $@" and r.{nameof(RB_WeChat_Lable_ViewModel.ParentId)} in({demodel.ParentIds})";
}
if (!string.IsNullOrEmpty(demodel.LableIds))
{
where += $@" and r.{nameof(RB_WeChat_Lable_ViewModel.Id)} in({demodel.LableIds})";
}
string sql = $@"
SELECT * From RB_WeChat_Lable r
WHERE {where}
ORDER BY r.Id asc ";
return Get(sql).ToList();
}
///
/// 获取指定ID的标签集合
///
///
///
public List GetLabelListByIds(string ids)
{
string sql = $"select * from RB_WeChat_Lable where Id in({ids})";
return Get(sql).ToList();
}
}
}