|
@@ -209,9 +209,8 @@ namespace TEAMModeBI.Controllers
|
|
|
name = DDbind.Name,
|
|
|
mobile = DDbind.Mobile,
|
|
|
title = DDbind.Title,
|
|
|
- DeptIdList = DDbind.DeptIdList,
|
|
|
+ deptIdList = DDbind.DeptIdList,
|
|
|
jobNumber = DDbind.JobNumber
|
|
|
-
|
|
|
};
|
|
|
|
|
|
Teacher teacher = null;
|
|
@@ -251,7 +250,7 @@ namespace TEAMModeBI.Controllers
|
|
|
return Ok(new { status = 200, id_token = $"{implicit_token.id_token.ToJsonString()}", access_token = $"{implicit_token.access_token}", expires_in = $"{implicit_token.expires_in}", token_type = $"{implicit_token.token_type}" });
|
|
|
}
|
|
|
}
|
|
|
- return Ok(new { status = 1, dingdinginfo = $"{dingDingBind.ToJsonString()}" });
|
|
|
+ return Ok(new { status = 1, dingdinginfo = dingDingBind });
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
@@ -269,30 +268,38 @@ namespace TEAMModeBI.Controllers
|
|
|
[HttpPost("send-sms")]
|
|
|
public async Task<IActionResult> send_sms(JsonElement jsonElement)
|
|
|
{
|
|
|
- if (!jsonElement.TryGetProperty("country", out JsonElement country)) return BadRequest();
|
|
|
- if (!jsonElement.TryGetProperty("to", out JsonElement to)) return BadRequest();
|
|
|
- if (!jsonElement.TryGetProperty("lang", out JsonElement lang)) return BadRequest();
|
|
|
- if (!jsonElement.TryGetProperty("HasUser", out JsonElement HasUser)) return BadRequest();
|
|
|
-
|
|
|
- string smsurl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
|
|
|
- HttpClient httpClient = new HttpClient();
|
|
|
- var content = new StringContent(jsonElement.ToString(), Encoding.UTF8, "application/json");
|
|
|
- HttpResponseMessage responseMessage = await httpClient.PostAsync($"{smsurl}/service/sandsms/pin", content);
|
|
|
- if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
+ try
|
|
|
{
|
|
|
- string str_json = await responseMessage.Content.ReadAsStringAsync();
|
|
|
- if (string.IsNullOrEmpty($"{str_json}"))
|
|
|
+ if (!jsonElement.TryGetProperty("country", out JsonElement country)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("to", out JsonElement to)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("lang", out JsonElement lang)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("HasUser", out JsonElement HasUser)) return BadRequest();
|
|
|
+
|
|
|
+ string smsurl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
|
|
|
+ HttpClient httpClient = new HttpClient();
|
|
|
+ var content = new StringContent(jsonElement.ToString(), Encoding.UTF8, "application/json");
|
|
|
+ HttpResponseMessage responseMessage = await httpClient.PostAsync($"{smsurl}/service/sandsms/pin", content);
|
|
|
+ if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- return Ok(new { status =200, message="发送成功" });
|
|
|
+ string str_json = await responseMessage.Content.ReadAsStringAsync();
|
|
|
+ if (string.IsNullOrEmpty($"{str_json}"))
|
|
|
+ {
|
|
|
+ return Ok(new { status = 200, message = "发送成功" });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ JsonElement json = str_json.ToObject<JsonElement>();
|
|
|
+ return Ok(json);
|
|
|
+ }
|
|
|
}
|
|
|
- else {
|
|
|
- JsonElement json = str_json.ToObject<JsonElement>();
|
|
|
- return Ok( json );
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(new { status = 0, message = "发送失败!" });
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- return Ok(new { status = 0 , message="发送失败!" });
|
|
|
+ return Ok(new { status = 0, message = $"发送失败!{ex.Message}" });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -305,41 +312,48 @@ namespace TEAMModeBI.Controllers
|
|
|
[HttpPost("verfiypin")]
|
|
|
public async Task<IActionResult> VerifiyPIN(JsonElement jsonElement)
|
|
|
{
|
|
|
- if (!jsonElement.TryGetProperty("mobile", out JsonElement mobile)) return BadRequest();
|
|
|
- if (!jsonElement.TryGetProperty("Authorization_Pin", out JsonElement sms)) return BadRequest();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!jsonElement.TryGetProperty("mobile", out JsonElement mobile)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("Authorization_Pin", out JsonElement sms)) return BadRequest();
|
|
|
|
|
|
- string smsurl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
|
|
|
- HttpClient httpClient = new HttpClient();
|
|
|
- var temp_job = new { Authorization_Pin = sms };
|
|
|
- var content = new StringContent(temp_job.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
- HttpResponseMessage responseMessage = await httpClient.PostAsync($"{smsurl}/service/verifiy/pin", content);
|
|
|
+ string smsurl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
|
|
|
+ HttpClient httpClient = new HttpClient();
|
|
|
+ var temp_job = new { Authorization_Pin = sms };
|
|
|
+ var content = new StringContent(temp_job.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
+ HttpResponseMessage responseMessage = await httpClient.PostAsync($"{smsurl}/service/verifiy/pin", content);
|
|
|
|
|
|
- if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
- {
|
|
|
- string responseBody = await responseMessage.Content.ReadAsStringAsync();
|
|
|
- var json = responseBody.ToObject<JsonElement>();
|
|
|
- json.TryGetProperty("resule", out JsonElement jsone);
|
|
|
- if (!string.IsNullOrEmpty($"{jsone}"))
|
|
|
+ if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- string[] mobules = $"{jsone}".Split("-");
|
|
|
- string temp_mobile = mobules.Length >= 2 ? mobules[1] : mobules[0];
|
|
|
- if (mobile.ToString().Equals(temp_mobile))
|
|
|
+ string responseBody = await responseMessage.Content.ReadAsStringAsync();
|
|
|
+ var json = responseBody.ToObject<JsonElement>();
|
|
|
+ json.TryGetProperty("resule", out JsonElement jsone);
|
|
|
+ if (!string.IsNullOrEmpty($"{jsone}"))
|
|
|
{
|
|
|
- return Ok(new { status = 200, message = "手机号和验证码验证都过了" });
|
|
|
+ string[] mobules = $"{jsone}".Split("-");
|
|
|
+ string temp_mobile = mobules.Length >= 2 ? mobules[1] : mobules[0];
|
|
|
+ if (mobile.ToString().Equals(temp_mobile))
|
|
|
+ {
|
|
|
+ return Ok(new { status = 200, message = "手机号和验证码验证都过了" });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(new { status = 5, message = "手机号码不正确" });
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return Ok(new { status = 5, message = "手机号码不正确" });
|
|
|
+ return Ok(json);
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
-
|
|
|
- return Ok(json);
|
|
|
- }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(new { status = 0, message = "发送状态错误" });
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- return Ok(new { status = 0 , message = "发送状态错误"});
|
|
|
+ return Ok(new { status = 0, message = $"发送状态错误{ex.Message}" });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -413,7 +427,7 @@ namespace TEAMModeBI.Controllers
|
|
|
var ddbind = teacher.ddbinds.Find(x => x.userid.Equals($"{ddbinds.userid}") && x.unionid.Equals($"{ddbinds.unionid}"));
|
|
|
if (ddbind == null)
|
|
|
{
|
|
|
- teacher.ddbinds = new List<DingDingBind> { new DingDingBind { type = $"{type}", unionid = $"{ddbinds.unionid}", userid = $"{ddbinds.userid}", name = $"{ddbinds.name}", mobile = $"{ddbinds.mobile}", title = $"{ddbinds.title}", DeptIdList = ddbinds.DeptIdList, jobNumber = $"{ddbinds.jobNumber}" } };
|
|
|
+ teacher.ddbinds = new List<DingDingBind> { new DingDingBind { type = $"{type}", unionid = $"{ddbinds.unionid}", userid = $"{ddbinds.userid}", name = $"{ddbinds.name}", mobile = $"{ddbinds.mobile}", title = $"{ddbinds.title}", deptIdList = ddbinds.DeptIdList, jobNumber = $"{ddbinds.jobNumber}" } };
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
}
|
|
|
}
|
|
@@ -453,7 +467,7 @@ namespace TEAMModeBI.Controllers
|
|
|
size = 1,
|
|
|
defaultSchool = null,
|
|
|
schools = new List<Teacher.TeacherSchool>(),
|
|
|
- ddbinds = new List<DingDingBind> { new DingDingBind { type = $"{type}", unionid = $"{ddbinds.unionid}", userid = $"{ddbinds.userid}", name = $"{ddbinds.name}", mobile = $"{ddbinds.mobile}", title = $"{ddbinds.title}", DeptIdList = ddbinds.DeptIdList, jobNumber = $"{ddbinds.jobNumber}" } }
|
|
|
+ ddbinds = new List<DingDingBind> { new DingDingBind { type = $"{type}", unionid = $"{ddbinds.unionid}", userid = $"{ddbinds.userid}", name = $"{ddbinds.name}", mobile = $"{ddbinds.mobile}", title = $"{ddbinds.title}", deptIdList = ddbinds.DeptIdList, jobNumber = $"{ddbinds.jobNumber}" } }
|
|
|
};
|
|
|
var container = _azureStorage.GetBlobContainerClient(temp_id);
|
|
|
await container.CreateIfNotExistsAsync(PublicAccessType.None); //尝试创建Teacher私有容器,如存在则不做任何事,保障容器一定存在
|
|
@@ -491,7 +505,7 @@ namespace TEAMModeBI.Controllers
|
|
|
var ddbind = teacher.ddbinds.Find(x => x.userid.Equals($"{ddbinds.userid}") && x.unionid.Equals($"{ddbinds.unionid}"));
|
|
|
if (ddbind == null)
|
|
|
{
|
|
|
- teacher.ddbinds = new List<DingDingBind> { new DingDingBind { type = $"{type}", unionid = $"{ddbind.unionid}", userid = $"{ddbind.userid}", name = $"{ddbind.name}", mobile = $"{ddbind.mobile}", title = $"{ddbind.title}", DeptIdList = ddbind.DeptIdList, jobNumber = $"{ddbind.jobNumber}" } };
|
|
|
+ teacher.ddbinds = new List<DingDingBind> { new DingDingBind { type = $"{type}", unionid = $"{ddbind.unionid}", userid = $"{ddbind.userid}", name = $"{ddbind.name}", mobile = $"{ddbind.mobile}", title = $"{ddbind.title}", deptIdList = ddbind.deptIdList, jobNumber = $"{ddbind.jobNumber}" } };
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
}
|
|
|
|
|
@@ -530,7 +544,7 @@ namespace TEAMModeBI.Controllers
|
|
|
size = 1,
|
|
|
defaultSchool = null,
|
|
|
schools = new List<Teacher.TeacherSchool>(),
|
|
|
- ddbinds = new List<DingDingBind> { new DingDingBind { type = $"{type}", unionid = $"{ddbinds.unionid}", userid = $"{ddbinds.userid}", name = $"{ddbinds.name}", mobile = $"{ddbinds.mobile}", title = $"{ddbinds.title}", DeptIdList = ddbinds.DeptIdList, jobNumber = $"{ddbinds.jobNumber}" } },
|
|
|
+ ddbinds = new List<DingDingBind> { new DingDingBind { type = $"{type}", unionid = $"{ddbinds.unionid}", userid = $"{ddbinds.userid}", name = $"{ddbinds.name}", mobile = $"{ddbinds.mobile}", title = $"{ddbinds.title}", deptIdList = ddbinds.DeptIdList, jobNumber = $"{ddbinds.jobNumber}" } },
|
|
|
};
|
|
|
|
|
|
var container = _azureStorage.GetBlobContainerClient(id);
|