People: refactor

This commit is contained in:
Maksim Chegulov 2022-02-28 21:54:08 +03:00
parent c252b94060
commit 1665fe7bf6
22 changed files with 247 additions and 275 deletions

View File

@ -39,7 +39,7 @@ public class EmployeeWraperFull : EmployeeWraper
public ApiDateTime Terminated { get; set; }
public string Department { get; set; }
public ApiDateTime WorkFrom { get; set; }
public List<GroupWrapperSummary> Groups { get; set; }
public List<GroupSummaryDto> Groups { get; set; }
public string Location { get; set; }
public string Notes { get; set; }
public string AvatarMax { get; set; }
@ -71,7 +71,7 @@ public class EmployeeWraperFull : EmployeeWraper
UserName = "Mike.Zanyatski",
LastName = "Zanyatski",
Title = "Manager",
Groups = new List<GroupWrapperSummary> { GroupWrapperSummary.GetSample() },
Groups = new List<GroupSummaryDto> { GroupSummaryDto.GetSample() },
AvatarMedium = "url to medium avatar",
Birthday = ApiDateTime.GetSample(),
Department = "Marketing",
@ -189,7 +189,7 @@ public class EmployeeWraperFullHelper : EmployeeWraperHelper
if (_context.Check("groups") || _context.Check("department"))
{
var groups = UserManager.GetUserGroups(userInfo.ID)
.Select(x => new GroupWrapperSummary(x, UserManager))
.Select(x => new GroupSummaryDto(x, UserManager))
.ToList();
if (groups.Count > 0)

View File

@ -1,54 +1,54 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using GroupInfo = ASC.Core.Users.GroupInfo;
namespace ASC.Web.Api.Models;
public class GroupWrapperSummary
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Manager { get; set; }
protected GroupWrapperSummary() { }
public GroupWrapperSummary(GroupInfo group, UserManager userManager)
{
Id = group.ID;
Name = group.Name;
Manager = userManager.GetUsers(userManager.GetDepartmentManager(group.ID)).UserName;
}
public static GroupWrapperSummary GetSample()
{
return new GroupWrapperSummary
{
Id = Guid.Empty,
Manager = "Jake.Zazhitski",
Name = "Group Name"
};
}
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using GroupInfo = ASC.Core.Users.GroupInfo;
namespace ASC.Web.Api.Models;
public class GroupSummaryDto
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Manager { get; set; }
protected GroupSummaryDto() { }
public GroupSummaryDto(GroupInfo group, UserManager userManager)
{
Id = group.ID;
Name = group.Name;
Manager = userManager.GetUsers(userManager.GetDepartmentManager(group.ID)).UserName;
}
public static GroupSummaryDto GetSample()
{
return new GroupSummaryDto
{
Id = Guid.Empty,
Manager = "Jake.Zazhitski",
Name = "Group Name"
};
}
}

View File

@ -117,7 +117,7 @@ namespace ASC.Api.Documents
else
{
//Shared to group
result.SharedTo = new GroupWrapperSummary(UserManager.GetGroupInfo(aceWrapper.SubjectId), UserManager);
result.SharedTo = new GroupSummaryDto(UserManager.GetGroupInfo(aceWrapper.SubjectId), UserManager);
}
}
else

View File

@ -30,14 +30,14 @@
}
[Read]
public IEnumerable<GroupWrapperSummary> GetAll()
public IEnumerable<GroupSummaryDto> GetAll()
{
var result = UserManager.GetDepartments().Select(r => r);
if (!string.IsNullOrEmpty(ApiContext.FilterValue))
{
result = result.Where(r => r.Name.Contains(ApiContext.FilterValue, StringComparison.InvariantCultureIgnoreCase));
}
return result.Select(x => new GroupWrapperSummary(x, UserManager));
return result.Select(x => new GroupSummaryDto(x, UserManager));
}
[Read("full")]
@ -58,9 +58,9 @@
}
[Read("user/{userid}")]
public IEnumerable<GroupWrapperSummary> GetByUserId(Guid userid)
public IEnumerable<GroupSummaryDto> GetByUserId(Guid userid)
{
return UserManager.GetUserGroups(userid).Select(x => new GroupWrapperSummary(x, UserManager));
return UserManager.GetUserGroups(userid).Select(x => new GroupSummaryDto(x, UserManager));
}
[Create]

View File

