public HttpResponseMessage CreateAccount([FromUri] CreateAccountRequest request) { logInfo.Info(string.Format("创建账号接口请求串:{0}", request.ToJson())); var viewModel = new SmsAccountViewModel(); if (!ModelState.IsValid) { viewModel.BusinessStatus = -10000; string msg = ModelState.Values.Where(item => item.Errors.Count == 1).Aggregate(string.Empty, (current, item) => current + (item.Errors[0].ErrorMessage + "; ")); viewModel.StatusMessage = "输入参数错误," + msg; return(viewModel.ResponseToJson()); } var response = _smsService.CreateAccount(request, Request.GetQueryNameValuePairs()); logInfo.Info("创建账号接口返回值" + response.ToJson()); if (response.ErrCode == -2) { viewModel.BusinessStatus = -10003; viewModel.StatusMessage = response.ErrMsg;//账号已存在 return(viewModel.ResponseToJson()); } if (response.Status == HttpStatusCode.BadRequest || response.Status == HttpStatusCode.Forbidden) { viewModel.BusinessStatus = -10001; viewModel.StatusMessage = "参数校验错误,请检查您的校验码"; return(viewModel.ResponseToJson()); } if (response.Status == HttpStatusCode.ExpectationFailed) { viewModel.BusinessStatus = -10002; viewModel.StatusMessage = response.ErrMsg; return(viewModel.ResponseToJson()); } if (response.Status == HttpStatusCode.OK) { viewModel.BusinessStatus = 1; viewModel.SmsAccount = response.SmsAccount.ConverToViewModel(); } else { viewModel.BusinessStatus = -10002; viewModel.StatusMessage = response.ErrMsg; } return(viewModel.ResponseToJson()); }