添加项目文件。
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using GroupService.Domain.Entities;
|
||||
using GroupService.Domain.IReposities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GroupService.Infrastructure.Reposities
|
||||
{
|
||||
public class GroupInvitationReposity : IGroupInvitationReposity
|
||||
{
|
||||
private readonly GroupDbContext db;
|
||||
|
||||
public GroupInvitationReposity(GroupDbContext db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public void Create(GroupInvitation invitation)
|
||||
{
|
||||
db.GroupInvitations.Add(invitation);
|
||||
}
|
||||
public async Task<GroupInvitation?> FindByIdAsync(Guid id)
|
||||
{
|
||||
return await db.GroupInvitations.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using GroupService.Domain.Entities;
|
||||
using GroupService.Domain.IReposities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GroupService.Infrastructure.Reposities
|
||||
{
|
||||
public class GroupJoinRequestReposity : IGroupRequestReposity
|
||||
{
|
||||
private readonly GroupDbContext db;
|
||||
|
||||
public GroupJoinRequestReposity(GroupDbContext db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public void Create(GroupJoinRequest request)
|
||||
{
|
||||
db.GroupJoinRequests.Add(request);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<GroupJoinRequest>> FindByGroupIdAsync(Guid groupId)
|
||||
{
|
||||
return await db.GroupJoinRequests.Where(x => x.GroupId == groupId)
|
||||
.OrderByDescending(o => o.CreationTime)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<GroupJoinRequest?> FindByIdAsync(Guid id)
|
||||
{
|
||||
return await db.GroupJoinRequests.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using GroupService.Domain.Entities;
|
||||
using GroupService.Domain.IReposities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GroupService.Infrastructure.Reposities
|
||||
{
|
||||
public class GroupMemberReposity : IGroupMemberReposity
|
||||
{
|
||||
private readonly GroupDbContext db;
|
||||
|
||||
public GroupMemberReposity(GroupDbContext db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckMemberExistAsync(Guid groupId, Guid userId)
|
||||
{
|
||||
return await db.GroupMembers.AnyAsync(x => x.UserId == userId &&
|
||||
x.GroupId == groupId
|
||||
);
|
||||
}
|
||||
|
||||
public GroupMember Create(GroupMember member)
|
||||
{
|
||||
db.GroupMembers.Add(member);
|
||||
return member;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<GroupMember>> FindByGroupIdAsync(Guid groupId)
|
||||
{
|
||||
return await db.GroupMembers.Where(x => x.GroupId == groupId).ToListAsync();
|
||||
}
|
||||
public async Task<GroupMember?> FindOneByGroupIdAndUserIdAsync(Guid groupId, Guid userId)
|
||||
{
|
||||
return await db.GroupMembers.FirstOrDefaultAsync(x => x.UserId == userId
|
||||
&& x.GroupId == groupId
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<GroupMember>> FindByUserIdAsync(Guid userId)
|
||||
{
|
||||
return await db.GroupMembers.Where(x => x.UserId == userId).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<GroupMember?> FindByIdAsync(Guid id)
|
||||
{
|
||||
return await db.GroupMembers.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using GroupService.Domain.Entities;
|
||||
using GroupService.Domain.IReposities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GroupService.Infrastructure.Reposities
|
||||
{
|
||||
public class GroupReposity : IGroupReposity
|
||||
{
|
||||
private readonly GroupDbContext db;
|
||||
|
||||
public GroupReposity(GroupDbContext db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public Group Create(Group group)
|
||||
{
|
||||
db.Groups.Add(group);
|
||||
return group;
|
||||
}
|
||||
|
||||
public async Task<Group?> FindByIdAsync(Guid id)
|
||||
{
|
||||
return await db.Groups.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Group>> FindByMasterIdAsync(Guid userId)
|
||||
{
|
||||
return await db.Groups.Where(x => x.GroupMaster == userId).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Group>> FindByNameAsync(string name)
|
||||
{
|
||||
return await db.Groups.Where(x => x.Name == name).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user