fix(ReviewEntity) , VER 1.4.14.19
parent
56e8e3e1d9
commit
28ffed532d
|
@ -5,7 +5,7 @@ public class ProductReviewController : ICarterModule
|
||||||
public void AddRoutes(IEndpointRouteBuilder app)
|
public void AddRoutes(IEndpointRouteBuilder app)
|
||||||
{
|
{
|
||||||
var group = app.NewVersionedApi("ProductReview")
|
var group = app.NewVersionedApi("ProductReview")
|
||||||
.MapGroup("product/review");
|
.MapGroup("api/product/review");
|
||||||
|
|
||||||
group.MapGet("{id}", GetAsync)
|
group.MapGet("{id}", GetAsync)
|
||||||
.WithDisplayName("Get Product Review")
|
.WithDisplayName("Get Product Review")
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<AssemblyVersion>1.4.12.17</AssemblyVersion>
|
<AssemblyVersion>1.4.14.19</AssemblyVersion>
|
||||||
<FileVersion>1.4.12.17do</FileVersion>
|
<FileVersion>1.4.14.19</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Netina.Domain.CommandQueries.Commands;
|
namespace Netina.Domain.CommandQueries.Commands;
|
||||||
|
|
||||||
public sealed record CreateReviewCommand(string Title, string Comment, float Rate, bool IsBuyer, Guid ProductId, Guid UserId) : IRequest<Guid>;
|
public sealed record CreateReviewCommand(string Title, string Comment, float Rate, bool IsBuyer,bool IsAdmin, Guid ProductId, Guid UserId) : IRequest<Guid>;
|
||||||
public sealed record UpdateReviewCommand(Guid Id,string Title, string Comment, float Rate, bool IsBuyer, Guid ProductId, Guid UserId): IRequest<Guid>;
|
public sealed record UpdateReviewCommand(Guid Id,string Title, string Comment, float Rate, bool IsBuyer, bool IsAdmin, Guid ProductId, Guid UserId): IRequest<Guid>;
|
||||||
public sealed record ConfirmReviewCommand(Guid Id) : IRequest<Guid>;
|
public sealed record ConfirmReviewCommand(Guid Id) : IRequest<Guid>;
|
||||||
public sealed record DeleteReviewCommand(Guid Id) : IRequest<Guid>;
|
public sealed record DeleteReviewCommand(Guid Id) : IRequest<Guid>;
|
|
@ -8,6 +8,7 @@ public class ReviewSDto : BaseDto<ReviewSDto, Review>
|
||||||
public string Comment { get; set; } = string.Empty;
|
public string Comment { get; set; } = string.Empty;
|
||||||
public float Rate { get; set; }
|
public float Rate { get; set; }
|
||||||
public bool IsBuyer { get; set; }
|
public bool IsBuyer { get; set; }
|
||||||
|
public bool IsAdmin { get; set; }
|
||||||
public Guid ProductId { get; set; }
|
public Guid ProductId { get; set; }
|
||||||
public Guid UserId { get; set; }
|
public Guid UserId { get; set; }
|
||||||
}
|
}
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
public partial class Review
|
public partial class Review
|
||||||
{
|
{
|
||||||
public static Reviews.Review Create(string title, string comment, float rate, bool isBuyer, Guid productId, Guid userId)
|
public static Reviews.Review Create(string title, string comment, float rate, bool isBuyer,bool isAdmin, Guid productId, Guid userId)
|
||||||
{
|
{
|
||||||
return new Reviews.Review(title, comment, rate, isBuyer, productId, userId);
|
return new Reviews.Review(title, comment, rate, isBuyer,isAdmin, productId, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConfirmReview()
|
public void ConfirmReview()
|
||||||
|
|
|
@ -10,12 +10,13 @@ public partial class Review : ApiEntity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Review(string title, string comment, float rate, bool isBuyer, Guid productId, Guid userId)
|
public Review(string title, string comment, float rate, bool isBuyer,bool isAdmin, Guid productId, Guid userId)
|
||||||
{
|
{
|
||||||
Title = title;
|
Title = title;
|
||||||
Comment = comment;
|
Comment = comment;
|
||||||
Rate = rate;
|
Rate = rate;
|
||||||
IsBuyer = isBuyer;
|
IsBuyer = isBuyer;
|
||||||
|
IsAdmin = isAdmin;
|
||||||
ProductId = productId;
|
ProductId = productId;
|
||||||
UserId = userId;
|
UserId = userId;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +25,7 @@ public partial class Review : ApiEntity
|
||||||
public float Rate { get; internal set; }
|
public float Rate { get; internal set; }
|
||||||
public bool IsBuyer { get; internal set; }
|
public bool IsBuyer { get; internal set; }
|
||||||
public bool IsConfirmed { get; internal set; }
|
public bool IsConfirmed { get; internal set; }
|
||||||
|
public bool IsAdmin { get; internal set; }
|
||||||
|
|
||||||
public Guid ProductId { get; internal set; }
|
public Guid ProductId { get; internal set; }
|
||||||
public Product? Product { get; internal set; }
|
public Product? Product { get; internal set; }
|
||||||
|
|
|
@ -127,6 +127,7 @@ namespace Netina.Domain.Mappers
|
||||||
Comment = p21.Comment,
|
Comment = p21.Comment,
|
||||||
Rate = p21.Rate,
|
Rate = p21.Rate,
|
||||||
IsBuyer = p21.IsBuyer,
|
IsBuyer = p21.IsBuyer,
|
||||||
|
IsAdmin = p21.IsAdmin,
|
||||||
ProductId = p21.ProductId,
|
ProductId = p21.ProductId,
|
||||||
UserId = p21.UserId,
|
UserId = p21.UserId,
|
||||||
Id = p21.Id,
|
Id = p21.Id,
|
||||||
|
@ -247,6 +248,7 @@ namespace Netina.Domain.Mappers
|
||||||
Comment = p37.Comment,
|
Comment = p37.Comment,
|
||||||
Rate = p37.Rate,
|
Rate = p37.Rate,
|
||||||
IsBuyer = p37.IsBuyer,
|
IsBuyer = p37.IsBuyer,
|
||||||
|
IsAdmin = p37.IsAdmin,
|
||||||
ProductId = p37.ProductId,
|
ProductId = p37.ProductId,
|
||||||
UserId = p37.UserId,
|
UserId = p37.UserId,
|
||||||
Id = p37.Id,
|
Id = p37.Id,
|
||||||
|
@ -494,6 +496,7 @@ namespace Netina.Domain.Mappers
|
||||||
Comment = item.Comment,
|
Comment = item.Comment,
|
||||||
Rate = item.Rate,
|
Rate = item.Rate,
|
||||||
IsBuyer = item.IsBuyer,
|
IsBuyer = item.IsBuyer,
|
||||||
|
IsAdmin = item.IsAdmin,
|
||||||
ProductId = item.ProductId,
|
ProductId = item.ProductId,
|
||||||
UserId = item.UserId,
|
UserId = item.UserId,
|
||||||
Id = item.Id,
|
Id = item.Id,
|
||||||
|
@ -615,6 +618,7 @@ namespace Netina.Domain.Mappers
|
||||||
Comment = item.Comment,
|
Comment = item.Comment,
|
||||||
Rate = item.Rate,
|
Rate = item.Rate,
|
||||||
IsBuyer = item.IsBuyer,
|
IsBuyer = item.IsBuyer,
|
||||||
|
IsAdmin = item.IsAdmin,
|
||||||
ProductId = item.ProductId,
|
ProductId = item.ProductId,
|
||||||
UserId = item.UserId,
|
UserId = item.UserId,
|
||||||
Id = item.Id,
|
Id = item.Id,
|
||||||
|
@ -708,6 +712,7 @@ namespace Netina.Domain.Mappers
|
||||||
Comment = item.Comment,
|
Comment = item.Comment,
|
||||||
Rate = item.Rate,
|
Rate = item.Rate,
|
||||||
IsBuyer = item.IsBuyer,
|
IsBuyer = item.IsBuyer,
|
||||||
|
IsAdmin = item.IsAdmin,
|
||||||
ProductId = item.ProductId,
|
ProductId = item.ProductId,
|
||||||
UserId = item.UserId,
|
UserId = item.UserId,
|
||||||
Id = item.Id,
|
Id = item.Id,
|
||||||
|
@ -800,6 +805,7 @@ namespace Netina.Domain.Mappers
|
||||||
Comment = item.Comment,
|
Comment = item.Comment,
|
||||||
Rate = item.Rate,
|
Rate = item.Rate,
|
||||||
IsBuyer = item.IsBuyer,
|
IsBuyer = item.IsBuyer,
|
||||||
|
IsAdmin = item.IsAdmin,
|
||||||
ProductId = item.ProductId,
|
ProductId = item.ProductId,
|
||||||
UserId = item.UserId,
|
UserId = item.UserId,
|
||||||
Id = item.Id,
|
Id = item.Id,
|
||||||
|
|
|
@ -110,6 +110,7 @@ namespace Netina.Domain.Mappers
|
||||||
Comment = p9.Comment,
|
Comment = p9.Comment,
|
||||||
Rate = p9.Rate,
|
Rate = p9.Rate,
|
||||||
IsBuyer = p9.IsBuyer,
|
IsBuyer = p9.IsBuyer,
|
||||||
|
IsAdmin = p9.IsAdmin,
|
||||||
ProductId = p9.ProductId,
|
ProductId = p9.ProductId,
|
||||||
UserId = p9.UserId,
|
UserId = p9.UserId,
|
||||||
Id = p9.Id,
|
Id = p9.Id,
|
||||||
|
@ -128,6 +129,7 @@ namespace Netina.Domain.Mappers
|
||||||
result.Comment = p10.Comment;
|
result.Comment = p10.Comment;
|
||||||
result.Rate = p10.Rate;
|
result.Rate = p10.Rate;
|
||||||
result.IsBuyer = p10.IsBuyer;
|
result.IsBuyer = p10.IsBuyer;
|
||||||
|
result.IsAdmin = p10.IsAdmin;
|
||||||
result.ProductId = p10.ProductId;
|
result.ProductId = p10.ProductId;
|
||||||
result.UserId = p10.UserId;
|
result.UserId = p10.UserId;
|
||||||
result.Id = p10.Id;
|
result.Id = p10.Id;
|
||||||
|
@ -143,6 +145,7 @@ namespace Netina.Domain.Mappers
|
||||||
Comment = p12.Comment,
|
Comment = p12.Comment,
|
||||||
Rate = p12.Rate,
|
Rate = p12.Rate,
|
||||||
IsBuyer = p12.IsBuyer,
|
IsBuyer = p12.IsBuyer,
|
||||||
|
IsAdmin = p12.IsAdmin,
|
||||||
ProductId = p12.ProductId,
|
ProductId = p12.ProductId,
|
||||||
UserId = p12.UserId,
|
UserId = p12.UserId,
|
||||||
Id = p12.Id,
|
Id = p12.Id,
|
||||||
|
@ -161,6 +164,7 @@ namespace Netina.Domain.Mappers
|
||||||
result.Comment = p13.Comment;
|
result.Comment = p13.Comment;
|
||||||
result.Rate = p13.Rate;
|
result.Rate = p13.Rate;
|
||||||
result.IsBuyer = p13.IsBuyer;
|
result.IsBuyer = p13.IsBuyer;
|
||||||
|
result.IsAdmin = p13.IsAdmin;
|
||||||
result.ProductId = p13.ProductId;
|
result.ProductId = p13.ProductId;
|
||||||
result.UserId = p13.UserId;
|
result.UserId = p13.UserId;
|
||||||
result.Id = p13.Id;
|
result.Id = p13.Id;
|
||||||
|
@ -174,6 +178,7 @@ namespace Netina.Domain.Mappers
|
||||||
Comment = p15.Comment,
|
Comment = p15.Comment,
|
||||||
Rate = p15.Rate,
|
Rate = p15.Rate,
|
||||||
IsBuyer = p15.IsBuyer,
|
IsBuyer = p15.IsBuyer,
|
||||||
|
IsAdmin = p15.IsAdmin,
|
||||||
ProductId = p15.ProductId,
|
ProductId = p15.ProductId,
|
||||||
UserId = p15.UserId,
|
UserId = p15.UserId,
|
||||||
Id = p15.Id,
|
Id = p15.Id,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Netina.Repository.Handlers.Reviews;
|
namespace Netina.Repository.Handlers.Reviews;
|
||||||
|
|
||||||
public class CreateReviewCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService)
|
public class CreateReviewCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||||
: IRequestHandler<CreateReviewCommand, Guid>
|
: IRequestHandler<CreateReviewCommand, Guid>
|
||||||
{
|
{
|
||||||
public async Task<Guid> Handle(CreateReviewCommand request, CancellationToken cancellationToken)
|
public async Task<Guid> Handle(CreateReviewCommand request, CancellationToken cancellationToken)
|
||||||
|
@ -13,13 +13,13 @@ public class CreateReviewCommandHandler(IRepositoryWrapper repositoryWrapper,ICu
|
||||||
if (!Guid.TryParse(currentUserService.UserId, out userId))
|
if (!Guid.TryParse(currentUserService.UserId, out userId))
|
||||||
throw new AppException("User id is wrong", ApiResultStatusCode.BadRequest);
|
throw new AppException("User id is wrong", ApiResultStatusCode.BadRequest);
|
||||||
}
|
}
|
||||||
var review = Review.Create(request.Title, request.Comment, request.Rate, request.IsBuyer, request.ProductId,
|
var review = Review.Create(request.Title, request.Comment, request.Rate, request.IsBuyer, request.IsAdmin, request.ProductId,
|
||||||
userId);
|
userId);
|
||||||
var product = await repositoryWrapper.SetRepository<Product>()
|
var product = await repositoryWrapper.SetRepository<Product>()
|
||||||
.TableNoTracking
|
.TableNoTracking
|
||||||
.FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken);
|
.FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken);
|
||||||
if (product == null)
|
if (product == null)
|
||||||
throw new AppException("Product not found",ApiResultStatusCode.NotFound);
|
throw new AppException("Product not found", ApiResultStatusCode.NotFound);
|
||||||
|
|
||||||
product.AddRate(request.Rate);
|
product.AddRate(request.Rate);
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace NetinaShop.Repository.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddIsAdminReview : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "IsAdmin",
|
||||||
|
schema: "public",
|
||||||
|
table: "Reviews",
|
||||||
|
type: "boolean",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IsAdmin",
|
||||||
|
schema: "public",
|
||||||
|
table: "Reviews");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -975,6 +975,9 @@ namespace NetinaShop.Repository.Migrations
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsAdmin")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<bool>("IsBuyer")
|
b.Property<bool>("IsBuyer")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue