|
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Text.Json;
|
|
|
using System.Threading.Tasks;
|
|
@@ -89,13 +90,14 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
|
string type = "";
|
|
|
if (string.IsNullOrEmpty(bizUsers.id))
|
|
|
{
|
|
|
+
|
|
|
bizUsers.id = Guid.NewGuid().ToString();
|
|
|
bizUsers.code = "BizUsers";
|
|
|
bizUsers.name = string.IsNullOrEmpty(bizUsers.name)? bizUsers.mobile.ToString(): bizUsers.name;
|
|
|
|
|
|
bizUsers.salt = salt;
|
|
|
bizUsers.pwd = string.IsNullOrEmpty(bizUsers.pwd) ? Utils.HashedPassword(bizUsers.mobile.ToString(), salt) : Utils.HashedPassword(bizUsers.pwd, salt);
|
|
|
-
|
|
|
+
|
|
|
bizUsers = await cosmosClient.GetContainer("TEAMModelOS", "Normal").CreateItemAsync<BizUsers>(bizUsers, new PartitionKey("BizUsers"));
|
|
|
strMsg.Append($"{bizUsers.name}【{bizUsers.id}】新增第三方用户信息基础信息。");
|
|
|
type = "bizuser-add";
|
|
@@ -111,7 +113,7 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
|
bizUsers.pk = "Business";
|
|
|
bizUsers.code = "BizUsers";
|
|
|
bizUsers.ttl = -1;
|
|
|
-
|
|
|
+ bizUsers.relation = tempbizUsers.relation;
|
|
|
bizUsers.salt = tempbizUsers.salt;
|
|
|
bizUsers.pwd = tempbizUsers.pwd;
|
|
|
bizUsers = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizUsers>(bizUsers, bizUsers.id, new PartitionKey("BizUsers"));
|
|
@@ -153,7 +155,7 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
|
BizUsers bizUsers = new();
|
|
|
StringBuilder strMsg = new($"{tmdName}[{tmdId}]操作:");
|
|
|
string salt = Utils.CreatSaltString(8);
|
|
|
- var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizConfig"));
|
|
|
+ var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizUsers"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
@@ -163,7 +165,7 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
|
|
|
|
strMsg.Append($"重置{bizUsers.name}【{bizUsers.id}】的密码,重置成功!");
|
|
|
bizUsers = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizUsers>(bizUsers, bizUsers.id, new PartitionKey("BizUsers"));
|
|
|
- }
|
|
|
+ }else return Ok(new { state = RespondCode.NotFound, msg="未找到该用户信息" });
|
|
|
|
|
|
//保存操作记录
|
|
|
await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "bizuser-reset", strMsg.ToString(), _dingDing, httpContext: HttpContext);
|
|
@@ -182,6 +184,7 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
|
{
|
|
|
if(!jsonElement.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
if (!jsonElement.TryGetProperty("bizs", out JsonElement _bizs)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("type", out JsonElement type)) return BadRequest();
|
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
var (tmdId, tmdName, pic, _, _, _) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
|
|
@@ -197,14 +200,14 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
|
blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
|
|
|
}
|
|
|
|
|
|
- StringBuilder strMsg = new($"{tmdName}[{tmdId}]");
|
|
|
- if (string.IsNullOrEmpty("add"))
|
|
|
+ StringBuilder strMsg = new($"{tmdName}[{tmdId}]给");
|
|
|
+ if ($"{type}".Equals("add"))
|
|
|
{
|
|
|
- strMsg.Append($"关联企业ID:{id},学校列表:");
|
|
|
+ strMsg.Append($"用户【{id}】关联企业信息:添加企业:");
|
|
|
}
|
|
|
- else if (string.IsNullOrEmpty("del"))
|
|
|
+ else if ($"{type}".Equals("del"))
|
|
|
{
|
|
|
- strMsg.Append("移除企业学校信息,学校列表:");
|
|
|
+ strMsg.Append($"用户【{id}】移除企业信息,移除企业:");
|
|
|
}
|
|
|
else { return Ok(new { state = RespondCode.ParamsError, msg = "类型错误" }); }
|
|
|
|
|
@@ -218,24 +221,26 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
|
bizUsers = json.ToObject<BizUsers>();
|
|
|
foreach (var item in bizRels)
|
|
|
{
|
|
|
- var temp = bizUsers.relation.Find(f => f.bizId.Equals(item.bizId));
|
|
|
- if (string.IsNullOrEmpty("add"))
|
|
|
+ var temp = bizUsers.relation.Find(f => f.bizId == item.bizId);
|
|
|
+ if ($"{type}".Equals("add"))
|
|
|
{
|
|
|
- if (temp == null)
|
|
|
+ if (temp != null)
|
|
|
+ noBizRel.Add(item);
|
|
|
+ else
|
|
|
{
|
|
|
bizUsers.relation.Add(item);
|
|
|
strMsg.Append($"{item.name}[{item.bizId}]|");
|
|
|
}
|
|
|
- else
|
|
|
- noBizRel.Add(temp);
|
|
|
}
|
|
|
- else if (string.IsNullOrEmpty("del"))
|
|
|
+ else if ($"{type}".Equals("del"))
|
|
|
{
|
|
|
if (temp != null)
|
|
|
{
|
|
|
- bizUsers.relation.Remove(temp);
|
|
|
+ bizUsers.relation.Add(item);
|
|
|
strMsg.Append($"{item.name}[{item.bizId}]|");
|
|
|
}
|
|
|
+ else
|
|
|
+ noBizRel.Add(item);
|
|
|
}
|
|
|
}
|
|
|
|