[C#] 纯文本查看 复制代码
/// <summary>
/// 用户信息对象操作类
/// </summary>
public class Yun_UserInfoBLL : BaseDAL<Yun_UserInfo>
{
protected override string ConnName => DALConfig.RuiTuoCMS;
/// <summary>
/// 分页查询
/// </summary>
/// <param name="page"></param>
/// <param name="totalCount"></param>
/// <returns></returns>
public List<Yun_UserInfo> GetListPage(OrmLitePageFactor page, out long totalCount)
{
var pageList = this.FindListPage(page, out totalCount);
if (pageList.Any())
{
var dailiUserList = new Yun_DaiLiBLL().FindList(string.Format("userid in ({0})", string.Join(",", pageList.Select(o => o.dailiuserid))));
var dailiEmployeeList = new Yun_DaiLi_YuanGongBLL().FindList(string.Format("userid in ({0}) and type=2", string.Join(",", pageList.Select(o => o.dailikefuuserid))));
foreach (var pageInfo in pageList)
{
var dailiUserInfo = dailiUserList.SingleOrDefault(o => o.userid == pageInfo.dailiuserid) ?? new Yun_DaiLiInfo();
var dailiEmployeeInfo = dailiEmployeeList.SingleOrDefault(o => o.userid == pageInfo.dailikefuuserid) ?? new Yun_DaiLi_YuanGongInfo();
pageInfo.dailiusername = dailiUserInfo.truename;
pageInfo.dailikefuusername = dailiEmployeeInfo.truename;
}
return pageList;
}
return null;
}
/// <summary>
/// 查询用户信息
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public Yun_UserInfo GetUserInfo(int userId)
{
var userInfo = FindListOne(string.Format("userid={0}", userId));
if (userInfo != null)
{
//查询代理商、客户、设计师名称
var dailiUserInfo = new Yun_DaiLiBLL().FindListOne(string.Format("userid={0}", userInfo.dailiuserid)) ??
new Yun_DaiLiInfo();
var dailiEmployeeInfo = new Yun_DaiLi_YuanGongBLL().FindListOne(string.Format("userid={0} and type=2", userInfo.dailikefuuserid)) ??
new Yun_DaiLi_YuanGongInfo();
userInfo.dailiusername = dailiUserInfo.truename;
userInfo.dailikefuusername = dailiEmployeeInfo.truename;
}
return null;
}
/// <summary>
/// 查询用户信息
/// </summary>
/// <param name="userId">用户ID</param>
/// <param name="agentId">代理ID</param>
/// <returns></returns>
public Yun_UserInfo GetUserInfo(int userId, int agentId)
{
var userInfo = FindListOne(string.Format("userid={0} and dailiuserid={1}", userId, agentId));
if (userInfo != null)
{
//查询代理商、客户、设计师名称
var dailiUserInfo = new Yun_DaiLiBLL().FindListOne(string.Format("userid={0}", userInfo.dailiuserid)) ??
new Yun_DaiLiInfo();
var dailiEmployeeInfo = new Yun_DaiLi_YuanGongBLL().FindListOne(string.Format("userid={0} and type=2", userInfo.dailikefuuserid)) ??
new Yun_DaiLi_YuanGongInfo();
userInfo.dailiusername = dailiUserInfo.truename;
userInfo.dailikefuusername = dailiEmployeeInfo.truename;
}
return null;
}
/// <summary>
/// 查询用户信息
/// </summary>
/// <param name="userId">用户ID</param>
/// <param name="agentId">代理ID</param>
/// <param name="kefuId">客服ID</param>
/// <returns></returns>
public Yun_UserInfo GetUserInfo(int userId, int agentId, int kefuId)
{
var userInfo = FindListOne(string.Format("userid={0} and dailiuserid={1} and dailikefuuserid={2}", userId, agentId, kefuId));
if (userInfo != null)
{
//查询代理商、客户、设计师名称
var dailiUserInfo = new Yun_DaiLiBLL().FindListOne(string.Format("userid={0}", userInfo.dailiuserid)) ??
new Yun_DaiLiInfo();
var dailiEmployeeInfo = new Yun_DaiLi_YuanGongBLL().FindListOne(string.Format("userid={0} and type=2", userInfo.dailikefuuserid)) ??
new Yun_DaiLi_YuanGongInfo();
userInfo.dailiusername = dailiUserInfo.truename;
userInfo.dailikefuusername = dailiEmployeeInfo.truename;
}
return null;
}
/// <summary>
/// 获取下拉列表树
/// </summary>
/// <param name="dailiUserId"></param>
/// <returns></returns>
public dynamic GetTreeString(int dailiUserId)
{
string sql = "1=1";
if (dailiUserId > 0)
{
sql += " and dailiuserid=" + dailiUserId + " order by truename";
}
var list = FindList(sql);
List<dynamic> dyList = new List<dynamic>();
List<dynamic> child = new List<dynamic>();
dynamic dy = new ExpandoObject();
dy.id = "0";
dy.label = "全部";
dyList.Add(dy);
if (list.Any())
{
foreach (var info in list)
{
if (info.truename.Trim().Length >= 1)
{
info.AddExData("parentid", PinYin.GetCodstring(info.truename.Substring(0, 1)));
}
}
foreach (string zm in PinYin.ZMList)
{
var data = list.FindAll(o => o.GetExData<string>("parentid") == zm);
if (data.Any())
{
child = new List<dynamic>();
foreach (var info in data)
{
dy = new ExpandoObject();
dy.id = info.userid.ToString();
dy.label = info.truename;
child.Add(dy);
}
dy = new ExpandoObject();
dy.id = zm;
dy.label = zm;
dy.children = child;
dyList.Add(dy);
}
}
}
return dyList;
}
}
[C#] 纯文本查看 复制代码
/// <summary>
/// 模型层附加数据基类
/// </summary>
[Serializable]
public class BaseModel
{
private Dictionary<string, object> _exData = new Dictionary<string, object>();
/// <summary>
/// 附件数据
/// </summary>
public Dictionary<string, object> ExData
{
get { return _exData; }
set { _exData = value; }
}
/// <summary>
/// 得到附加数据
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="name"></param>
/// <returns></returns>
public T GetExData<T>(string name)
{
object data;
if (_exData.TryGetValue(name, out data))
{
return (T)data;
}
return default(T);
}
/// <summary>
/// 添加附加数据
/// </summary>
/// <param name="name"></param>
/// <param name="obj"></param>
public void AddExData(string name, object obj)
{
_exData.Add(name, obj);
}
/// <summary>
/// 检测附加数据是否存在
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public bool ExistsExData(string name)
{
return _exData.ContainsKey(name);
}
}