///<summary> /// 用户收藏信息获取 ///</summary> ///<param name="userId">用户id</param> ///<returns></returns> public IList <UserFavorite> UserFavoriteList(int userId) { return(Try(nameof(UserFavoriteList), () => { var sql = @"select * from UserFavorite where userId=@userId"; var cmd = SqlBuilder.Raw(sql, new { userId }).ToCommand(); return PassportConn.Query <UserFavorite>(cmd).ToList(); })); }
/// <summary> /// 用户地址获取 /// </summary> /// <param name="userId">用户id</param> /// <param name="groupId">地址分组 0为收货地址 2发货地址 3退货地址</param> /// <returns></returns> public IList <UserAddress> UserAddressList(int userId, byte?groupId = null) { return(Try(nameof(UserAddressList), () => { var cmd = SqlBuilder.Select("*") .From("UserAddress") .Where("UserId=@userId", new { userId }) .Where(groupId.HasValue, "GroupId=@groupId", new { groupId }) .ToCommand(); return PassportConn.Query <UserAddress>(cmd).ToList(); })); }
/// <summary> /// 用户名是否已存在 /// </summary> /// <param name="uid">用户名/绑定邮箱/绑定手机号</param> /// <returns></returns> public bool UserExist(string uid) { return(Try(nameof(UserExist), () => { var sql = @"select 0 from user where name=@uid union select 0 from user where mobile=@uid union select 0 from user where email=@uid "; var cmd = SqlBuilder.Raw(sql, new { uid }).ToCommand(); return PassportConn.Query <int>(cmd).Any(); })); }