@ -1,9 +1,8 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.RequestDto;
public class GroupRequestDto
{
public class GroupRequestDto
{
public Guid GroupManager { get; set; }
public string GroupName { get; set; }
public IEnumerable<Guid> Members { get; set; }
}
public Guid GroupManager { get; set; }
public string GroupName { get; set; }
public IEnumerable<Guid> Members { get; set; }
}

View File

@ -1,16 +1,15 @@
namespace ASC.People.Models
{
public class LinkAccountRequestDto
{
public string SerializedProfile { get; set; }
}
public class SignupAccountRequestDto: LinkAccountRequestDto
{
public EmployeeType? EmplType { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string PasswordHash { get; set; }
}
namespace ASC.People.ApiModels.RequestDto;
public class LinkAccountRequestDto
{
public string SerializedProfile { get; set; }
}
public class SignupAccountRequestDto : LinkAccountRequestDto
{
public EmployeeType? EmplType { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string PasswordHash { get; set; }
}

View File

@ -1,30 +1,28 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.RequestDto;
public class MemberRequestDto
{
public class MemberRequestDto
{
public bool IsVisitor { get; set; }
public string Email { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
public Guid[] Department { get; set; }
public string Title { get; set; }
public string Location { get; set; }
public string Sex { get; set; }
public ApiDateTime Birthday { get; set; }
public ApiDateTime Worksfrom { get; set; }
public string Comment { get; set; }
public IEnumerable<Contact> Contacts { get; set; }
public string Files { get; set; }
public string Password { get; set; }
public string PasswordHash { get; set; }
public bool FromInviteLink { get; set; }
}
public class UpdateMemberRequestDto : MemberRequestDto
{
public string UserId { get; set; }
public bool? Disable { get; set; }
public string CultureName { get; set; }
}
public bool IsVisitor { get; set; }
public string Email { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
public Guid[] Department { get; set; }
public string Title { get; set; }
public string Location { get; set; }
public string Sex { get; set; }
public ApiDateTime Birthday { get; set; }
public ApiDateTime Worksfrom { get; set; }
public string Comment { get; set; }
public IEnumerable<Contact> Contacts { get; set; }
public string Files { get; set; }
public string Password { get; set; }
public string PasswordHash { get; set; }
public bool FromInviteLink { get; set; }
}
public class UpdateMemberRequestDto : MemberRequestDto
{
public string UserId { get; set; }
public bool? Disable { get; set; }
public string CultureName { get; set; }
}

View File

@ -1,10 +1,9 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.RequestDto;
public class RegisterPersonalUserRequestDto
{
public class RegisterPersonalUserRequestDto
{
public string Email { get; set; }
public string Lang { get; set; }
public bool Spam { get; set; }
public string RecaptchaResponse { get; set; }
}
public string Email { get; set; }
public string Lang { get; set; }
public bool Spam { get; set; }
public string RecaptchaResponse { get; set; }
}

View File

@ -1,7 +1,6 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.RequestDto;
public class SetManagerRequestDto
{
public class SetManagerRequestDto
{
public Guid UserId { get; set; }
}
public Guid UserId { get; set; }
}

View File

@ -1,9 +1,8 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.RequestDto;
public class StartReassignRequestDto
{
public class StartReassignRequestDto
{
public Guid FromUserId { get; set; }
public Guid ToUserId { get; set; }
public bool DeleteProfile { get; set; }
}
public Guid FromUserId { get; set; }
public Guid ToUserId { get; set; }
public bool DeleteProfile { get; set; }
}

View File

@ -1,7 +1,6 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.RequestDto;
public class TerminateRequestDto
{
public class TerminateRequestDto
{
public Guid UserId { get; set; }
}
public Guid UserId { get; set; }
}

View File

@ -1,11 +1,10 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.RequestDto;
public class ThumbnailsRequestDto
{
public class ThumbnailsRequestDto
{
public string TmpFile { get; set; }
public int X { get; set; }
public int Y { get; set; }
public int Width { get; set; }
public int Height { get; set; }
}
public string TmpFile { get; set; }
public int X { get; set; }
public int Y { get; set; }
public int Width { get; set; }
public int Height { get; set; }
}

View File

@ -1,8 +1,7 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.RequestDto;
public class TransferGroupMembersRequestDto
{
public class TransferGroupMembersRequestDto
{
public Guid GroupId { get; set; }
public Guid NewGroupId { get; set; }
}
public Guid GroupId { get; set; }
public Guid NewGroupId { get; set; }
}

View File

@ -1,7 +1,6 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.RequestDto;
public class UpdateMembersRequestDto
{
public class UpdateMembersRequestDto
{
public IEnumerable<Guid> UserIds { get; set; }
}
public IEnumerable<Guid> UserIds { get; set; }
}

View File

@ -1,8 +1,7 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.RequestDto;
public class UploadPhotoRequestDto
{
public class UploadPhotoRequestDto
{
public List<IFormFile> Files { get; set; }
public bool Autosave { get; set; }
}
public List<IFormFile> Files { get; set; }
public bool Autosave { get; set; }
}

View File

@ -1,10 +1,9 @@
namespace ASC.People.Models
namespace ASC.People.ApiModels.ResponseDto;
public class AccountInfoDto
{
public class AccountInfoDto
{
public string Provider { get; set; }
public string Url { get; set; }
public bool Linked { get; set; }
public string Class { get; set; }
}
public string Provider { get; set; }
public string Url { get; set; }
public bool Linked { get; set; }
public string Class { get; set; }
}

View File

@ -1,4 +1,4 @@
namespace ASC.People.ApiModels;
namespace ASC.People.ApiModels.ResponseDto;
public class FileUploadResultDto
{

View File

@ -23,67 +23,60 @@
*
*/
namespace ASC.Web.Api.Models
namespace ASC.People.ApiModels.ResponseDto;
public class GroupDto
{
public class GroupDto
public string Description { get; set; }
public string Name { get; set; }
public Guid? Parent { get; set; }
public Guid Category { get; set; }
public Guid Id { get; set; }
public EmployeeWraper Manager { get; set; }
public List<EmployeeWraper> Members { get; set; }
public static GroupDto GetSample()
{
public string Description { get; set; }
public string Name { get; set; }
public Guid? Parent { get; set; }
public Guid Category { get; set; }
public Guid Id { get; set; }
public EmployeeWraper Manager { get; set; }
public List<EmployeeWraper> Members { get; set; }
public static GroupDto GetSample()
return new GroupDto
{
return new GroupDto
{
Id = Guid.NewGuid(),
Manager = EmployeeWraper.GetSample(),
Category = Guid.NewGuid(),
Name = "Sample group",
Parent = Guid.NewGuid(),
Members = new List<EmployeeWraper> { EmployeeWraper.GetSample() }
};
}
Id = Guid.NewGuid(),
Manager = EmployeeWraper.GetSample(),
Category = Guid.NewGuid(),
Name = "Sample group",
Parent = Guid.NewGuid(),
Members = new List<EmployeeWraper> { EmployeeWraper.GetSample() }
};
}
}
[Scope]
public class GroupWraperFullHelper
{
private UserManager UserManager { get; }
private EmployeeWraperHelper EmployeeWraperHelper { get; }
public GroupWraperFullHelper(UserManager userManager, EmployeeWraperHelper employeeWraperHelper)
{
UserManager = userManager;
EmployeeWraperHelper = employeeWraperHelper;
}
[Scope]
public class GroupWraperFullHelper
public GroupDto Get(GroupInfo group, bool includeMembers)
{
private UserManager UserManager { get; }
private EmployeeWraperHelper EmployeeWraperHelper { get; }
public GroupWraperFullHelper(UserManager userManager, EmployeeWraperHelper employeeWraperHelper)
var result = new GroupDto
{
UserManager = userManager;
EmployeeWraperHelper = employeeWraperHelper;
Id = group.ID,
Category = group.CategoryID,
Parent = group.Parent != null ? group.Parent.ID : Guid.Empty,
Name = group.Name,
Manager = EmployeeWraperHelper.Get(UserManager.GetUsers(UserManager.GetDepartmentManager(group.ID)))
};
if (includeMembers)
{
result.Members = new List<EmployeeWraper>(UserManager.GetUsersByGroup(group.ID).Select(EmployeeWraperHelper.Get));
}
public GroupDto Get(GroupInfo group, bool includeMembers)
{
var result = new GroupDto
{
Id = group.ID,
Category = group.CategoryID,
Parent = group.Parent != null ? group.Parent.ID : Guid.Empty,
Name = group.Name,
Manager = EmployeeWraperHelper.Get(UserManager.GetUsers(UserManager.GetDepartmentManager(group.ID)))
};
if (includeMembers)
{
result.Members = new List<EmployeeWraper>(UserManager.GetUsersByGroup(group.ID).Select(EmployeeWraperHelper.Get));
}
return result;
}
return result;
}
}
}

View File

@ -23,48 +23,39 @@
*
*/
namespace ASC.Web.Api.Models
{
public class ThumbnailsDataDto
{
public ThumbnailsDataDto(Guid userId, UserPhotoManager userPhotoManager)
{
Original = userPhotoManager.GetPhotoAbsoluteWebPath(userId);
Retina = userPhotoManager.GetRetinaPhotoURL(userId);
Max = userPhotoManager.GetMaxPhotoURL(userId);
Big = userPhotoManager.GetBigPhotoURL(userId);
Medium = userPhotoManager.GetMediumPhotoURL(userId);
Small = userPhotoManager.GetSmallPhotoURL(userId);
}
private ThumbnailsDataDto()
{
}
public string Original { get; set; }
public string Retina { get; set; }
public string Max { get; set; }
public string Big { get; set; }
public string Medium { get; set; }
public string Small { get; set; }
public static ThumbnailsDataDto GetSample()
{
return new ThumbnailsDataDto
{
Original = "default_user_photo_size_1280-1280.png",
Retina = "default_user_photo_size_360-360.png",
Max = "default_user_photo_size_200-200.png",
Big = "default_user_photo_size_82-82.png",
Medium = "default_user_photo_size_48-48.png",
Small = "default_user_photo_size_32-32.png",
};
}
}
}
namespace ASC.People.ApiModels.ResponseDto;
public class ThumbnailsDataDto
{
public ThumbnailsDataDto(Guid userId, UserPhotoManager userPhotoManager)
{
Original = userPhotoManager.GetPhotoAbsoluteWebPath(userId);
Retina = userPhotoManager.GetRetinaPhotoURL(userId);
Max = userPhotoManager.GetMaxPhotoURL(userId);
Big = userPhotoManager.GetBigPhotoURL(userId);
Medium = userPhotoManager.GetMediumPhotoURL(userId);
Small = userPhotoManager.GetSmallPhotoURL(userId);
}
private ThumbnailsDataDto() { }
public string Original { get; set; }
public string Retina { get; set; }
public string Max { get; set; }
public string Big { get; set; }
public string Medium { get; set; }
public string Small { get; set; }
public static ThumbnailsDataDto GetSample()
{
return new ThumbnailsDataDto
{
Original = "default_user_photo_size_1280-1280.png",
Retina = "default_user_photo_size_360-360.png",
Max = "default_user_photo_size_200-200.png",
Big = "default_user_photo_size_82-82.png",
Medium = "default_user_photo_size_48-48.png",
Small = "default_user_photo_size_32-32.png",
};
}
}

View File

@ -29,7 +29,8 @@ global using ASC.FederatedLogin.Profile;
global using ASC.MessagingSystem.Core;
global using ASC.MessagingSystem.Models;
global using ASC.People;
global using ASC.People.Models;
global using ASC.People.ApiModels.RequestDto;
global using ASC.People.ApiModels.ResponseDto;
global using ASC.People.Resources;
global using ASC.Security.Cryptography;
global using ASC.Web.Api.Models;

View File

@ -789,7 +789,7 @@ namespace ASC.Api.Settings
WebItemId = i.WebItemId,
Enabled = i.Enabled,
Users = i.Users.Select(EmployeeWraperHelper.Get),
Groups = i.Groups.Select(g => new GroupWrapperSummary(g, UserManager)),
Groups = i.Groups.Select(g => new GroupSummaryDto(g, UserManager)),
IsSubItem = subItemList.Contains(i.WebItemId),
}).ToList();
}

View File

@ -31,7 +31,7 @@ namespace ASC.Api.Settings
public IEnumerable<EmployeeWraper> Users { get; set; }
public IEnumerable<GroupWrapperSummary> Groups { get; set; }
public IEnumerable<GroupSummaryDto> Groups { get; set; }
public bool Enabled { get; set; }
@ -44,9 +44,9 @@ namespace ASC.Api.Settings
WebItemId = Guid.Empty.ToString(),
Enabled = true,
IsSubItem = false,
Groups = new List<GroupWrapperSummary>
Groups = new List<GroupSummaryDto>
{
GroupWrapperSummary.GetSample()
GroupSummaryDto.GetSample()
},
Users = new List<EmployeeWraper>
{