ow
This commit is contained in:
1 parent
7f5bf3c68d
commit
816209fc35
37 files changed
+3236
-4515
No files matched your search
@@ -8,6 +8,7 @@ using CloudBuilder.Master.Policy;
|
||||
using CloudBuilder.Master.SearchCriteria;
|
||||
using CloudBuilder.Security.Data;
|
||||
using CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.Policy;
|
||||
using CloudBuilder.Security.Service;
|
||||
using CloudBuilder.Security.Utility;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -18,6 +19,9 @@ namespace CloudBuilder.Master.Service
|
||||
{
|
||||
public class FamilyTreeService : IFamilyTreeService
|
||||
{
|
||||
/// <summary>头像上传目录,与前端 FileUpload 的 file-path 保持一致</summary>
|
||||
private const string AVATAR_FOLDER_NAME = "FamilyPersonAvatar";
|
||||
|
||||
private readonly IApplicationService service;
|
||||
|
||||
private IRepository<FamilyTreeEntity> repository;
|
||||
@@ -27,6 +31,23 @@ namespace CloudBuilder.Master.Service
|
||||
repository = service.GetRepository<IRepository<FamilyTreeEntity>>();
|
||||
}
|
||||
|
||||
/// <summary>把 AvatarFilename 拼装成可访问的 AvatarUrl,供谱系图卡片显示头像</summary>
|
||||
private void FillAvatarUrl(FamilyPersonDisplayData person)
|
||||
{
|
||||
if (person == null) return;
|
||||
person.AvatarUrl = FileTypePolicy.PackAvatarUrl(service, AVATAR_FOLDER_NAME, person.AvatarFilename);
|
||||
}
|
||||
|
||||
/// <summary>批量填充头像访问地址</summary>
|
||||
private void FillAvatarUrl(FamilyPersonDisplayData[] persons)
|
||||
{
|
||||
if (persons == null || persons.Length == 0) return;
|
||||
foreach (FamilyPersonDisplayData person in persons)
|
||||
{
|
||||
FillAvatarUrl(person);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: MasterPermissionPolicy.FamilyTree, operate: Operate.Find)]
|
||||
public FamilyTreeData FindAllByTreeId(string treeId)
|
||||
{
|
||||
@@ -46,6 +67,8 @@ namespace CloudBuilder.Master.Service
|
||||
|
||||
data.CurrentPerson.FamilyPerson = new FamilyPersonDisplayData(repositoryFamilyPerson.DetachedEntities.Where(x => x.PersonId == currentPerson).FirstOrDefault()!);
|
||||
|
||||
FillAvatarUrl(data.CurrentPerson.FamilyPerson);
|
||||
|
||||
data.FamilyTree.AncestorPersonGenealogyName = data.CurrentPerson.FamilyPerson.GenealogyName;
|
||||
|
||||
IRepository<FamilyTreeChildrenMapViewEntity> repositoryChildrenMap = repository.GetRepository<IRepository<FamilyTreeChildrenMapViewEntity>>();
|
||||
@@ -72,6 +95,7 @@ namespace CloudBuilder.Master.Service
|
||||
if (families != null && families.Length > 0)
|
||||
{
|
||||
data.CurrentPerson.FamilyTreePersons = families.Select(x => new FamilyPersonDisplayData(x)).ToArray();
|
||||
FillAvatarUrl(data.CurrentPerson.FamilyTreePersons);
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -116,6 +140,8 @@ namespace CloudBuilder.Master.Service
|
||||
data.CurrentPerson.FamilyPerson = new FamilyPersonDisplayData(repositoryFamilyPerson.DetachedEntities.Where(x => x.PersonId == personId).FirstOrDefault()!);
|
||||
}
|
||||
|
||||
FillAvatarUrl(data.CurrentPerson.FamilyPerson);
|
||||
|
||||
IRepository<FamilyTreeChildrenMapViewEntity> repositoryChildrenMap = repository.GetRepository<IRepository<FamilyTreeChildrenMapViewEntity>>();
|
||||
|
||||
IRepository<FamilyTreeSpouseMapViewEntity> repositorySpouseMap = repository.GetRepository<IRepository<FamilyTreeSpouseMapViewEntity>>();
|
||||
@@ -125,6 +151,26 @@ namespace CloudBuilder.Master.Service
|
||||
//data.CurrentPerson.FamilyTreeParentMaps = repositoryChildrenMap.GetRepository<IRepository<FamilyTreeChildrenMapViewEntity>>().DetachedEntities.Where(x => x.ChildrenId == key).OrderBy(x => x.Orderby).ToArray();
|
||||
data.CurrentPerson.FamilyTreeChildrenMaps = repositoryChildrenMap.GetRepository<IRepository<FamilyTreeChildrenMapViewEntity>>().DetachedEntities.Where(x => x.PersonId == currentPerson).OrderBy(x => x.Orderby).ToArray();
|
||||
|
||||
// 补充当前人员及其配偶、子女的人员信息(含头像地址),供谱系图卡片显示头像
|
||||
List<string> ps = new List<string>();
|
||||
if (!string.IsNullOrEmpty(currentPerson)) ps.Add(currentPerson);
|
||||
if (data.CurrentPerson.FamilyTreeSpouseMaps != null)
|
||||
{
|
||||
ps.AddRange(data.CurrentPerson.FamilyTreeSpouseMaps.Select(x => x.SpouseId).ToArray());
|
||||
}
|
||||
if (data.CurrentPerson.FamilyTreeChildrenMaps != null)
|
||||
{
|
||||
ps.AddRange(data.CurrentPerson.FamilyTreeChildrenMaps.Select(x => x.ChildrenId).ToArray());
|
||||
}
|
||||
|
||||
ps = ps.Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
|
||||
FamilyPersonEntity[] families = repositoryFamilyPerson.DetachedEntities.Where(x => ps.AsQueryable().Contains(x.PersonId)).ToArray();
|
||||
if (families != null && families.Length > 0)
|
||||
{
|
||||
data.CurrentPerson.FamilyTreePersons = families.Select(x => new FamilyPersonDisplayData(x)).ToArray();
|
||||
FillAvatarUrl(data.CurrentPerson.FamilyTreePersons);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user