feat:搭建积分领域

This commit is contained in:
陈淳
2024-01-11 18:51:53 +08:00
parent 3ee8419802
commit 5a65a2e49f
46 changed files with 466 additions and 80 deletions

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Level
{
public class LevelGetListInputDto:PagedResultRequestDto
{ /// <summary>
/// 当前等级
/// </summary>
public int? MinLevel { get; set; }
/// <summary>
/// 等级名称
/// </summary>
public string? Name { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
using Volo.Abp.Application.Dtos;
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Level
{
public class LevelOutputDto : EntityDto<Guid>
{
public Guid Id { get; set; }
/// <summary>
/// 当前等级
/// </summary>
public int CurrentLevel { get; set; }
/// <summary>
/// 最小所需经验值
/// </summary>
public decimal MinExperience { get; set; }
/// <summary>
/// 等级名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 等级称号
/// </summary>
public string? Nick { get; set; }
/// <summary>
/// 等候logo
/// </summary>
public string? Logo { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Level;
using Yi.Framework.Ddd.Application.Contracts;
namespace Yi.Framework.Bbs.Application.Contracts.IServices
{
public interface ILevelService : IYiCrudAppService<LevelOutputDto, Guid, LevelGetListInputDto>
{
}
}

View File

@@ -0,0 +1,24 @@
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Shared.Etos;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.EventHandlers
{
public class MoneyChangeEventHandler : ILocalEventHandler<MoneyChangeEventArgs>, ITransientDependency
{
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userInfoRepository;
public MoneyChangeEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userInfoRepository)
{
_userInfoRepository = userInfoRepository;
}
public async Task HandleEventAsync(MoneyChangeEventArgs eventData)
{
//原子性sql
await _userInfoRepository._Db.Updateable<BbsUserExtraInfoEntity>()
.SetColumns(it => it.Money == it.Money + eventData.Number)
.Where(x => x.UserId == eventData.UserId).ExecuteCommandAsync();
}
}
}

View File

@@ -6,10 +6,10 @@ using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Shared.Etos;
namespace Yi.Framework.Bbs.Domain.EventHandlers
namespace Yi.Framework.Bbs.Application.EventHandlers
{
public class SeeDiscussEventHandler : ILocalEventHandler<SeeDiscussEventArgs>, ITransientDependency
{

View File

@@ -5,7 +5,7 @@ using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Shared.Enums;
using Yi.Framework.Rbac.Domain.Shared.Etos;
namespace Yi.Framework.Rbac.Application.EventHandlers
namespace Yi.Framework.Bbs.Application.EventHandlers
{
public class UserCreateEventHandler : ILocalEventHandler<UserCreateEventArgs>, ITransientDependency
{
@@ -19,7 +19,7 @@ namespace Yi.Framework.Rbac.Application.EventHandlers
//创建主表
var bbsUser = new BbsUserExtraInfoEntity(eventData.UserId)
{
};
await _repository.InsertAsync(bbsUser);
}

View File

@@ -5,6 +5,7 @@ using Volo.Abp.Application.Services;
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Managers;
using Yi.Framework.Bbs.Domain.Shared.Enums;
using Yi.Framework.Rbac.Domain.Entities;

View File

@@ -3,10 +3,10 @@ using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Uow;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Argee;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services
namespace Yi.Framework.Bbs.Application.Services.Forum
{
/// <summary>
/// 点赞功能
@@ -32,7 +32,7 @@ namespace Yi.Framework.Bbs.Application.Services
[Authorize]
public async Task<AgreeDto> PostOperateAsync(Guid discussId)
{
var entity = await _repository.GetFirstAsync(x => x.DiscussId == discussId && x.CreatorId == this.CurrentUser.Id);
var entity = await _repository.GetFirstAsync(x => x.DiscussId == discussId && x.CreatorId == CurrentUser.Id);
//判断是否已经点赞过
if (entity is null)
{

View File

@@ -13,7 +13,7 @@ using Volo.Abp.Domain.Repositories;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Article;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Plate;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Extensions;
using Yi.Framework.Bbs.Domain.Managers;
using Yi.Framework.Bbs.Domain.Repositories;
@@ -25,7 +25,7 @@ using Yi.Framework.Rbac.Domain.Authorization;
using Yi.Framework.Rbac.Domain.Shared.Consts;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services
namespace Yi.Framework.Bbs.Application.Services.Forum
{
/// <summary>
/// Article服务实现
@@ -193,7 +193,7 @@ namespace Yi.Framework.Bbs.Application.Services
//这块有点绕,这个版本的写法比较清晰
bool result = false;
if (this.CurrentUser.GetPermissions().Contains(UserConst.AdminPermissionCode))
if (CurrentUser.GetPermissions().Contains(UserConst.AdminPermissionCode))
{
//如果是超管,直接跳过
result = true;

View File

@@ -3,11 +3,11 @@ using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Banner;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Ddd.Application;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services
namespace Yi.Framework.Bbs.Application.Services.Forum
{
/// <summary>
/// Banner服务实现
@@ -18,7 +18,7 @@ namespace Yi.Framework.Bbs.Application.Services
private ISqlSugarRepository<BannerEntity, Guid> _repository;
public BannerService(ISqlSugarRepository<BannerEntity, Guid> repository) : base(repository)
{
_repository= repository;
_repository = repository;
}
public override async Task<PagedResultDto<BannerGetListOutputDto>> GetListAsync(BannerGetListInputVo input)

View File

@@ -7,7 +7,7 @@ using Volo.Abp.Application.Dtos;
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Comment;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Extensions;
using Yi.Framework.Bbs.Domain.Managers;
using Yi.Framework.Bbs.Domain.Shared.Consts;
@@ -16,7 +16,7 @@ using Yi.Framework.Rbac.Domain.Authorization;
using Yi.Framework.Rbac.Domain.Shared.Consts;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services
namespace Yi.Framework.Bbs.Application.Services.Forum
{
/// <summary>
/// 评论
@@ -112,7 +112,7 @@ namespace Yi.Framework.Bbs.Application.Services
}
//子类需要排序
var rootOutoutDto= allOutoutDto.Where(x => x.ParentId == Guid.Empty).ToList();
var rootOutoutDto = allOutoutDto.Where(x => x.ParentId == Guid.Empty).ToList();
rootOutoutDto?.ForEach(x =>
{
x.Children = x.Children.OrderByDescending(x => x.CreationTime).ToList();

View File

@@ -10,6 +10,7 @@ using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Extensions;
using Yi.Framework.Bbs.Domain.Managers;
using Yi.Framework.Bbs.Domain.Shared.Consts;
@@ -22,7 +23,7 @@ using Yi.Framework.Rbac.Domain.Entities;
using Yi.Framework.Rbac.Domain.Shared.Consts;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services
namespace Yi.Framework.Bbs.Application.Services.Forum
{
/// <summary>
/// Discuss应用服务实现,用于参数效验、领域服务业务组合、日志记录、事务处理、账户信息
@@ -58,10 +59,10 @@ namespace Yi.Framework.Bbs.Application.Services
//查询主题发布 浏览主题 事件,浏览数+1
var item = await _forumManager._discussRepository._DbQueryable.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
.LeftJoin<BbsUserExtraInfoEntity>((discuss, user, info) => user.Id == info.UserId)
.LeftJoin<PlateEntity>((discuss, user, info,plate) => plate.Id == discuss.PlateId)
.LeftJoin<PlateEntity>((discuss, user, info, plate) => plate.Id == discuss.PlateId)
.Select((discuss, user, info, plate) => new DiscussGetOutputDto
{
Id=discuss.Id,
Id = discuss.Id,
IsAgree = SqlFunc.Subqueryable<AgreeEntity>().WhereIF(CurrentUser.Id != null, x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(),
User = new BbsUserGetListOutputDto()
{
@@ -72,14 +73,14 @@ namespace Yi.Framework.Bbs.Application.Services
Level = info.Level,
UserLimit = info.UserLimit
},
Plate=new Contracts.Dtos.Plate.PlateGetOutputDto()
{
Name=plate.Name,
Id=plate.Id,
Code=plate.Code,
Introduction=plate.Introduction,
Logo=plate.Logo
Plate = new Contracts.Dtos.Plate.PlateGetOutputDto()
{
Name = plate.Name,
Id = plate.Id,
Code = plate.Code,
Introduction = plate.Introduction,
Logo = plate.Logo
}
}, true)
.SingleAsync(discuss => discuss.Id == id);
@@ -106,7 +107,7 @@ namespace Yi.Framework.Bbs.Application.Services
var items = await _forumManager._discussRepository._DbQueryable
.WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title))
.WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId)
.WhereIF(input.IsTop is not null,x=>x.IsTop==input.IsTop)
.WhereIF(input.IsTop is not null, x => x.IsTop == input.IsTop)
.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
.LeftJoin<BbsUserExtraInfoEntity>((discuss, user, info) => user.Id == info.UserId)
@@ -155,21 +156,21 @@ namespace Yi.Framework.Bbs.Application.Services
User = new BbsUserGetListOutputDto
{
Id = user.Id,
Name=user.Name,
Name = user.Name,
Sex = user.Sex,
State = user.State,
Address = user.Address,
Age = user.Age,
CreationTime = user.CreationTime,
Level =info.Level,
Introduction = user.Introduction,
Icon= user.Icon,
Nick= user.Nick,
UserName=user.UserName,
Remark= user.Remark,
UserLimit=info.UserLimit
Level = info.Level,
Introduction = user.Introduction,
Icon = user.Icon,
Nick = user.Nick,
UserName = user.UserName,
Remark = user.Remark,
UserLimit = info.UserLimit
}
}, true)
.ToListAsync();

View File

@@ -2,11 +2,11 @@ using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
using Yi.Framework.Bbs.Application.Contracts.Dtos.MyType;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Ddd.Application;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services
namespace Yi.Framework.Bbs.Application.Services.Forum
{
/// <summary>
/// Label服务实现
@@ -15,9 +15,9 @@ namespace Yi.Framework.Bbs.Application.Services
IMyTypeService
{
private ISqlSugarRepository<MyTypeEntity, Guid> _repository;
public MyTypeService(ISqlSugarRepository<MyTypeEntity,Guid> repository, IDataFilter dataFilter):base(repository)
public MyTypeService(ISqlSugarRepository<MyTypeEntity, Guid> repository, IDataFilter dataFilter) : base(repository)
{
_repository= repository;
_repository = repository;
_dataFilter = dataFilter;
}
@@ -32,7 +32,7 @@ namespace Yi.Framework.Bbs.Application.Services
{
//过滤器需要更换
//_dataFilter.Enable<MyTypeEntity>(x => x.UserId == CurrentUser.Id);
//_dataFilter.AddFilter<MyTypeEntity>(x => x.UserId == CurrentUser.Id);
return base.GetListAsync(input);
}
@@ -45,7 +45,7 @@ namespace Yi.Framework.Bbs.Application.Services
public override async Task<MyTypeOutputDto> CreateAsync(MyTypeCreateInputVo input)
{
var entity = await MapToEntityAsync(input);
entity.UserId = CurrentUser.Id??Guid.Empty;
entity.UserId = CurrentUser.Id ?? Guid.Empty;
entity.IsDeleted = false;
var outputEntity = await _repository.InsertReturnEntityAsync(entity);
return await MapToGetOutputDtoAsync(outputEntity);

View File

@@ -3,12 +3,12 @@ using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Plate;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Ddd.Application;
using Yi.Framework.Rbac.Application.Contracts.Dtos.Config;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services
namespace Yi.Framework.Bbs.Application.Services.Forum
{
/// <summary>
/// Plate服务实现
@@ -19,7 +19,7 @@ namespace Yi.Framework.Bbs.Application.Services
private ISqlSugarRepository<PlateEntity, Guid> _repository;
public PlateService(ISqlSugarRepository<PlateEntity, Guid> repository) : base(repository)
{
_repository= repository;
_repository = repository;
}
public override async Task<PagedResultDto<PlateGetListOutputDto>> GetListAsync(PlateGetListInputVo input)
@@ -29,7 +29,7 @@ namespace Yi.Framework.Bbs.Application.Services
var entities = await _repository._DbQueryable.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name!))
.WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Name.Contains(input.Code!))
.WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.OrderByDescending(x=>x.OrderNum)
.OrderByDescending(x => x.OrderNum)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto<PlateGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Yi.Framework.Bbs.Domain.Managers;
namespace Yi.Framework.Bbs.Application.Services.Integral
{
public class IntegralService:ApplicationService
{
private IntegralManager _integralManager;
public IntegralService(IntegralManager integralManager)
{
_integralManager= integralManager;
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Level;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities.Integral;
using Yi.Framework.Ddd.Application;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services.Integral
{
/// <summary>
/// 等级服务
/// </summary>
public class LevelService : YiCrudAppService<LevelEntity, LevelOutputDto, Guid, LevelGetListInputDto>, ILevelService
{
private ISqlSugarRepository<LevelEntity, Guid> _repository;
public LevelService(ISqlSugarRepository<LevelEntity, Guid> repository) : base(repository)
{
_repository= repository;
}
/// <summary>
/// 查询等级配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<PagedResultDto<LevelOutputDto>> GetListAsync(LevelGetListInputDto input)
{
RefAsync<int> total = 0;
var entities = await _repository._DbQueryable
.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name!))
.WhereIF(input.MinLevel is not null , x => x.CurrentLevel>=input.MinLevel)
.OrderBy(x => x.CurrentLevel)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto<LevelOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Bbs.Domain.Shared.Etos
{
public class ExperienceChangeEventArgs
{
/// <summary>
/// 用户id
/// </summary>
public Guid UserId { get; set; }
/// <summary>
/// 变化经验,可负
/// </summary>
public decimal Number { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Bbs.Domain.Shared.Etos
{
public class MoneyChangeEventArgs
{
/// <summary>
/// 用户id
/// </summary>
public Guid UserId { get; set; }
/// <summary>
/// 变化金额,可负
/// </summary>
public decimal Number { get; set; }
}
}

View File

@@ -27,15 +27,27 @@ namespace Yi.Framework.Bbs.Domain.Entities
/// </summary>
public Guid UserId { get; set; }
/// <summary>
/// 用户限制
/// </summary>
public UserLimitEnum UserLimit { get; set; } = UserLimitEnum.Normal;
/// <summary>
/// 用户等级
/// </summary>
public int Level { get; set; } = 1;
/// <summary>
/// 用户限制
/// 钱钱
/// </summary>
public UserLimitEnum UserLimit { get; set; } = UserLimitEnum.Normal;
public decimal Money { get; set; } = 0m;
/// <summary>
/// 经验
/// </summary>
public long Experience { get; set; } = 0;
}
}

View File

@@ -2,7 +2,7 @@
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Agree")]
public class AgreeEntity : Entity<Guid>, ICreationAuditedObject

View File

@@ -3,10 +3,10 @@ using Volo.Abp;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Article")]
public class ArticleEntity : Entity<Guid>, ISoftDelete,IAuditedObject
public class ArticleEntity : Entity<Guid>, ISoftDelete, IAuditedObject
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
public override Guid Id { get; protected set; }

View File

@@ -3,7 +3,7 @@ using Volo.Abp;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Banner")]
public class BannerEntity : Entity<Guid>, ISoftDelete, IAuditedObject

View File

@@ -4,7 +4,7 @@ using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Yi.Framework.Rbac.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
/// <summary>
@@ -29,7 +29,7 @@ namespace Yi.Framework.Bbs.Domain.Entities
public override Guid Id { get; protected set; }
public bool IsDeleted { get; set; }
[SugarColumn(Length =500)]
[SugarColumn(Length = 500)]
public string Content { get; set; }
public Guid DiscussId { get; set; }

View File

@@ -4,7 +4,7 @@ using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Yi.Framework.Bbs.Domain.Shared.Enums;
namespace Yi.Framework.Bbs.Domain.Entities
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Discuss")]
public class DiscussEntity : Entity<Guid>, ISoftDelete, IAuditedObject

View File

@@ -1,7 +1,7 @@
using SqlSugar;
using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("DiscussMyType")]
public class DiscussMyTypeEntity : Entity<Guid>

View File

@@ -7,7 +7,7 @@ using SqlSugar;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
/// <summary>
/// 首页置顶主题

View File

@@ -2,7 +2,7 @@
using Volo.Abp;
using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("MyType")]
public class MyTypeEntity : Entity<Guid>, ISoftDelete

View File

@@ -3,7 +3,7 @@ using Volo.Abp.Domain.Entities;
using Volo.Abp;
using Volo.Abp.Auditing;
namespace Yi.Framework.Bbs.Domain.Entities
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Plate")]
public class PlateEntity : Entity<Guid>, ISoftDelete, IAuditedObject

View File

@@ -0,0 +1,51 @@
using SqlSugar;
using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities.Integral
{
/// <summary>
/// 等级表
/// </summary>
[SugarTable("Level")]
public class LevelEntity : Entity<Guid>
{
public LevelEntity() { }
public LevelEntity(int currentLevel, string name, decimal minExperience)
{
this.CurrentLevel = currentLevel;
this.Name = name;
this.MinExperience = minExperience;
}
[SugarColumn(IsPrimaryKey = true)]
public override Guid Id { get; protected set; }
/// <summary>
/// 当前等级
/// </summary>
public int CurrentLevel { get; set; }
/// <summary>
/// 最小所需经验值
/// </summary>
public decimal MinExperience { get; set; }
/// <summary>
/// 等级名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 等级称号
/// </summary>
public string? Nick { get; set; }
/// <summary>
/// 等候logo
/// </summary>
public string? Logo { get; set; }
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities.Integral
{
/// <summary>
/// 签到表
/// </summary>
[SugarTable("SignIn")]
public class SignInEntity : Entity<Guid>, ICreationAuditedObject
{
[SugarColumn(IsPrimaryKey = true)]
public override Guid Id { get; protected set; }
/// <summary>
/// 签到时间
/// </summary>
public DateTime CreationTime { get; set; }
//签到用户
public Guid? CreatorId { get; set; }
}
}

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Shared.Model;
using Yi.Framework.Core.Data;

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Shared.Model;
namespace Yi.Framework.Bbs.Domain.Managers.ArticleImport

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Shared.Model;
namespace Yi.Framework.Bbs.Domain.Managers.ArticleImport

View File

@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Domain.Services;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Managers.ArticleImport;
using Yi.Framework.Bbs.Domain.Shared.Enums;
using Yi.Framework.Bbs.Domain.Shared.Model;

View File

@@ -0,0 +1,49 @@
using Volo.Abp.Domain.Services;
using Volo.Abp.EventBus.Local;
using Yi.Framework.Bbs.Domain.Entities.Integral;
using Yi.Framework.Bbs.Domain.Shared.Etos;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Domain.Managers
{
public class IntegralManager : DomainService
{
private ISqlSugarRepository<LevelEntity> _levelRepository;
private ISqlSugarRepository<SignInEntity> _signInRepository;
private readonly ILocalEventBus _localEventBus;
public IntegralManager(ISqlSugarRepository<LevelEntity> levelRepository, ISqlSugarRepository<SignInEntity> signInRepository, ILocalEventBus localEventBus)
{
_levelRepository = levelRepository;
_localEventBus = localEventBus;
_signInRepository = signInRepository;
}
/// <summary>
/// 签到
/// </summary>
/// <returns></returns>
public async Task PostSignInAsync(Guid userId)
{
//签到,添加用户钱钱
//发送一个充值的领域事件即可
//签到添加的钱钱,跟连续签到有关系
//每天随机3-10连续签到每次累加多1点最多一天30
//额外
//如果随机数数字都相同额外再获取乘10倍
//这种逻辑,就是属于核心领域业务了
decimal number = 3;
//发布一个其他领域的事件
await _localEventBus.PublishAsync(new MoneyChangeEventArgs() { UserId = userId, Number = number });
}
}
}

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Domain.Repositories

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Rbac.Domain.Entities;
using Yi.Framework.SqlSugarCore.Abstractions;

View File

@@ -0,0 +1,41 @@
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Yi.Framework.Bbs.Domain.Entities.Integral;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
{
public class LevelDataSeed : IDataSeedContributor, ITransientDependency
{
private ISqlSugarRepository<LevelEntity> _repository;
public LevelDataSeed(ISqlSugarRepository<LevelEntity> repository)
{
_repository = repository;
}
public async Task SeedAsync(DataSeedContext context)
{
if (!await _repository.IsAnyAsync(x => true))
{
await _repository.InsertManyAsync(GetSeedData());
}
}
public List<LevelEntity> GetSeedData()
{
List<LevelEntity> entities = new List<LevelEntity>()
{
new LevelEntity(1,"小白",10),
new LevelEntity(2,"中白",30),
new LevelEntity(3,"大白",100),
new LevelEntity(4,"精英",300),
new LevelEntity(5,"熟练",600),
new LevelEntity(6,"高手",1000),
new LevelEntity(7,"老手",1500),
new LevelEntity(8,"大佬",2000),
new LevelEntity(9,"巨佬",2500),
new LevelEntity(10,"大神",3000),
};
return entities;
}
}
}

View File

@@ -1,6 +1,6 @@
using System.Linq.Expressions;
using Volo.Abp.DependencyInjection;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Repositories;
using Yi.Framework.SqlSugarCore.Abstractions;
using Yi.Framework.SqlSugarCore.Repositories;