添加项目文件。
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using ContactService.Domain.Entities;
|
||||
using ContactService.Domain.ValueObjects;
|
||||
using IM.Commons;
|
||||
|
||||
namespace ContactService.Domain
|
||||
{
|
||||
public class FriendDomainService
|
||||
{
|
||||
private readonly IFriendReposity reposity;
|
||||
|
||||
public FriendDomainService(IFriendReposity reposity)
|
||||
{
|
||||
this.reposity = reposity;
|
||||
}
|
||||
|
||||
public async Task<Result<Friend?>> CreateAsync(UserProfile owner, UserProfile target, string? remarkName)
|
||||
{
|
||||
var isExist = await reposity.CheckOwnerIdAndTargetIdAsync(owner.Id, target.Id);
|
||||
if (isExist)
|
||||
{
|
||||
return Result<Friend?>.Fail(ResultCode.ALREADY_FRIENDS);
|
||||
}
|
||||
var friend = new Friend(owner, target, remarkName);
|
||||
var res = await reposity.CreateAsync(friend);
|
||||
return Result<Friend?>.Success(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user