mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-04 08:06:37 +08:00
feat: 支持用户限制
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Uow;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.Argee;
|
||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||
using Yi.Framework.Bbs.Domain.Managers;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
@@ -13,12 +15,13 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
/// </summary>
|
||||
public class AgreeService : ApplicationService, IApplicationService
|
||||
{
|
||||
public AgreeService(ISqlSugarRepository<AgreeEntity> repository, ISqlSugarRepository<DiscussAggregateRoot> discssRepository)
|
||||
public AgreeService(ISqlSugarRepository<AgreeEntity> repository, ISqlSugarRepository<DiscussAggregateRoot> discssRepository, BbsUserManager bbsUserManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_discssRepository = discssRepository;
|
||||
_bbsUserManager = bbsUserManager;
|
||||
}
|
||||
|
||||
private readonly BbsUserManager _bbsUserManager;
|
||||
private ISqlSugarRepository<AgreeEntity> _repository { get; set; }
|
||||
|
||||
private ISqlSugarRepository<DiscussAggregateRoot> _discssRepository { get; set; }
|
||||
@@ -26,17 +29,17 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
|
||||
/// <summary>
|
||||
/// 点赞,返回true为点赞+1,返回false为点赞-1
|
||||
/// Todo: 可放入领域层
|
||||
/// Todo: 可放入领域层,但是没必要,这个项目太简单了
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
public async Task<AgreeDto> PostOperateAsync(Guid discussId)
|
||||
{
|
||||
await _bbsUserManager.VerifyUserLimitAsync(CurrentUser.GetId());
|
||||
var entity = await _repository.GetFirstAsync(x => x.DiscussId == discussId && x.CreatorId == CurrentUser.Id);
|
||||
//判断是否已经点赞过
|
||||
if (entity is null)
|
||||
{
|
||||
|
||||
//没点赞过,添加记录即可,,修改总点赞数量
|
||||
await _repository.InsertAsync(new AgreeEntity(discussId));
|
||||
var discussEntity = await _discssRepository.GetByIdAsync(discussId);
|
||||
|
||||
Reference in New Issue
Block a user