|
@@ -39,6 +39,11 @@ using System.Runtime.InteropServices;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.CompilerServices;
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
using TEAMModelBI.Tool.Extension;
|
|
using TEAMModelBI.Tool.Extension;
|
|
|
|
+using System.IO;
|
|
|
|
+using static TEAMModelBI.Controllers.BISchool.BatchSchoolController;
|
|
|
|
+using System.Net.Http;
|
|
|
|
+using System.Net.Http.Json;
|
|
|
|
+using System.Net;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.BITest
|
|
namespace TEAMModelBI.Controllers.BITest
|
|
{
|
|
{
|
|
@@ -53,8 +58,10 @@ namespace TEAMModelBI.Controllers.BITest
|
|
private readonly IWebHostEnvironment _environment; //读取文件
|
|
private readonly IWebHostEnvironment _environment; //读取文件
|
|
//读取配置文件
|
|
//读取配置文件
|
|
private readonly IConfiguration _configuration;
|
|
private readonly IConfiguration _configuration;
|
|
|
|
+ private readonly CoreAPIHttpService _coreAPIHttpService;
|
|
|
|
+ private readonly HttpClient _httpClient;
|
|
|
|
|
|
- public TestController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration)
|
|
|
|
|
|
+ public TestController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient)
|
|
{
|
|
{
|
|
_azureCosmos = azureCosmos;
|
|
_azureCosmos = azureCosmos;
|
|
_dingDing = dingDing;
|
|
_dingDing = dingDing;
|
|
@@ -62,6 +69,8 @@ namespace TEAMModelBI.Controllers.BITest
|
|
_option = option?.Value;
|
|
_option = option?.Value;
|
|
_environment = hostingEnvironment;
|
|
_environment = hostingEnvironment;
|
|
_configuration = configuration;
|
|
_configuration = configuration;
|
|
|
|
+ _coreAPIHttpService = coreAPIHttpService;
|
|
|
|
+ _httpClient = httpClient;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -316,6 +325,205 @@ namespace TEAMModelBI.Controllers.BITest
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取在职ID
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("get-onthejob")]
|
|
|
|
+ public async Task<IActionResult> GetOnTheJob()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ string appKey = _configuration["DingDingAuth:appKey"];
|
|
|
|
+ string appSecret = _configuration["DingDingAuth:appSecret"];
|
|
|
|
+ string agentld = _configuration["DingDingAuth:Agentld"];
|
|
|
|
+
|
|
|
|
+ //获取access_token
|
|
|
|
+ IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
|
|
|
|
+ OapiGettokenRequest request = new OapiGettokenRequest() { Appkey = appKey, Appsecret = appSecret };
|
|
|
|
+ request.SetHttpMethod("Get");
|
|
|
|
+ OapiGettokenResponse response = client.Execute(request);
|
|
|
|
+ if (response.IsError)
|
|
|
|
+ {
|
|
|
|
+ return BadRequest();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //access_token的有效期为7200秒(2小时),有效期内重复获取会返回相同结果并自动续期,过期后获取会返回新的access_token
|
|
|
|
+ string access_token = response.AccessToken;
|
|
|
|
+
|
|
|
|
+ //bool vars = false;
|
|
|
|
+ //long offst = 1;
|
|
|
|
+ //do
|
|
|
|
+ //{
|
|
|
|
+ // IDingTalkClient jobclient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/queryonjob");
|
|
|
|
+ // OapiSmartworkHrmEmployeeQueryonjobRequest jobreq = new OapiSmartworkHrmEmployeeQueryonjobRequest { StatusList = "2,3,-1", Offset = offst, Size = 50 }; //2:试用期 3:正式 5:待离职 -1:无状态
|
|
|
|
+ // OapiSmartworkHrmEmployeeQueryonjobResponse jobrsp = jobclient.Execute(jobreq, access_token);
|
|
|
|
+
|
|
|
|
+ // if (jobrsp.Result.NextCursor > 0)
|
|
|
|
+ // offst += 1;
|
|
|
|
+ // else vars = true;
|
|
|
|
+ //} while (vars);
|
|
|
|
+
|
|
|
|
+ IDingTalkClient jobclient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/queryonjob");
|
|
|
|
+ OapiSmartworkHrmEmployeeQueryonjobRequest jobreq = new OapiSmartworkHrmEmployeeQueryonjobRequest { StatusList = "2,3,-1", Offset = 1, Size = 50 }; //2:试用期 3:正式 5:待离职 -1:无状态
|
|
|
|
+ OapiSmartworkHrmEmployeeQueryonjobResponse jobrsp = jobclient.Execute(jobreq, access_token);
|
|
|
|
+ if (jobrsp.SubErrCode == "60011")
|
|
|
|
+ {
|
|
|
|
+ return Ok(new { state = 200, msg = jobrsp.SubErrMsg });
|
|
|
|
+ }
|
|
|
|
+ foreach (var item in jobrsp.Result.DataList)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var ser = jobrsp.Result.DataList; // jobrsp.Body.GetEnumerator("result");
|
|
|
|
+
|
|
|
|
+ return Ok(new { state = 200, jobrsp.Body, ser });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 测试 使用yield 优化
|
|
|
|
+ /// 依据学校编号查询学校信息;若是没有传学校编号,则查询所有学校信息
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
|
+ [HttpPost("get-schoolsinfo")]
|
|
|
|
+ public async Task<IActionResult> GetSchoolsInfo(JsonElement jsonElement)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ jsonElement.TryGetProperty("schoolCode", out JsonElement _schoolCode);
|
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
+ List<SchoolAssist> schoolAssists = new();
|
|
|
|
+ //StringBuilder stringBuilder = new StringBuilder("select value(c) from c");
|
|
|
|
+ StringBuilder stringBuilder = new StringBuilder("select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard from c");
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty($"{_schoolCode}"))
|
|
|
|
+ {
|
|
|
|
+ stringBuilder.Append($" where c.id='{_schoolCode}'");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
|
+ //{
|
|
|
|
+ // SchoolAssist schoolAssist = new()
|
|
|
|
+ // {
|
|
|
|
+ // id = itemSchool.id,
|
|
|
|
+ // code = itemSchool.code,
|
|
|
|
+ // schoolCode = itemSchool.schoolCode,
|
|
|
|
+ // name = itemSchool.name,
|
|
|
|
+ // region = itemSchool.region,
|
|
|
|
+ // province = itemSchool.province,
|
|
|
|
+ // city = itemSchool.city,
|
|
|
|
+ // dist = itemSchool.dist,
|
|
|
|
+ // size = itemSchool.size,
|
|
|
|
+ // address = itemSchool.address,
|
|
|
|
+ // picture = itemSchool.picture,
|
|
|
|
+ // type = itemSchool.type,
|
|
|
|
+ // scale = itemSchool.scale,
|
|
|
|
+ // areaId = itemSchool.areaId,
|
|
|
|
+ // standard = itemSchool.standard
|
|
|
|
+ // };
|
|
|
|
+
|
|
|
|
+ // var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(itemSchool.id, new PartitionKey("ProductSum"));
|
|
|
|
+ // if (response.Status == 200)
|
|
|
|
+ // {
|
|
|
|
+ // using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
|
+ // schoolAssist.serial = json.RootElement.GetProperty("serial").GetArrayLength();
|
|
|
|
+ // schoolAssist.service = json.RootElement.GetProperty("service").GetArrayLength();
|
|
|
|
+ // schoolAssist.hard = json.RootElement.GetProperty("hard").GetArrayLength();
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // schoolAssist.assists = await CommonFind.FindSchoolRoles(cosmosClient, itemSchool.id, "assist");
|
|
|
|
+
|
|
|
|
+ // schoolAssists.Add(schoolAssist);
|
|
|
|
+ //}
|
|
|
|
+ //return Ok(new { state = 200, schoolAssists });
|
|
|
|
+
|
|
|
|
+ await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
|
+ {
|
|
|
|
+ using var jsonSchool = await JsonDocument.ParseAsync(itemSchool.ContentStream);
|
|
|
|
+ foreach (var objSchool in jsonSchool.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ var schoolId = objSchool.GetProperty("id").GetString();
|
|
|
|
+ SchoolAssist schoolAssist = new()
|
|
|
|
+ {
|
|
|
|
+ id = schoolId,
|
|
|
|
+ code = objSchool.GetProperty("code").GetString(),
|
|
|
|
+ schoolCode = objSchool.GetProperty("schoolCode").GetString(),
|
|
|
|
+ name = objSchool.GetProperty("name").GetString(),
|
|
|
|
+ region = objSchool.GetProperty("region").GetString(),
|
|
|
|
+ province = objSchool.GetProperty("province").GetString(),
|
|
|
|
+ city = objSchool.GetProperty("city").GetString(),
|
|
|
|
+ dist = objSchool.GetProperty("dist").GetString(),
|
|
|
|
+ size = objSchool.GetProperty("size").GetInt32(),
|
|
|
|
+ address = objSchool.GetProperty("address").GetString(),
|
|
|
|
+ picture = objSchool.GetProperty("picture").GetString(),
|
|
|
|
+ type = objSchool.GetProperty("type").GetInt32(),
|
|
|
|
+ //scale = objSchool.GetProperty("scale").GetInt32(),
|
|
|
|
+ areaId = objSchool.GetProperty("areaId").GetString(),
|
|
|
|
+ standard = objSchool.GetProperty("standard").GetString(),
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ try { schoolAssist.scale = objSchool.GetProperty("scale").GetInt32(); }
|
|
|
|
+ catch { schoolAssist.scale = 0; }
|
|
|
|
+
|
|
|
|
+ //var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("ProductSum"));
|
|
|
|
+ //if (response.Status == 200)
|
|
|
|
+ //{
|
|
|
|
+ // using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
|
+ // schoolAssist.serial = json.RootElement.GetProperty("serial").GetArrayLength();
|
|
|
|
+ // schoolAssist.service = json.RootElement.GetProperty("service").GetArrayLength();
|
|
|
|
+ // schoolAssist.hard = json.RootElement.GetProperty("hard").GetArrayLength();
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ //schoolAssist.assists = await CommonFind.FindSchoolRoles(cosmosClient, schoolId, "assist");
|
|
|
|
+ schoolAssists.Add(schoolAssist);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<SchoolAssist> tempSchoolAssists = new();
|
|
|
|
+ await foreach (var temp in GetSchools(cosmosClient, schoolAssists))
|
|
|
|
+ {
|
|
|
|
+ tempSchoolAssists.AddRange(temp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Ok(new { state = 200, schoolAssists = tempSchoolAssists });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schoolsinfo \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
|
+ return BadRequest();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 使用yield 优化
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="cosmosClient"></param>
|
|
|
|
+ /// <param name="schoolAssists"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ private async IAsyncEnumerable<List<SchoolAssist>> GetSchools(CosmosClient cosmosClient, List<SchoolAssist> schoolAssists)
|
|
|
|
+ {
|
|
|
|
+ List<SchoolAssist> tempSchoolAssists = new();
|
|
|
|
+ foreach (var temp in schoolAssists)
|
|
|
|
+ {
|
|
|
|
+ var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(temp.id, new PartitionKey("ProductSum"));
|
|
|
|
+ if (response.Status == 200)
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
|
+ temp.serial = json.RootElement.GetProperty("serial").GetArrayLength();
|
|
|
|
+ temp.service = json.RootElement.GetProperty("service").GetArrayLength();
|
|
|
|
+ temp.hard = json.RootElement.GetProperty("hard").GetArrayLength();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ temp.assists = await CommonFind.FindSchoolRoles(cosmosClient, temp.id, "assist");
|
|
|
|
+ tempSchoolAssists.Add(temp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ yield return tempSchoolAssists;
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 赋值默认的顾问角色和BI默认的功能权限
|
|
/// 赋值默认的顾问角色和BI默认的功能权限
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -696,40 +904,6 @@ namespace TEAMModelBI.Controllers.BITest
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// 测试获取传过来的头部
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="jsonElement"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- [ProducesDefaultResponseType]
|
|
|
|
- [HttpPost("get-xauth")]
|
|
|
|
- public async Task<IActionResult> GetXAuth(JsonElement jsonElement)
|
|
|
|
- {
|
|
|
|
- string authHeader = this.Request.Headers["Authorization"];//Header中的token
|
|
|
|
- string _auth = HttpContext.GetXAuth("AuthToken");
|
|
|
|
-
|
|
|
|
- //var (id, name, pic, did, dname, dpic) = HttpJwtAnalysis.GetAuthTokenInfo(HttpContext);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //var (tmdId, tmdName) = HttpJwtAnalysis.JwtXAuth(_auth, _option);
|
|
|
|
- var (tmdId, tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(_auth, _option);
|
|
|
|
-
|
|
|
|
- // var (id, name) = httpXAuth(_auth, _option);
|
|
|
|
-
|
|
|
|
- //string id = null;
|
|
|
|
- //string name = null;
|
|
|
|
-
|
|
|
|
- //if (!string.IsNullOrWhiteSpace(_auth) && JwtAuthExtension.ValidateApiToken(_auth, _option.JwtSecretKey))
|
|
|
|
- //{
|
|
|
|
- // var jwt = new JwtSecurityTokenHandler().ReadJwtToken(_auth);
|
|
|
|
- // id = jwt.Payload.Sub;
|
|
|
|
- // name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
- return Ok(new { state = 200, tmdId, tmdName });
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 测试CosmosDB分页查询
|
|
/// 测试CosmosDB分页查询
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -760,18 +934,112 @@ namespace TEAMModelBI.Controllers.BITest
|
|
return Ok(new { state = 200, schools });
|
|
return Ok(new { state = 200, schools });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 测试隐式登录
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("get-implicit")]
|
|
|
|
+ public async Task<IActionResult> GetImplicit()
|
|
|
|
+ {
|
|
|
|
+ var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
|
|
|
|
+ var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
|
|
|
|
+
|
|
|
|
+ var location = _option.Location;
|
|
|
|
+ if (location.Contains("China"))
|
|
|
|
+ {
|
|
|
|
+ location = "China";
|
|
|
|
+ }
|
|
|
|
+ else if (location.Contains("Global"))
|
|
|
|
+ {
|
|
|
|
+ location = "Global";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location);
|
|
|
|
+ if (_httpClient.DefaultRequestHeaders.Contains("Authorization"))
|
|
|
|
+ {
|
|
|
|
+ _httpClient.DefaultRequestHeaders.Remove("Authorization");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
|
|
|
|
+ var url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
|
|
|
|
+ url = $"{url}/oauth2/implicit";
|
|
|
|
+ Dictionary<string, string> data = new()
|
|
|
|
+ {
|
|
|
|
+ { "grant_type", "implicit" },
|
|
|
|
+ { "client_id", clientID },
|
|
|
|
+ { "account", "1636016499" },
|
|
|
|
+ { "nonce", Guid.NewGuid().ToString() }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync(url, data);
|
|
|
|
+ if (responseMessage.StatusCode == HttpStatusCode.OK) //BI连接字符
|
|
|
|
+ {
|
|
|
|
+ string content = await responseMessage.Content.ReadAsStringAsync();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Ok(new { state = 200, token, responseMessage });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 测试
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
|
+ /// <returns></returns>
|
|
[HttpPost("get-test")]
|
|
[HttpPost("get-test")]
|
|
- public async Task<IActionResult> GetTest(JsonElement jsonElement)
|
|
|
|
|
|
+ public async Task<IActionResult> GetTest(JsonElement jsonElement)
|
|
{
|
|
{
|
|
- if (!jsonElement.TryGetProperty("size", out JsonElement size)) return BadRequest();
|
|
|
|
- string temps = GenerateRandom.StrRandom(int.Parse($"{size}"), small:true);
|
|
|
|
|
|
+ List<Test> list1 = new List<Test>();
|
|
|
|
+ list1.Add(new Test { score = 10, name = "001" });
|
|
|
|
+ list1.Add(new Test { score = 20, name = "002" });
|
|
|
|
+ list1.Add(new Test { score = 30, name = "003" });
|
|
|
|
+ list1.Add(new Test { score = 40, name = "004" });
|
|
|
|
+ list1.Add(new Test { score = 50, name = "005" });
|
|
|
|
+ list1.Add(new Test { score = 60, name = "006" });
|
|
|
|
+
|
|
|
|
+ List<Test> list2 = new List<Test>();
|
|
|
|
+ list2.Add(new Test { score = 40, name = "004" });
|
|
|
|
+ list2.Add(new Test { score = 50, name = "005" });
|
|
|
|
+ list2.Add(new Test { score = 60, name = "006" });
|
|
|
|
+ list2.Add(new Test { score = 70, name = "007" });
|
|
|
|
+ list2.Add(new Test { score = 80, name = "008" });
|
|
|
|
+ list2.Add(new Test { score = 90, name = "009" });
|
|
|
|
+ list2.Add(new Test { score = 100, name = "010" });
|
|
|
|
+
|
|
|
|
+ //list3 return 2
|
|
|
|
+ List<Test> list3 = list1.Where(x => !list2.Any(x2 => x.score == x2.score && x.name==x2.name)).ToList();
|
|
|
|
+ //list4 return 2
|
|
|
|
+ List<Test> list4 = list1.Where(x => list2.All(x2 => x.score != x2.score)).ToList();
|
|
|
|
+
|
|
|
|
+ List<Test> temp = list1.Where(p => !list2.Select(b => b.score).Contains(p.score)).ToList();
|
|
|
|
+
|
|
|
|
+ //List<Test> mergedList = new List<Test>(list1);
|
|
|
|
+ //mergedList.AddRange(list2.Except(list1));
|
|
|
|
+
|
|
|
|
+ // var mergedList = list1.Union(list2);
|
|
|
|
+
|
|
|
|
+ var en2 = list1.Concat(list2).Except(list1.Intersect(list2));// 容斥原理
|
|
|
|
+
|
|
|
|
+ var bingji = list1.Union(list2).ToList();//并(全)集
|
|
|
|
|
|
- RNGCryptoServiceProvider csp = new RNGCryptoServiceProvider();
|
|
|
|
- byte[] byteCsp = new byte[int.Parse($"{size}")];
|
|
|
|
- csp.GetBytes(byteCsp);
|
|
|
|
- string lo = BitConverter.ToString(byteCsp);
|
|
|
|
|
|
+ var cha = bingji.GroupBy(x => x.score).Select(c => c.First()).ToList();
|
|
|
|
|
|
- return Ok(new { state = 200, temps, byteCsp, csp, lo });
|
|
|
|
|
|
+
|
|
|
|
+ var jiaoji = list1.Intersect(list2).ToList();//交集
|
|
|
|
+ var chaji = list1.Except(list2).ToList();//差集
|
|
|
|
+
|
|
|
|
+ List<Test> have = list1.Where(a => !list2.Exists(t => a.score == t.score)).ToList();
|
|
|
|
+ have.AddRange(list2.Where(a => !list1.Exists(t => a.score == t.score)).ToList());
|
|
|
|
+
|
|
|
|
+ return Ok(new { state = 200, have, en2, bingji, cha, jiaoji, chaji, list3, list4, temp, list1 });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public class Test
|
|
|
|
+ {
|
|
|
|
+ public int age { get; set; }
|
|
|
|
+ public string name { get; set; }
|
|
|
|
+ public int score { get; set; }
|
|
}
|
|
}
|
|
|
|
|
|
public class strend
|
|
public class strend
|