Browse Source

钉钉扫码登录接口,扫码成功并找到该成员返回200,扫码成功没有该组织没有该成员返回-1,扫码成功教师没有绑定成员返回0

Li 3 năm trước cách đây
mục cha
commit
b93b68e914

+ 1 - 1
TEAMModeBI/ClientApp/package.json

@@ -13,7 +13,7 @@
         "core-js": "^3.7.0",
         "element-plus": "^1.1.0-beta.24",
         "less": "^4.1.2",
-        "vue": "^3.0.2",
+        "vue": "^3.2.0",
         "vue-loader-v16": "npm:vue-loader@^16.0.0-alpha.3",
         "vue-router": "^4.0.0-rc.5"
     },

+ 72 - 4
TEAMModeBI/Controllers/BISchool/BatchAreaController.cs

@@ -1,5 +1,7 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Options;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -8,6 +10,10 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
 
+using DingTalk.Api;
+using DingTalk.Api.Request;
+using DingTalk.Api.Response;
+
 namespace TEAMModeBI.Controllers.BISchool
 {
     [Route("batcharea")]
@@ -20,21 +26,83 @@ namespace TEAMModeBI.Controllers.BISchool
         private readonly Option _option;
         private readonly AzureStorageFactory _azureStorage;
 
-        public BatchAreaController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, Option option)
+        public BatchAreaController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option)
         {
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _azureStorage = azureStorage;
-            _option = option;
+            _option = option?.Value;
         }
 
         //public async Task<IActionResult> BatchArea(Area area) 
         //{
-            
-        //}
 
+        //}
 
 
+        private readonly IConfiguration _configuration;
+        public IActionResult DingDingLogin(string loginTmpCode)
+        {
+            string appKey = _configuration["DingDingAuth:appKey"];
+            string appSecret = _configuration["DingDingAuth:appSecret"];
+            string getuserinfo_bycode = _configuration["DingDingAuth:getuserinfo_bycode"];
+            //判断参数是否为空
+            if (string.IsNullOrEmpty(loginTmpCode))
+            {
+                return BadRequest("temp code error");
+            }
+            //获取access_token
+            DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
+            OapiGettokenRequest request = new OapiGettokenRequest();
+            request.Appkey = appKey;
+            request.Appsecret = appSecret;
+            request.SetHttpMethod("Get");
+            OapiGettokenResponse response = client.Execute(request);
+            if (response.IsError)
+            {
+                return BadRequest();
+            }
+            string access_token = response.AccessToken;
+            //获取临时授权码 获取授权用户的个人信息
+            DefaultDingTalkClient client1 = new DefaultDingTalkClient("https://oapi.dingtalk.com/sns/getuserinfo_bycode");
+            OapiSnsGetuserinfoBycodeRequest bycodeRequest = new OapiSnsGetuserinfoBycodeRequest()
+            {
+                //通过扫描二维码,跳转到指定的Url后,向Url中追加Code临时授权码
+                TmpAuthCode = loginTmpCode
+            };
+            OapiSnsGetuserinfoBycodeResponse bycodeResponse = client1.Execute(bycodeRequest, appKey, appSecret);
+            if (bycodeResponse.IsError)
+            {
+                return BadRequest();
+            }
+            //根据unionid获取userid
+            string unionid = bycodeResponse.UserInfo.Unionid;
+            DefaultDingTalkClient clientDingTalkClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/user/getbyunionid");
+            OapiUserGetbyunionidRequest byunionidRequest = new OapiUserGetbyunionidRequest()
+            {
+                Unionid = unionid
+            };
+            OapiUserGetbyunionidResponse byunionidResponse = clientDingTalkClient.Execute(byunionidRequest, access_token);
+            if (byunionidResponse.IsError)
+            {
+                return BadRequest();
+            }
+            string userid = byunionidResponse.Result.Userid;
+            //根据userId获取用户信息
+            DefaultDingTalkClient clientDingTalkClient2 = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
+            OapiV2UserGetRequest getRequest = new OapiV2UserGetRequest()
+            {
+                Userid = userid,
+                Language = "zh_CN"
+            };
+            getRequest.SetHttpMethod("Get");
+            OapiV2UserGetResponse getResponse = clientDingTalkClient2.Execute(getRequest, access_token);
+            if (getResponse.IsError)
+            {
+                return BadRequest();
+            }
+            return Ok(getResponse.Body);
+        }
 
 
     }

+ 3 - 2
TEAMModeBI/Controllers/BISchool/BatchSchoolController.cs

