|
@@ -545,101 +545,109 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<Teacher>(id, new PartitionKey($"Base"));
|
|
|
var schoolData= teacher.schools.Find(z => z.schoolId.Equals($"{school_code}"));
|
|
|
- List<string> addAuthority = new List<string>();
|
|
|
- List<string> rmvAuthority = new List<string>();
|
|
|
- if (permission.IsNotEmpty())
|
|
|
- {
|
|
|
- st.permissions = permission;
|
|
|
- // addAuthority.AddRange(permission);
|
|
|
- }
|
|
|
- if (addPm.IsNotEmpty())
|
|
|
- {
|
|
|
- st.permissions.AddRange(addPm);
|
|
|
- //addAuthority.AddRange(addPm);
|
|
|
- }
|
|
|
- if (rmvPm.IsNotEmpty())
|
|
|
- {
|
|
|
- st.permissions.RemoveAll(x => rmvPm.Contains(x));
|
|
|
- //rmvAuthority.AddRange(rmvPm);
|
|
|
- }
|
|
|
- if (hasjob)
|
|
|
- {
|
|
|
- st.job = $"{_job}";
|
|
|
- }
|
|
|
- //清除权限标记。
|
|
|
- if (_pmClean.ValueKind.Equals(JsonValueKind.True)) {
|
|
|
- st.permissions = new List<string>();
|
|
|
- //rmvAuthority.AddRange(st.permissions);
|
|
|
- }
|
|
|
- //再次确认已经移除的权限。
|
|
|
- if (oldper != null)
|
|
|
- {
|
|
|
- var rmper = oldper.Except(st.permissions);
|
|
|
- if (rmper != null)
|
|
|
+ if (schoolData!=null) {
|
|
|
+ List<string> addAuthority = new List<string>();
|
|
|
+ List<string> rmvAuthority = new List<string>();
|
|
|
+ if (permission.IsNotEmpty())
|
|
|
{
|
|
|
- var rm = rmper.Except(rmvAuthority);
|
|
|
- rmvAuthority.AddRange(rm);
|
|
|
+ st.permissions = permission;
|
|
|
+ // addAuthority.AddRange(permission);
|
|
|
}
|
|
|
- var adper = st.permissions.Except(oldper);
|
|
|
- if (adper != null)
|
|
|
+ if (addPm.IsNotEmpty())
|
|
|
{
|
|
|
- var ad = adper.Except(addAuthority);
|
|
|
- addAuthority.AddRange(ad);
|
|
|
+ st.permissions.AddRange(addPm);
|
|
|
+ //addAuthority.AddRange(addPm);
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
- if (st.permissions.IsNotEmpty()) {
|
|
|
- addAuthority.AddRange(st.permissions);
|
|
|
+ if (rmvPm.IsNotEmpty())
|
|
|
+ {
|
|
|
+ st.permissions.RemoveAll(x => rmvPm.Contains(x));
|
|
|
+ //rmvAuthority.AddRange(rmvPm);
|
|
|
}
|
|
|
- }
|
|
|
- List<IdNameCode> nameCodes = new List<IdNameCode> { new IdNameCode { id = teacher.id, name = teacher.name, code = teacher.lang } };
|
|
|
-
|
|
|
- nameCodes.FindAll(x => string.IsNullOrWhiteSpace(x.code) || (!x.code.Equals("zh-cn") && !x.code.Equals("zh-tw") && !x.code.Equals("en-us"))).ForEach(x => { x.code = lang; });
|
|
|
- string path = Path.Combine("", $"Lang/{nameCodes.First().code}.json");
|
|
|
- var jsonAuth =System.IO. File.ReadAllText(path,Encoding.UTF8);
|
|
|
- var jsonData = jsonAuth.ToObject<JsonElement>();
|
|
|
- List<string> addText = new List<string>();
|
|
|
- List<string> rmvText = new List<string>();
|
|
|
- var authority =jsonData.GetProperty("authority");
|
|
|
- string none = nameCodes.First().code.Equals("zh-cn") ? "无" : nameCodes.First().code.Equals("zh-tw") ? "無" : "none";
|
|
|
- if (addAuthority.IsNotEmpty())
|
|
|
- {
|
|
|
- addAuthority.ForEach(z => {
|
|
|
- if (authority.TryGetProperty(z, out JsonElement text)) {
|
|
|
- addText.Add($"{text}");
|
|
|
+ if (hasjob)
|
|
|
+ {
|
|
|
+ st.job = $"{_job}";
|
|
|
+ }
|
|
|
+ //清除权限标记。
|
|
|
+ if (_pmClean.ValueKind.Equals(JsonValueKind.True))
|
|
|
+ {
|
|
|
+ st.permissions = new List<string>();
|
|
|
+ //rmvAuthority.AddRange(st.permissions);
|
|
|
+ }
|
|
|
+ //再次确认已经移除的权限。
|
|
|
+ if (oldper != null)
|
|
|
+ {
|
|
|
+ var rmper = oldper.Except(st.permissions);
|
|
|
+ if (rmper != null)
|
|
|
+ {
|
|
|
+ var rm = rmper.Except(rmvAuthority);
|
|
|
+ rmvAuthority.AddRange(rm);
|
|
|
}
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
- else {
|
|
|
- addText.Add($"{none}");
|
|
|
- }
|
|
|
- if (rmvAuthority.IsNotEmpty())
|
|
|
- {
|
|
|
- rmvAuthority.ForEach(z => {
|
|
|
- if (authority.TryGetProperty(z, out JsonElement text))
|
|
|
+ var adper = st.permissions.Except(oldper);
|
|
|
+ if (adper != null)
|
|
|
{
|
|
|
- rmvText.Add($"{text}");
|
|
|
+ var ad = adper.Except(addAuthority);
|
|
|
+ addAuthority.AddRange(ad);
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
- else {
|
|
|
- rmvText.Add($"{none}");
|
|
|
- }
|
|
|
-
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(st, id, new PartitionKey($"Teacher-{school_code}"));
|
|
|
- _coreAPIHttpService.PushNotify(nameCodes, "authority-change", Constant.NotifyType_IES5_Management,
|
|
|
- new Dictionary<string, object> { { "tmdname", teacher.name }, { "tmdid", teacher.id }, { "schoolName", schoolData.name }, { "addAuthority", $"[{string.Join(",", addText)}]" }, { "rmvAuthority", $"[{string.Join(",", rmvText)}]" } }
|
|
|
- , _option.Location, _configuration, _dingDing, _environment.ContentRootPath);
|
|
|
- schoolTeachers.Add(st);
|
|
|
- //标记
|
|
|
- if (addAuthority.Contains("teacher-upd"))
|
|
|
- {
|
|
|
- adminChange.adminAdd.Add(id);
|
|
|
- }
|
|
|
- if (rmvAuthority.Contains("teacher-upd"))
|
|
|
- {
|
|
|
- adminChange.adminRmv.Add(id);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (st.permissions.IsNotEmpty())
|
|
|
+ {
|
|
|
+ addAuthority.AddRange(st.permissions);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<IdNameCode> nameCodes = new List<IdNameCode> { new IdNameCode { id = teacher.id, name = teacher.name, code = teacher.lang } };
|
|
|
+
|
|
|
+ nameCodes.FindAll(x => string.IsNullOrWhiteSpace(x.code) || (!x.code.Equals("zh-cn") && !x.code.Equals("zh-tw") && !x.code.Equals("en-us"))).ForEach(x => { x.code = lang; });
|
|
|
+ string path = Path.Combine("", $"Lang/{nameCodes.First().code}.json");
|
|
|
+ var jsonAuth = System.IO.File.ReadAllText(path, Encoding.UTF8);
|
|
|
+ var jsonData = jsonAuth.ToObject<JsonElement>();
|
|
|
+ List<string> addText = new List<string>();
|
|
|
+ List<string> rmvText = new List<string>();
|
|
|
+ var authority = jsonData.GetProperty("authority");
|
|
|
+ string none = nameCodes.First().code.Equals("zh-cn") ? "无" : nameCodes.First().code.Equals("zh-tw") ? "無" : "none";
|
|
|
+ if (addAuthority.IsNotEmpty())
|
|
|
+ {
|
|
|
+ addAuthority.ForEach(z => {
|
|
|
+ if (authority.TryGetProperty(z, out JsonElement text))
|
|
|
+ {
|
|
|
+ addText.Add($"{text}");
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ addText.Add($"{none}");
|
|
|
+ }
|
|
|
+ if (rmvAuthority.IsNotEmpty())
|
|
|
+ {
|
|
|
+ rmvAuthority.ForEach(z => {
|
|
|
+ if (authority.TryGetProperty(z, out JsonElement text))
|
|
|
+ {
|
|
|
+ rmvText.Add($"{text}");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ rmvText.Add($"{none}");
|
|
|
+ }
|
|
|
+
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(st, id, new PartitionKey($"Teacher-{school_code}"));
|
|
|
+ _coreAPIHttpService.PushNotify(nameCodes, "authority-change", Constant.NotifyType_IES5_Management,
|
|
|
+ new Dictionary<string, object> { { "tmdname", teacher.name }, { "tmdid", teacher.id }, { "schoolName", schoolData.name }, { "addAuthority", $"[{string.Join(",", addText)}]" }, { "rmvAuthority", $"[{string.Join(",", rmvText)}]" } }
|
|
|
+ , _option.Location, _configuration, _dingDing, _environment.ContentRootPath);
|
|
|
+ schoolTeachers.Add(st);
|
|
|
+ //标记
|
|
|
+ if (addAuthority.Contains("teacher-upd"))
|
|
|
+ {
|
|
|
+ adminChange.adminAdd.Add(id);
|
|
|
+ }
|
|
|
+ if (rmvAuthority.Contains("teacher-upd"))
|
|
|
+ {
|
|
|
+ adminChange.adminRmv.Add(id);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
await _coreAPIHttpService.AdminChange(adminChange, _option.Location, _configuration, _dingDing);
|