http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 16362|回复: 1
打印 上一主题 下一主题

[例子] 【苏飞分布式数据框架】一个经典的多表组合使用方法

[复制链接]
跳转到指定楼层
楼主
发表于 2019-11-13 10:18:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我直接贴代码这是一个关于用户的操作类。

[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;
        }
    }




1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
推荐
 楼主| 发表于 2019-11-13 10:18:58 | 只看该作者
Model需要继承这个类
[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);
        }
    }

回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-11-22 01:34

© 2014-2021

快速回复 返回顶部 返回列表