feat:基于furion搭建
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cike.AutoWebApi.Setting;
|
||||
using Yi.BBS.Application.Contracts.Exhibition.Dtos.Argee;
|
||||
using Yi.BBS.Domain.Exhibition.Entities;
|
||||
using Yi.BBS.Domain.Forum.Entities;
|
||||
using Yi.Framework.Core.CurrentUsers;
|
||||
using Yi.Framework.Ddd.Repositories;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
using Yi.Framework.Ddd.Services.Abstract;
|
||||
using Yi.Framework.Uow;
|
||||
|
||||
namespace Yi.BBS.Application.Exhibition
|
||||
{
|
||||
/// <summary>
|
||||
/// 点赞功能
|
||||
/// </summary>
|
||||
[AppService]
|
||||
public class AgreeService : ApplicationService, IApplicationService, IAutoApiService
|
||||
{
|
||||
|
||||
[Autowired]
|
||||
private IRepository<AgreeEntity> _repository { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IRepository<DiscussEntity> _discssRepository { get; set; }
|
||||
[Autowired]
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
|
||||
[Autowired]
|
||||
private IUnitOfWorkManager _unitOfWorkManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点赞,返回true为点赞+1,返回false为点赞-1
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<AgreeDto> PostOperateAsync(long discussId)
|
||||
{
|
||||
var entity = await _repository.GetFirstAsync(x => x.DiscussId == discussId && x.CreatorId == _currentUser.Id);
|
||||
//判断是否已经点赞过
|
||||
if (entity is null)
|
||||
{
|
||||
using (var uow = _unitOfWorkManager.CreateContext())
|
||||
{
|
||||
//没点赞过,添加记录即可,,修改总点赞数量
|
||||
await _repository.InsertAsync(new AgreeEntity(discussId));
|
||||
var discussEntity = await _discssRepository.GetByIdAsync(discussId);
|
||||
if (discussEntity is null)
|
||||
{
|
||||
throw new UserFriendlyException("主题为空");
|
||||
}
|
||||
discussEntity.AgreeNum += 1;
|
||||
await _discssRepository.UpdateAsync(discussEntity);
|
||||
uow.Commit();
|
||||
}
|
||||
return new AgreeDto(true);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var uow = _unitOfWorkManager.CreateContext())
|
||||
{
|
||||
//点赞过,删除即可,修改总点赞数量
|
||||
await _repository.DeleteByIdAsync(entity.Id);
|
||||
var discussEntity = await _discssRepository.GetByIdAsync(discussId);
|
||||
if (discussEntity is null)
|
||||
{
|
||||
throw new UserFriendlyException("主题为空");
|
||||
}
|
||||
discussEntity.AgreeNum -= 1;
|
||||
await _discssRepository.UpdateAsync(discussEntity);
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
return new AgreeDto(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<DocumentationFile>./$(AssemblyName)SwaggerDoc.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\framework\Yi.Framework.Auth.JwtBearer\Yi.Framework.Auth.JwtBearer.csproj" />
|
||||
<ProjectReference Include="..\..\..\framework\Yi.Framework.Uow\Yi.Framework.Uow.csproj" />
|
||||
<ProjectReference Include="..\..\rbac\Yi.RBAC.Application\Yi.RBAC.Application.csproj" />
|
||||
<ProjectReference Include="..\Yi.BBS.Application.Contracts\Yi.BBS.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\Yi.BBS.Domain\Yi.BBS.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="Yi.BBS.ApplicationSwaggerDoc.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,36 +0,0 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StartupModules;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.BBS.Application.Contracts;
|
||||
using Yi.Framework.Auth.JwtBearer;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Data;
|
||||
using Yi.Framework.Ddd;
|
||||
using Yi.BBS.Domain;
|
||||
using Yi.RBAC.Application;
|
||||
|
||||
namespace Yi.BBS.Application
|
||||
{
|
||||
[DependsOn(
|
||||
|
||||
typeof(YiBBSApplicationContractsModule),
|
||||
typeof(YiBBSDomainModule),
|
||||
typeof(YiFrameworkAuthJwtBearerModule),
|
||||
typeof(YiRBACApplicationModule)
|
||||
)]
|
||||
public class YiBBSApplicationModule : IStartupModule
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||
{
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user