コード例 #1
0
        public async Task<NewtonsoftJsonActionResult<ValidateResult>> SendMsg(UsermessageRequest model)
        {
            //注册短信或者忘记密码发送验证当前账号是否已存在
            if (model.type == (int)UserEnum.UserMessEnum.注册 || model.type == (int)UserEnum.UserMessEnum.登陆 || model.type == (int)UserEnum.UserMessEnum.忘记密码)
            {
                UserLoginRequest request = new UserLoginRequest();
                request.account = model.phone;
                request.logintype = (int)UserEnum.UserLogintypeEnum.手机;
                ValidateResult<CrmEntity> ret = await _appUser.GetUser(request);
                if (model.type == (int)UserEnum.UserMessEnum.注册)
                {
                    if (ret.Data != null)
                    {
                        ValidateResult res = new ValidateResult();
                        res.Result = false;
                        res.Description = "当前账号已存在!";
                        return res;
                    }
                }
                else if (model.type == (int)UserEnum.UserMessEnum.忘记密码 || model.type == (int)UserEnum.UserMessEnum.登陆)
                {
                    if (ret.Data == null)
                    {
                        ValidateResult res = new ValidateResult();
                        res.Result = false;
                        res.Description = "当前账号不存在!";
                        return res;
                    }
                }
            }

            Random rad = new Random();
            model.valcode = "1234";// rad.Next(1000, 9999).ToString();
            return await _appUsermessage.Add(model);
        }