Example #1
0
        public (dynamic, int) GetTableData(string subtable, int page, int count, string json, JObject dd)
        {
            if (!subtable.IsTable())
            {
                throw new Exception($"表名{subtable}不正确!");
            }
            var role = _identitySvc.GetSelectRole(subtable);

            if (!role.Item1)//没有权限返回异常
            {
                throw new Exception(role.Item2);
            }
            string selectrole = role.Item2;

            subtable = _tableMapper.GetTableName(subtable);
            JObject values = JObject.Parse(json);

            page  = values["page"] == null ? page : int.Parse(values["page"].ToString());
            count = values["count"] == null ? count : int.Parse(values["count"].ToString());
            values.Remove("page");
            values.Remove("count");
            var tb = sugarQueryable(subtable, selectrole, values, dd);

            if (count > 0)
            {
                int total = 0;
                return(tb.ToPageList(page, count, ref total), total);
            }
            else
            {
                return(tb.ToList(), tb.Count());
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="subtable"></param>
        /// <param name="page"></param>
        /// <param name="count"></param>
        /// <param name="json"></param>
        /// <param name="dd"></param>
        /// <returns></returns>
        public Tuple <dynamic, int> GetTableData(string subtable, int page, int count, int query, string json, JObject dd)
        {
            var role = _identitySvc.GetSelectRole(subtable);

            if (!role.Item1)//没有权限返回异常
            {
                throw new Exception(role.Item2);
            }
            string selectrole = role.Item2;

            subtable = _tableMapper.GetTableName(subtable);

            JObject values = JObject.Parse(json);

            page  = values["page"] == null ? page : int.Parse(values["page"].ToString());
            count = values["count"] == null ? count : int.Parse(values["count"].ToString());
            query = values["query"] == null ? query : int.Parse(values["query"].ToString());
            values.Remove("page");
            values.Remove("count");
            var tb = sugarQueryable(subtable, selectrole, values, dd);

            if (query == 1)//1-总数
            {
                return(new Tuple <dynamic, int>(new List <object>(), tb.Count()));
            }
            else
            {
                if (count > 0)
                {
                    int total = 0;
                    if (query == 0)//0-对象
                    {
                        return(new Tuple <dynamic, int>(tb.ToPageList(page, count), total));
                    }
                    else
                    {
                        //2-以上全部
                        return(new Tuple <dynamic, int>(tb.ToPageList(page, count, ref total), total));
                    }
                }
                else
                {
                    if (query == 0)
                    {
                        return(new Tuple <dynamic, int>(tb.ToList(), 0));
                    }
                    else
                    {
                        return(new Tuple <dynamic, int>(tb.ToList(), tb.Count()));
                    }
                }
            }
        }
Example #3
0
        private string ToSql(string subtable, int page, int count, int query, string json)
        {
            JObject values = JObject.Parse(json);

            page  = values["page"] == null ? page : int.Parse(values["page"].ToString());
            count = values["count"] == null ? count : int.Parse(values["count"].ToString());
            query = values["query"] == null ? query : int.Parse(values["query"].ToString());
            values.Remove("page");
            values.Remove("count");
            subtable = _tableMapper.GetTableName(subtable);
            var tb = sugarQueryable(subtable, "*", values, null);
            var xx = tb.Skip((page - 1) * count).Take(10).ToSql();

            return(xx.Key);
        }