ソースを参照

钉钉扫码未绑定醍摩豆账户返回信息更改,和钉钉信息的数据结构更改。

Li 3 年 前
コミット
18ddac87ff

+ 63 - 49
TEAMModeBI/Controllers/LoginController.cs

@@ -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);

+ 181 - 9
TEAMModelOS.SDK/Models/Cosmos/Teacher/Teacher.cs

@@ -55,6 +55,87 @@ namespace TEAMModelOS.SDK.Models
             /// </summary>
             public string type { get; set; }
 
+            /// <summary>
+            /// 是否激活
+            /// </summary>
+            public string active { get; set; }
+
+            /// <summary>
+            /// 是否管理员
+            /// </summary>
+            public string admin { get; set; }
+
+            /// <summary>
+            /// 头像
+            /// </summary>
+            public string avatar { get; set; }
+
+            /// <summary>
+            /// 是否老板
+            /// </summary>
+            public string boss { get; set; }
+
+            /// <summary>
+            /// 所属部门id列表
+            /// </summary>
+            public List<long> deptIdList { get; set; }
+
+            /// <summary>
+            /// 员工在对应的部门中的排序
+            /// </summary>
+            public List<DeptOrderDomain> deptOrderList { get; set; }
+
+            /// <summary>
+            /// 任职信息
+            /// </summary>
+            public List<DeptPositionDomain> deptPositionList { get; set; }
+
+            /// <summary>
+            /// 员工工号
+            /// </summary>
+            public string jobNumber { get; set; }
+
+            /// <summary>
+            /// 员工在对应的部门中是否领导。
+            /// </summary>
+            public List<DeptLeaderDomain> leaderInDept { get; set; }
+
+            /// <summary>
+            /// 主管的ID,仅限企业内部开发调用
+            /// </summary>
+            public string managerUserid { get; set; }
+
+            /// <summary>
+            /// 手机号
+            /// </summary>
+            public string mobile { get; set; }
+
+            /// <summary>
+            /// 角色列表
+            /// </summary>
+            public List<UserRoleDomain> roleList { get; set; }
+
+            /// <summary>
+            /// 是否高管
+            /// </summary>
+            public string senior { get; set; }
+
+            /// <summary>
+            /// 职位名称
+            /// </summary>
+            public string title { get; set; }
+
+            /// <summary>
+            /// 关联信息
+            /// </summary>
+            public string unionEmpExt { get; set; }
+
+            /// <summary>
+            /// 钉钉用户名
+            /// </summary>
+            public string name { get; set; }
+
+
             /// <summary>
             /// 钉钉unionid
             /// </summary>
@@ -64,31 +145,122 @@ namespace TEAMModelOS.SDK.Models
             /// 钉钉ID
             /// </summary>
             public string userid { get; set; }
+        }
 
+        /// <summary>
+        /// 员工在对应的部门中的排序的数据结构
+        /// </summary>
+        public class DeptOrderDomain 
+        {
             /// <summary>
-            /// 钉钉用户名
+            /// 部门id
             /// </summary>
-            public string name { get; set; }
+            public string deptId { get; set; }
 
             /// <summary>
-            /// 手机号
+            /// 员工在部门中的排序。
             /// </summary>
-            public string mobile { get; set; }
+            public string order { get; set; }
+        }
 
+        /// <summary>
+        /// 任职信息数据结构
+        /// </summary>
+        public class DeptPositionDomain 
+        {
             /// <summary>
-            /// 职位名称
+            /// 部门ID
+            /// </summary>
+            public string deptId { get; set; }
+
+            /// <summary>
+            /// 是否是主任职
+            /// </summary>
+            public string isMain { get; set; }
+
+            /// <summary>
+            /// 部门内职位
             /// </summary>
             public string title { get; set; }
 
             /// <summary>
-            /// 所属部门id列表
+            /// 部门内工作地
             /// </summary>
-            public List<long> DeptIdList { get; set; }
+            public string workPlace { get; set; }
+        }
 
+        /// <summary>
+        /// 员工在对应的部门中是否领导 数据结构
+        /// </summary>
+        public class DeptLeaderDomain 
+        {
             /// <summary>
-            /// 员工工号
+            /// 部门id
             /// </summary>
-            public string jobNumber { get; set; }
+            public string deptId { get; set; }
+
+            /// <summary>
+            /// 是否领导
+            /// </summary>
+            public string leader { get; set; }
+        }
+
+        /// <summary>
+        /// 角色列表 数据结构
+        /// </summary>
+        public class UserRoleDomain 
+        {
+            /// <summary>
+            /// 角色组名称
+            /// </summary>
+            public string groupName { get; set; }
+
+            /// <summary>
+            /// 角色id
+            /// </summary>
+            public string id { get; set; }
+
+            /// <summary>
+            /// 角色名称
+            /// </summary>
+            public string name { get; set; }
+        }
+
+        /// <summary>
+        /// 关联信息 数据结构
+        /// </summary>
+        public class UnionEmpExtDomain
+        {
+            /// <summary>
+            /// 企业ID
+            /// </summary>
+            public string corpId { get; set; }
+
+            /// <summary>
+            /// 关联映射关系
+            /// </summary>
+            public List<UnionEmpMapVoDomain> unionEmpMapList{get;set;}
+
+            /// <summary>
+            /// 员工id
+            /// </summary>
+            public string userid { get; set; }
+        }
+
+        /// <summary>
+        /// 关联映射关系
+        /// </summary>
+        public class UnionEmpMapVoDomain
+        {
+            /// <summary>
+            /// 企业id
+            /// </summary>
+            public string corpId { get; set; }
+
+            /// <summary>
+            /// 用户id
+            /// </summary>
+            public string userid { get; set; }
         }
 
     }