@@ -1,6 +1,7 @@
 using Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Options;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -21,12 +22,12 @@ namespace TEAMModeBI.Controllers.BISchool
         private readonly Option _option;
         private readonly AzureStorageFactory _azureStorage;
 
-        public BatchSchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, Option option)
+        public BatchSchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option)
         {
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _azureStorage = azureStorage;
-            _option = option;
+            _option = option?.Value;
         }
 
         /// <summary>

+ 10 - 9
TEAMModeBI/Controllers/DingDingLogin/DDBindController.cs

@@ -3,6 +3,7 @@ using Azure.Storage.Blobs.Models;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Options;
 using System;
 using System.Collections.Generic;
 using System.IdentityModel.Tokens.Jwt;
@@ -24,12 +25,12 @@ namespace TEAMModeBI.Controllers.DingDingLogin
         private readonly AzureStorageFactory _azureStorage;
         public readonly string type = "ddteammodel";
 
-        public DDBindController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, Option option)
+        public DDBindController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option)
         {
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _azureStorage = azureStorage;
-            _option = option;
+            _option = option?.Value;
         }
 
         /// <summary>
@@ -64,12 +65,12 @@ namespace TEAMModeBI.Controllers.DingDingLogin
                 {
                     if (teacher.id.Equals(id))
                     {
-                        var ddbind = teacher.ddbinds.Find(x => x.userid.Equals($"{ddrcord.userid}") && x.loginid.Equals($"{ddrcord.loginid}"));
-                        if (ddbind == null)
-                        {
-                            teacher.ddbinds = new List<Teacher.DingDingBind> { new Teacher.DingDingBind { type = type, loginid = $"{ddrcord.loginid}", userid = $"{ddrcord.userid}", userName = $"{ddrcord.userName}", Mobile = $"{ddrcord.mobile}", email = $"{ddrcord.email}", sourceid = ddrcord.sourceid } };
-                            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
-                        }
+                        //var ddbind = teacher.ddbinds.Find(x => x.userid.Equals($"{ddrcord.userid}") && x.loginid.Equals($"{ddrcord.loginid}"));
+                        //if (ddbind == null)
+                        //{
+                        //    teacher.ddbinds = new List<Teacher.DingDingBind> { new Teacher.DingDingBind { type = type, loginid = $"{ddrcord.loginid}", userid = $"{ddrcord.userid}", userName = $"{ddrcord.userName}", Mobile = $"{ddrcord.mobile}", email = $"{ddrcord.email}", sourceid = ddrcord.sourceid } };
+                        //    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
+                        //}
                     }
                     else
                     {
@@ -98,7 +99,7 @@ namespace TEAMModeBI.Controllers.DingDingLogin
                         size = 1,
                         defaultSchool = null,
                         schools = new List<Teacher.TeacherSchool>(),
-                        ddbinds = new List<Teacher.DingDingBind> { new Teacher.DingDingBind { type = type, loginid = $"{ddrcord.loginid.ToString()}", userid = $"{ddrcord.userid.ToString()}", userName = $"{ddrcord.userName}", Mobile = $"{ddrcord.mobile}", email = $"{ddrcord.email}", sourceid = ddrcord.sourceid } }
+                        //ddbinds = new List<Teacher.DingDingBind> { new Teacher.DingDingBind { type = type, loginid = $"{ddrcord.loginid.ToString()}", userid = $"{ddrcord.userid.ToString()}", userName = $"{ddrcord.userName}", Mobile = $"{ddrcord.mobile}", email = $"{ddrcord.email}", sourceid = ddrcord.sourceid } }
                     };
 
                     var container = _azureStorage.GetBlobContainerClient(id);

+ 61 - 161
TEAMModeBI/Controllers/LoginController.cs

@@ -15,11 +15,15 @@ using TEAMModelOS.SDK.Models;
 using HTEXLib.COMM.Helpers;
 using TEAMModelOS.Models;
 using static TEAMModelOS.SDK.Models.Teacher;
+using Microsoft.Extensions.Options;
+using TEAMModelOS.SDK.Extension;
+using TEAMModelOS.SDK.Models.Service;
+using static TEAMModelOS.Controllers.Third.ScController;
 
 namespace TEAMModeBI.Controllers
 {
-    //[ProducesResponseType(StatusCodes.Status200OK)]
-    //[ProducesResponseType(StatusCodes.Status400BadRequest)]
+    [ProducesResponseType(StatusCodes.Status200OK)]
+    [ProducesResponseType(StatusCodes.Status400BadRequest)]
     [Route("common/login")]
     [ApiController]
     public class LoginController : ControllerBase
@@ -32,13 +36,18 @@ namespace TEAMModeBI.Controllers
         //钉钉提示信息
         private readonly DingDing _dingDing;
         private readonly Option _option;
-        public LoginController(IConfiguration configuration, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, DingDing dingDing, Option option)
+        //隐世登录
+        private readonly CoreAPIHttpService _accountHttpService;
+        string type = "ddteammodel";
+
+        public LoginController(IConfiguration configuration, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, CoreAPIHttpService coreAPIHttpService)
         {
             _configuration = configuration;
             _azureCosmos = azureCosmos;
             _azureStorage = azureStorage;
             _dingDing = dingDing;
-            _option = option;
+            _option = option?.Value;
+            _accountHttpService = coreAPIHttpService;
         }
 
         /// <summary>
@@ -118,7 +127,7 @@ namespace TEAMModeBI.Controllers
         /// <returns>Json结果</returns>
         [ProducesDefaultResponseType]
         [HttpGet("DingLogin")]
-        public async Task<IActionResult> DingLogin(JsonElement jsonElement)
+        public async Task<IActionResult> DingLogin(string LoginTempCode)
         {
             string temp_mess = null;
             //state 是前端传入的,钉钉并不会修改,比如有多种登录方式的时候,一个登录方法判断登录方式可以进行不同的处理。
@@ -126,14 +135,13 @@ namespace TEAMModeBI.Controllers
             {
                 string str_appKey = _configuration["DingDingAuth:appKey"];
                 string str_appSecret = _configuration["DingDingAuth:appSecret"];
-                string str_agentld = "1290158212";
                 if (string.IsNullOrWhiteSpace(str_appKey) || string.IsNullOrWhiteSpace(str_appSecret))
                 {
-                    throw new Exception("请先配置钉钉扫码登录信息!");
+                    return BadRequest("请先配置钉钉扫码登录信息!");
                 }
                 //自己传的code
-                if (jsonElement.TryGetProperty("tempCode", out JsonElement LoginTempCode)) return BadRequest();
-                string accreCode = LoginTempCode.ToString();
+                //if (!jsonElement.TryGetProperty("tempCode", out JsonElement LoginTempCode)) return BadRequest();
+                string loginTempCode = LoginTempCode.ToString();
                 //判断参数是否为空
                 if (string.IsNullOrEmpty(LoginTempCode.ToString()))
                 {
@@ -149,50 +157,23 @@ namespace TEAMModeBI.Controllers
                 OapiGettokenResponse tokenResponse = Iclient.Execute(request);
                 if (tokenResponse.IsError)
                 {
-                    return BadRequest();
+                    return Ok(new { ddbinds = $"status=-1"});
                 }
 
-                //temp_mess = tokenResponse.Body;
-                //获取引用后台免登录凭证
-                DefaultDingTalkClient NoVoucher = new DefaultDingTalkClient("https://oapi.dingtalk.com/sso/gettoken");
-                OapiSsoGettokenRequest ssoRequest = new OapiSsoGettokenRequest();
-                ssoRequest.Corpid = str_agentld;
-                ssoRequest.Corpsecret = str_appSecret;
-                ssoRequest.SetHttpMethod("GET");
-                OapiSsoGettokenResponse ssoResponse = new OapiSsoGettokenResponse();
-                ssoResponse = NoVoucher.Execute(ssoRequest);
-
-                //temp_mess += "=====" + ssoResponse.Body;
-                ////return Ok(tokenResponse.Body);
-                ////自己传的code
-                //if (!jsonElement.TryGetProperty("accreCode", out JsonElement jsaccreCode)) return BadRequest();
-                //string accreCode = jsaccreCode.ToString();
-
-                //自己获取code
-                //string accreCode = tokenResponse.AccessToken;
-                //temp_mess += "====="+accreCode;
-
+                string access_token = tokenResponse.AccessToken;
+                //获取临时授权码 获取授权用户的个人信息
                 DefaultDingTalkClient clientinfo = new DefaultDingTalkClient("https://oapi.dingtalk.com/sns/getuserinfo_bycode");
-                OapiSnsGetuserinfoBycodeRequest req = new OapiSnsGetuserinfoBycodeRequest() { TmpAuthCode = accreCode };
-                //req.TmpAuthCode = code;
+                OapiSnsGetuserinfoBycodeRequest req = new OapiSnsGetuserinfoBycodeRequest() { TmpAuthCode = loginTempCode };  //通过扫描二维码,跳转到指定的Url后,向Url中追加Code临时授权码
                 OapiSnsGetuserinfoBycodeResponse response = clientinfo.Execute(req, str_appKey, str_appSecret);
-                //temp_mess += "====="+ response.Body;
-                //return Ok(temp_mess);
-                ////return Ok(response.Body); //用户信息代检验;
-                ////获取到response后就可以进行自己的登录业务处理了
-                ////xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
                 if (response.IsError)
                 {
                     return BadRequest();
                 }
 
-                //temp_mess += response.UserInfo;
-                //根据unionid获取userid
                 string unionid = response.UserInfo.Unionid;
                 IDingTalkClient client2 = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/user/getbyunionid"); //userid地址
                 OapiUserGetbyunionidRequest byunionidRequest = new OapiUserGetbyunionidRequest() { Unionid = unionid };
-                OapiUserGetbyunionidResponse byunionidResponse = client2.Execute(byunionidRequest, accreCode);
+                OapiUserGetbyunionidResponse byunionidResponse = client2.Execute(byunionidRequest, access_token);
                 if (byunionidResponse.IsError)
                 {
                     return BadRequest();
@@ -206,150 +187,69 @@ namespace TEAMModeBI.Controllers
                     Language = "zh_CN"
                 };
                 v2GetRequest.SetHttpMethod("POST");
-                OapiV2UserGetResponse v2GetResponse = client3.Execute(v2GetRequest, accreCode);
+                OapiV2UserGetResponse v2GetResponse = client3.Execute(v2GetRequest, access_token);
                 if (v2GetResponse.IsError)
                 {
                     return BadRequest();
                 }
 
                 var DDbind = v2GetResponse.Result;
-
-                DingDingBind dingDingBind = new()
+                //return Ok(new { v2GetResponse.Result ,v2GetResponse.Body});
+                DingDingBind dingDingBind = new DingDingBind 
                 {
-                    type = "ddteammodel",
-                    loginid = DDbind.LoginId,
+                    type = type,
+                    unionid = DDbind.Unionid,
                     userid = DDbind.Userid,
-                    userName = DDbind.Name,
-                    Mobile = DDbind.Mobile,
-                    email = DDbind.Email,
-                    sourceid = new HashSet<string> { DDbind.LoginId }
+                    name = DDbind.Name,
+                    mobile = DDbind.Mobile,
+                    title = DDbind.Title,
+                    DeptIdList = DDbind.DeptIdList,
+                    jobNumber = DDbind.JobNumber,
                 };
-                
+
                 Teacher teacher = null;
-                string sql = $"select distinct value(c) c join A1 in c.ddbinds where A1.userid={dingDingBind.userid} AND A1.loginid = {dingDingBind.loginid}";
-                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") })) 
+                string sql = $"select distinct value(c) from c join A1 in c.ddbinds where A1.userid='{dingDingBind.userid}' AND A1.unionid ='{dingDingBind.unionid}'";
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                 {
                     teacher = item;
                     break;
                 }
                 if (teacher == null)
                 {
-                    return Ok(new { status = 0, msg = "没有绑定!" , dingDingBind });
+                    return Ok(new { ddbinds = $"status=0&dingDingBind={dingDingBind.ToJsonString()}" });
                 }
-                else 
+                else
                 {
-                    var ddbind = teacher.ddbinds.FindAll(x => x.userid.Equals($"{dingDingBind.userid}") && x.loginid.Equals($"{dingDingBind.loginid}"));
-                    if (ddbind != null)
-                    {
-                        return Ok(new { teacher, dingDingBind });
-                    }
-                    else 
+                    var url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
+                    var clientID = _configuration.GetValue<string>("HaBookAuth:clientID");
+                    var clientSecret = _configuration.GetValue<string>("HaBookAuth:clientSecret");
+                    var logintion = _option.Location;
+                    //隐式登录
+                    (int code, string content) = await _accountHttpService.Implicit(clientID, clientSecret, logintion, $"{url}/oauth2/implicit",
+                        new Dictionary<string, string>()
+                        {
+                            { "grant_type", "implicit" },
+                            { "client_id",clientID},
+                            { "account",teacher.id},
+                            { "nonce",Guid.NewGuid().ToString()}
+                        });
+
+                    TmdidImplicit implicit_token = new TmdidImplicit();
+                    if (!string.IsNullOrEmpty(content) && code == 200)
                     {
-                        teacher.ddbinds.Add(dingDingBind);
-                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
-                        return Ok(new { teacher, dingDingBind });
+                        implicit_token = content.ToObject<TmdidImplicit>();
+                        var ddbind = teacher.ddbinds.Find(x => x.userid.Equals($"{dingDingBind.userid}") && x.unionid.Equals($"{dingDingBind.unionid}"));
+                        if (ddbind != null)
+                        {
+                            return Ok(new { ddbinds = $"status=200$id_token={implicit_token.id_token}&access_token={implicit_token.access_token}&expires_in={implicit_token.expires_in}&token_type={implicit_token.token_type}" });
+                        }
                     }
+                    return Ok(new { ddbinds= $"status=1&param={dingDingBind.ToJsonString()}&type={type}&bindurl=sc/bind" });                    
                 }
             }
             catch (Exception e)
             {
-                return BadRequest(temp_mess + "======" + e.Message);
-            }
-
-        }
-
-
-
-
-        /// <summary>
-        /// 钉钉扫码登录返回String
-        /// </summary>
-        /// <param name="accreCode"></param>
-        /// <param name="state"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpGet("DLogin")]
-        public string DLogin(string accreCode, string state)
-        {
-            //state 是前端传入的,钉钉并不会修改,比如有多种登录方式的时候,一个登录方法判断登录方式可以进行不同的处理。
-            OapiSnsGetuserinfoBycodeResponse response = new OapiSnsGetuserinfoBycodeResponse();
-            try
-            {
-                string qrAppId = _configuration["DingDingAuth:appKey"];
-                string qrAppSecret = _configuration["DingDingAuth:appSecret"];
-                if (string.IsNullOrWhiteSpace(qrAppId) || string.IsNullOrWhiteSpace(qrAppSecret))
-                {
-                    throw new Exception("请先配置钉钉扫码登录信息!");
-                }
-
-                DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/sns/getuserinfo_bycode");
-                OapiSnsGetuserinfoBycodeRequest req = new OapiSnsGetuserinfoBycodeRequest();
-                req.TmpAuthCode = accreCode;
-                response = client.Execute(req, qrAppId, qrAppSecret);
-
-                //获取到response后就可以进行自己的登录业务处理了
-                //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx               
-
-                if (response.IsError)
-                {
-                    return "unionid读取失败";
-                }
-
-                //根据unionid获取userid
-                string unionid = response.UserInfo.Unionid;
-                IDingTalkClient client2 = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/user/getbyunionid"); //userid地址
-                OapiUserGetbyunionidRequest byunionidRequest = new OapiUserGetbyunionidRequest() { Unionid = unionid };
-                OapiUserGetbyunionidResponse byunionidResponse = client2.Execute(byunionidRequest, accreCode);
-                if (byunionidResponse.IsError)
-                {
-                    return "userid读取失败";
-                }
-                // 根据userId获取用户信息
-                string userid = byunionidResponse.Result.Userid;
-                IDingTalkClient client3 = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
-                OapiV2UserGetRequest v2GetRequest = new OapiV2UserGetRequest()
-                {
-                    Userid = userid,
-                    Language = "zh_CN"
-                };
-                v2GetRequest.SetHttpMethod("GET");
-                OapiV2UserGetResponse v2GetResponse = client3.Execute(v2GetRequest, accreCode);
-                if (v2GetResponse.IsError)
-                {
-                    return "用户信息读取错误";
-                }
-
-                return response.Body;
-
-            }
-            catch (Exception e)
-            {
-                return response.Errmsg = e.Message;
-            }
-
-        }
-
-
-        public async Task<IActionResult> TeamModeBILogin(JsonElement jsonElement)
-        {
-            try
-            {
-                if (!jsonElement.TryGetProperty("id", out JsonElement id)) return BadRequest();
-                if (!jsonElement.TryGetProperty("pw", out JsonElement pw)) return BadRequest();
-
-                var client = _azureCosmos.GetCosmosClient();
-
-                var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(id.GetString(), new PartitionKey($"Base"));
-
-
-                return Ok(new { });
-
-
-            }
-            catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"IES5,{_option.Location},LoginController/TeamModeBILogin\n Error Message{ex.Message}  Error sting:{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
-                throw;
+                return BadRequest($"{temp_mess }{e.Message}{e.StackTrace} ");
             }
 
         }

+ 12 - 14
TEAMModeBI/Startup.cs

@@ -168,26 +168,24 @@ namespace TEAMModeBI
             //        spa.Options.SourcePath = "ClientApp/";
             //    else
             //        spa.Options.SourcePath = "dist";
-
             //    if (env.IsDevelopment())
             //    {
             //        spa.UseVueCli(npmScript: "serve");
             //    }
-
             //});
 
-            app.UseSpa(spa =>
-            {
-                spa.Options.SourcePath = "ClientApp/";
-                if (env.IsDevelopment())
-                {
-                    //spa.UseProxyToSpaDevelopmentServer("https://localhost:5001");
-                    //spa.Options.StartupTimeout = new TimeSpan(0, 0, 80);
-                    //spa.UseVueCli(npmScript: "serve"); 
-                    //spa.UseProxyToSpaDevelopmentServer("https://localhost:5001");
-                    spa.UseVueCli(npmScript: "serve");
-                }
-            });
+            //app.UseSpa(spa =>
+            //{
+            //    spa.Options.SourcePath = "ClientApp/";
+            //    if (env.IsDevelopment())
+            //    {
+            //        //spa.UseProxyToSpaDevelopmentServer("https://localhost:5001");
+            //        //spa.Options.StartupTimeout = new TimeSpan(0, 0, 80);
+            //        //spa.UseVueCli(npmScript: "serve"); 
+            //        //spa.UseProxyToSpaDevelopmentServer("https://localhost:5001");
+            //        spa.UseVueCli(npmScript: "serve");
+            //    }
+            //});
 
             app.UseEndpoints(endpoints =>
             {

+ 2 - 0
TEAMModeBI/TEAMModeBI.csproj

@@ -61,5 +61,7 @@
     </ItemGroup>
   </Target>
 
+  <ProjectExtensions><VisualStudio><UserProperties clientapp_4package_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
+
 
 </Project>

+ 2 - 0
TEAMModeBI/appsettings.Development.json

@@ -49,6 +49,8 @@
     "CoreId": {
       "userinfo": "https://api2.teammodel.cn/Oauth2/GetUserInfos"
     },
+    "Account": "https://account.teammodel.cn",
+    "CoreAPI": "https://api2.teammodel.cn",
     "CoreService": {
       "clientID": "c7317f88-7cea-4e48-ac57-a16071f7b884",
       "clientSecret": "kguxh:V.PLmxBdaI@jnrTrDSth]A3346",

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

@@ -49,15 +49,16 @@ namespace TEAMModelOS.SDK.Models
 
         public class DingDingBind
         {
+
             /// <summary>
             /// 绑定类型  ddteammodel
             /// </summary>
             public string type { get; set; }
 
             /// <summary>
-            /// 用户来源
+            /// 钉钉unionid
             /// </summary>
-            public string loginid { get; set; }
+            public string unionid { get; set; }
 
             /// <summary>
             /// 钉钉ID
@@ -67,21 +68,28 @@ namespace TEAMModelOS.SDK.Models
             /// <summary>
             /// 钉钉用户名
             /// </summary>
-            public string userName { get; set; }
+            public string name { get; set; }
 
             /// <summary>
-            /// 钉钉手机号
+            /// 手机号
             /// </summary>
-            public string Mobile { get; set; }
+            public string mobile { get; set; }
 
             /// <summary>
-            /// 邮箱
+            /// 钉钉职位名称
             /// </summary>
-            public string email { get; set; }
+            public string title { get; set; }
 
+            /// <summary>
+            /// 所属部门id列表
+            /// </summary>
+            public List<long> DeptIdList { get; set; }
 
-            public HashSet<string> sourceid { get; set; } = new HashSet<string>();
-
+            /// <summary>
+            /// 员工工号
+            /// </summary>
+            public string jobNumber { get; set; }
         }
+
     }
 }

+ 5 - 2
TEAMModelOS/Controllers/Third/ScController.cs

@@ -552,12 +552,15 @@ namespace TEAMModelOS.Controllers.Third
         [HttpPost("bind")]
         [AllowAnonymous]
         public async Task<IActionResult> Bind(SSO sso) {
-            var rurl = new StringBuilder($"https://{_option.HostName}/sso");
             try 
             {
                 Teacher teacher = null;
                 if (string.IsNullOrEmpty(sso.id_token)) {
-                    return Redirect(rurl.Append($"?status=1").ToString());
+                    return Ok(new
+                    {
+                        location = _option.Location,
+                        status = 2,
+                    });
                 }
                 var jwt = new JwtSecurityToken(sso.id_token);
                 if (!jwt.Payload.Iss.Equals("account.teammodel", StringComparison.OrdinalIgnoreCase)) return BadRequest();