Example #1
0
        /// <summary>
        /// 模块 列表
        /// </summary>
        /// <returns></returns>
        public IList <RBAC.Module> ModuleWidthFuncList()
        {
            var sql = @"select * from Module;select * from Func;";

            return(Try(nameof(ModuleWidthFuncList), () =>
            {
                var cmd = SqlBuilder.Raw(sql).ToCommand();
                using (var reader = TradeConn.QueryMultiple(cmd))
                {
                    var ms = reader.Read <RBAC.Module>();
                    if (ms != null)
                    {
                        var fs = reader.Read <RBAC.Func>();
                        if (fs != null)
                        {
                            foreach (var m in ms)
                            {
                                m.Funcs = fs.Where(x => x.Mid == m.Id).ToList();
                            }
                        }
                    }
                    return ms.ToList();
                }
            }));
        }
 /// <summary>
 /// 获取订单
 /// </summary>
 /// <param name="id">订单id</param>
 /// <param name="userId">用户id</param>
 /// <param name="isSeller">是否为卖家</param>
 /// <param name="includeItems">是否包含明细</param>
 /// <returns></returns>
 public Order OrderGet(string id, int userId, bool isSeller, bool includeItems = false)
 {
     return(Try(nameof(OrderGet), () =>
     {
         if (includeItems)
         {
             var sql = @"select * from orderinfo where id=@id and BuyerId=@userId;select * from orderitem where orderid=@id and BuyerId=@userId;";
             if (isSeller)
             {
                 sql = @"select * from orderinfo where id=@id and SellerId=@userId;select * from orderitem where orderid=@id and SellerId=@userId;;";
             }
             var cmd = SqlBuilder.Raw(sql, new { id, userId }).ToCommand();
             using (var reader = TradeConn.QueryMultiple(cmd))
             {
                 var o = reader.Read <Order>().FirstOrDefault();
                 if (o != null)
                 {
                     o.Items = reader.Read <OrderItem>().ToList();
                 }
                 return o;
             }
         }
         else
         {
             var cmd = SqlBuilder
                       .Select("*").From("orderinfo")
                       .Where("id=@id", new { id })
                       .Where(isSeller ? "SellerId=@userId" : "BuyerId=@userId", new { userId })
                       .ToCommand();
             return TradeConn.QueryFirstOrDefault <Order>(cmd);
         }
     }));
 }