示例#1
0
        public ApiResult HashGet(int id)
        {
            UserModel entity = null;
            Dictionary <string, string> dicHash;

            try
            {
                string key = $"{0}:{1}:" + 2;

                dicHash = RedisBase.Core.GetAllEntriesFromHash(key);

                if (dicHash != null && dicHash.Count > 0)
                {
                    entity = new UserModel
                    {
                        Uid      = id,
                        NickName = RedisBase.GetHashValue(dicHash, $"{0}:"),
                        UserName = RedisBase.GetHashValue(dicHash, $"{1}:"),
                        Sex      = RedisBase.GetHashValue(dicHash, $"{2}:") == "1",
                        HeadUrl  = RedisBase.GetHashValue(dicHash, $"{3}:"),
                        PhoneNo  = RedisBase.GetHashValue(dicHash, $"{4}:"),
                        Address  = RedisBase.GetHashValue(dicHash, $"{5}:"),
                    };
                }
            }
            catch
            {
            }
            return(ApiResult.ReturnWebResult(true, "", entity));
        }