Example #1
0
        public void Inser(UserSignDto dto)
        {
            var entity = _mapper.Map <UserSignDto, UserSignEntity>(dto);

            _funHaiNanContext.UserSign.Add(entity);
            _funHaiNanContext.SaveChanges();
        }
Example #2
0
        /// <summary>
        /// 初始化用户初始数据
        /// author:陶林辉
        /// </summary>
        /// <param name="user">用户注册数据</param>
        /// <param name="login">用户登陆信息</param>
        /// <param name="userInfo">用户信息</param>
        /// <returns>注册用户uerid</returns>
        public long Register(RegisterDto user, UserLoginDto login, UserInfoDto userInfo)
        {
            using (var vTran = _context.Database.BeginTransaction())
            {
                try
                {
                    var vRegister   = _mapper.Map <RegisterDto, RegisterEntity>(user);
                    var vDbRegister = _context.Register;
                    vDbRegister.Add(vRegister);
                    _context.SaveChanges();
                    var vLogin = _mapper.Map <UserLoginDto, UserLoginEntity>(login);
                    vLogin.Userid = vRegister.Userid;
                    var vDbLogin = _context.UserLogin;
                    vDbLogin.Add(vLogin);
                    var vUserInfp = _mapper.Map <UserInfoDto, UserInfoEntity>(userInfo);
                    vUserInfp.Userid = vRegister.Userid;
                    var vDbInfo = _context.UserInfo;
                    vDbInfo.Add(vUserInfp);
                    _context.SaveChanges();
                    vTran.Commit(); //提交事务
                    return(vRegister.Userid);
                }
                catch (global::System.Exception)
                {
                    vTran.Rollback(); //回滚
                    return(0);

                    throw;
                }
            }
        }
Example #3
0
        /// <summary>
        /// H5获取token
        /// author:陶林辉
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <returns></returns>
        public TokenView GetH5Token(long userId)
        {
            var    vInfo = _context.UserLogin.Where(e => e.Userid == userId).FirstOrDefault();
            string token = Guid.NewGuid().ToString();

            RedisHelper.KeyDelete($"{CacheKey.Token}{token}", RedisFolderEnum.token, RedisEnum.Five);
            RedisHelper.StringSet($"{CacheKey.Token}{token}", vInfo, 10080, RedisFolderEnum.token, RedisEnum.Five);
            TokenView result = new TokenView
            {
                token = token
            };

            vInfo.Token = token;
            _context.SaveChanges();
            return(result);
        }