mirror of https://github.com/abpframework/abp.git
13 changed files with 1245 additions and 42 deletions
File diff suppressed because it is too large
@ -0,0 +1,43 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
namespace Volo.CmsKit.Migrations |
||||
|
{ |
||||
|
public partial class Added_UserReactions : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "CmsUserReactions", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(nullable: false), |
||||
|
EntityType = table.Column<string>(maxLength: 64, nullable: false), |
||||
|
EntityId = table.Column<string>(maxLength: 64, nullable: false), |
||||
|
ReactionName = table.Column<string>(maxLength: 32, nullable: false), |
||||
|
CreationTime = table.Column<DateTime>(nullable: false), |
||||
|
UserId = table.Column<Guid>(nullable: false) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_CmsUserReactions", x => x.Id); |
||||
|
}); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_CmsUserReactions_EntityType_EntityId", |
||||
|
table: "CmsUserReactions", |
||||
|
columns: new[] { "EntityType", "EntityId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_CmsUserReactions_UserId_EntityType_EntityId_ReactionName", |
||||
|
table: "CmsUserReactions", |
||||
|
columns: new[] { "UserId", "EntityType", "EntityId", "ReactionName" }); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropTable( |
||||
|
name: "CmsUserReactions"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,11 +1,13 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
using Microsoft.AspNetCore.Mvc.RazorPages; |
using Microsoft.AspNetCore.Mvc.RazorPages; |
||||
|
|
||||
namespace Volo.CmsKit.Pages |
namespace Volo.CmsKit.Pages |
||||
{ |
{ |
||||
|
[Authorize] |
||||
public class IndexModel : PageModel |
public class IndexModel : PageModel |
||||
{ |
{ |
||||
public void OnGet() |
public void OnGet() |
||||
{ |
{ |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,10 @@ |
|||||
|
namespace Volo.CmsKit.Reactions |
||||
|
{ |
||||
|
public static class UserReactionConsts |
||||
|
{ |
||||
|
public static int EntityTypeLength { get; set; } = 64; |
||||
|
|
||||
|
public static int EntityIdLength { get; set; } = 64; |
||||
|
public static int ReactionNameLength { get; set; } = 32; |
||||
|
} |
||||
|
} |
||||
@ -1,13 +1,13 @@ |
|||||
using Volo.Abp.Data; |
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Data; |
||||
using Volo.Abp.EntityFrameworkCore; |
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.CmsKit.Reactions; |
||||
|
|
||||
namespace Volo.CmsKit.EntityFrameworkCore |
namespace Volo.CmsKit.EntityFrameworkCore |
||||
{ |
{ |
||||
[ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] |
[ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] |
||||
public interface ICmsKitDbContext : IEfCoreDbContext |
public interface ICmsKitDbContext : IEfCoreDbContext |
||||
{ |
{ |
||||
/* Add DbSet for each Aggregate Root here. Example: |
DbSet<UserReaction> UserReactions { get; } |
||||
* DbSet<Question> Questions { get; } |
|
||||
*/ |
|
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,32 +1,60 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
||||
using Volo.Abp.EntityFrameworkCore; |
using Volo.Abp.EntityFrameworkCore; |
||||
using Volo.CmsKit.EntityFrameworkCore; |
using Volo.CmsKit.EntityFrameworkCore; |
||||
|
|
||||
namespace Volo.CmsKit.Reactions |
namespace Volo.CmsKit.Reactions |
||||
{ |
{ |
||||
public class EfCoreUserReactionRepository : EfCoreRepository<ICmsKitDbContext, UserReaction, Guid>, IUserReactionRepository |
public class EfCoreUserReactionRepository : EfCoreRepository<ICmsKitDbContext, UserReaction, Guid>, |
||||
|
IUserReactionRepository |
||||
{ |
{ |
||||
public EfCoreUserReactionRepository(IDbContextProvider<ICmsKitDbContext> dbContextProvider) |
public EfCoreUserReactionRepository(IDbContextProvider<ICmsKitDbContext> dbContextProvider) |
||||
: base(dbContextProvider) |
: base(dbContextProvider) |
||||
{ |
{ |
||||
} |
} |
||||
|
|
||||
public Task<UserReaction> FindAsync(Guid userId, string entityType, string entityId, string reactionName) |
public async Task<UserReaction> FindAsync( |
||||
|
Guid userId, |
||||
|
string entityType, |
||||
|
string entityId, |
||||
|
string reactionName) |
||||
{ |
{ |
||||
throw new NotImplementedException(); |
return await DbSet |
||||
|
.Where(x => |
||||
|
x.UserId == userId && |
||||
|
x.EntityType == entityType && |
||||
|
x.EntityId == entityId && |
||||
|
x.ReactionName == reactionName) |
||||
|
.FirstOrDefaultAsync(); |
||||
} |
} |
||||
|
|
||||
public Task<List<UserReaction>> GetListForUserAsync(Guid userId, string entityType, string entityId) |
public async Task<List<UserReaction>> GetListForUserAsync(Guid userId, string entityType, string entityId) |
||||
{ |
{ |
||||
throw new NotImplementedException(); |
return await DbSet |
||||
|
.Where(x => |
||||
|
x.UserId == userId && |
||||
|
x.EntityType == entityType && |
||||
|
x.EntityId == entityId) |
||||
|
.ToListAsync(); |
||||
} |
} |
||||
|
|
||||
public Task<List<ReactionSummaryQueryResultItem>> GetSummariesAsync(string inputEntityType, string inputEntityId) |
public async Task<List<ReactionSummaryQueryResultItem>> GetSummariesAsync(string entityType, string entityId) |
||||
{ |
{ |
||||
throw new NotImplementedException(); |
return await DbSet |
||||
|
.Where(x => |
||||
|
x.EntityType == entityType && |
||||
|
x.EntityId == entityId) |
||||
|
.GroupBy(x => x.ReactionName) |
||||
|
.Select(g => new ReactionSummaryQueryResultItem |
||||
|
{ |
||||
|
ReactionName = g.Key, |
||||
|
Count = g.Count() |
||||
|
}) |
||||
|
.ToListAsync(); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue