Merge branch 'abp' of https://gitee.com/ccnetcore/Yi into abp

This commit is contained in:
陈淳
2024-01-12 17:18:45 +08:00
18 changed files with 347 additions and 14 deletions

View File

@@ -19,5 +19,16 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser
/// 用户限制
/// </summary>
public UserLimitEnum UserLimit { get; set; }
/// <summary>
/// 钱钱
/// </summary>
public decimal Money { get; set; }
/// <summary>
/// 经验
/// </summary>
public long Experience { get; set; }
}
}

View File

@@ -71,7 +71,9 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
Icon = user.Icon,
Id = user.Id,
Level = info.Level,
UserLimit = info.UserLimit
UserLimit = info.UserLimit,
Money=info.Money,
Experience=info.Experience
},
Plate = new Contracts.Dtos.Plate.PlateGetOutputDto()
{
@@ -128,7 +130,9 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
Nick = user.Nick,
Icon = user.Icon,
Level = info.Level,
UserLimit = info.UserLimit
UserLimit = info.UserLimit,
Money = info.Money,
Experience = info.Experience
}
}, true)
@@ -169,7 +173,9 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
Nick = user.Nick,
UserName = user.UserName,
Remark = user.Remark,
UserLimit = info.UserLimit
UserLimit = info.UserLimit,
Money = info.Money,
Experience = info.Experience
}
}, true)

View File

@@ -3,18 +3,33 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Services;
using Volo.Abp.Users;
using Yi.Framework.Bbs.Domain.Managers;
namespace Yi.Framework.Bbs.Application.Services.Integral
{
public class IntegralService:ApplicationService
public class IntegralService : ApplicationService
{
private IntegralManager _integralManager;
public IntegralService(IntegralManager integralManager)
private ICurrentUser _currentUser;
public IntegralService(IntegralManager integralManager, ICurrentUser currentUser)
{
_integralManager= integralManager;
_integralManager = integralManager;
_currentUser = currentUser;
}
/// <summary>
/// 签到
/// </summary>
/// <returns></returns>
[Authorize]
public async Task<object> PostSignInAsync()
{
var value = await _integralManager.SignInAsync(_currentUser.Id ?? Guid.Empty);
return new { value };
}
}
}

View File

@@ -13,6 +13,7 @@ namespace Yi.Framework.Bbs.Domain.Entities
/// 评论表
/// </summary>
[SugarTable("BbsUserExtraInfo")]
[SugarIndex($"index_{nameof(UserId)}", nameof(UserId), OrderByType.Asc)]
public class BbsUserExtraInfoEntity : Entity<Guid>
{
public BbsUserExtraInfoEntity() { }

View File

@@ -5,6 +5,8 @@ using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Agree")]
[SugarIndex($"index_{nameof(CreatorId)}_{nameof(DiscussId)}", nameof(CreatorId), OrderByType.Asc,
nameof(DiscussId), OrderByType.Asc)]
public class AgreeEntity : Entity<Guid>, ICreationAuditedObject
{
public AgreeEntity()

View File

@@ -6,6 +6,9 @@ using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Article")]
[SugarIndex($"index_{nameof(Name)}", nameof(Name), OrderByType.Asc)]
[SugarIndex($"index_{nameof(ParentId)}", nameof(ParentId), OrderByType.Asc)]
[SugarIndex($"index_{nameof(DiscussId)}", nameof(DiscussId), OrderByType.Asc)]
public class ArticleEntity : Entity<Guid>, ISoftDelete, IAuditedObject
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]

View File

@@ -11,6 +11,8 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
/// 评论表
/// </summary>
[SugarTable("Comment")]
[SugarIndex($"index_{nameof(DiscussId)}", nameof(DiscussId), OrderByType.Asc)]
[SugarIndex($"index_{nameof(ParentId)}", nameof(ParentId), OrderByType.Asc)]
public class CommentEntity : Entity<Guid>, ISoftDelete, IAuditedObject
{
/// <summary>

View File

@@ -7,6 +7,9 @@ using Yi.Framework.Bbs.Domain.Shared.Enums;
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Discuss")]
[SugarIndex($"index_{nameof(Title)}", nameof(Title), OrderByType.Asc)]
[SugarIndex($"index_{nameof(PlateId)}", nameof(PlateId), OrderByType.Asc)]
[SugarIndex($"index_{nameof(CreationTime)}", nameof(CreationTime), OrderByType.Desc)]
public class DiscussEntity : Entity<Guid>, ISoftDelete, IAuditedObject
{
public DiscussEntity()

View File

@@ -13,6 +13,8 @@ namespace Yi.Framework.Bbs.Domain.Entities.Integral
/// 签到表
/// </summary>
[SugarTable("SignIn")]
[SugarIndex($"index_{nameof(CreatorId)}", nameof(CreatorId), OrderByType.Asc)]
public class SignInEntity : Entity<Guid>, ICreationAuditedObject
{
@@ -27,5 +29,10 @@ namespace Yi.Framework.Bbs.Domain.Entities.Integral
//签到用户
public Guid? CreatorId { get; set; }
/// <summary>
/// 连续签到次数
/// </summary>
public int ContinuousNumber { get; set; } = 1;
}
}

View File

@@ -25,7 +25,10 @@ namespace Yi.Framework.Bbs.Domain.Managers
public async Task<BbsUserInfoDto?> GetBbsUserInfoAsync(Guid userId)
{
return await _userRepository._DbQueryable.LeftJoin<BbsUserExtraInfoEntity>((user, info) => user.Id == info.UserId)
.Select((user, info) => new BbsUserInfoDto { Id = user.Id ,Icon=user.Icon,Level=info.Level,UserLimit=info.UserLimit}, true)
.Select((user, info) => new BbsUserInfoDto { Id = user.Id ,Icon=user.Icon,Level=info.Level,UserLimit=info.UserLimit,
Money = info.Money,
Experience = info.Experience
}, true)
.FirstAsync(user => user.Id==userId);
}
@@ -34,7 +37,10 @@ namespace Yi.Framework.Bbs.Domain.Managers
return await _userRepository._DbQueryable
.Where(user => userIds.Contains(user.Id))
.LeftJoin<BbsUserExtraInfoEntity>((user, info) => user.Id == info.UserId)
.Select((user, info) => new BbsUserInfoDto { Id = user.Id , Icon = user.Icon , Level = info.Level, UserLimit = info.UserLimit },true)
.Select((user, info) => new BbsUserInfoDto { Id = user.Id , Icon = user.Icon , Level = info.Level, UserLimit = info.UserLimit,
Money = info.Money,
Experience = info.Experience
},true)
.ToListAsync();
}
@@ -68,5 +74,17 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// </summary>
public UserLimitEnum UserLimit { get; set; }
/// <summary>
/// 钱钱
/// </summary>
public decimal Money { get; set; }
/// <summary>
/// 经验
/// </summary>
public long Experience { get; set; }
}
}

View File

@@ -1,5 +1,7 @@
using Volo.Abp.Domain.Services;
using Volo.Abp;
using Volo.Abp.Domain.Services;
using Volo.Abp.EventBus.Local;
using Volo.Abp.Uow;
using Yi.Framework.Bbs.Domain.Entities.Integral;
using Yi.Framework.Bbs.Domain.Shared.Etos;
using Yi.Framework.SqlSugarCore.Abstractions;
@@ -23,7 +25,8 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// 签到
/// </summary>
/// <returns></returns>
public async Task PostSignInAsync(Guid userId)
[UnitOfWork]
public async Task<decimal> SignInAsync(Guid userId)
{
//签到,添加用户钱钱
//发送一个充值的领域事件即可
@@ -33,17 +36,96 @@ namespace Yi.Framework.Bbs.Domain.Managers
//每天随机3-10连续签到每次累加多1点最多一天30
//额外
//如果随机数数字都相同额外再获取乘10
//如果随机数数字以9结尾额外再获取乘1倍
//这种逻辑,就是属于核心领域业务了
decimal number = 3;
var sigInLast = await _signInRepository._DbQueryable.Where(x => x.CreatorId == userId).OrderByDescending(x => x.CreationTime).FirstAsync();
//verify 效验是否允许签到了
if (sigInLast is not null)
{
VerifySignInTime(sigInLast.CreationTime);
}
//连续签到次数
var continuousNumber = GetContinuousNumber(sigInLast);
//签到奖励值
var value = GetSignInValue(continuousNumber);
//插入记录
var entity = new SignInEntity() { ContinuousNumber = continuousNumber };
await _signInRepository.InsertAsync(entity);
//发布一个其他领域的事件
await _localEventBus.PublishAsync(new MoneyChangeEventArgs() { UserId = userId, Number = number });
await _localEventBus.PublishAsync(new MoneyChangeEventArgs() { UserId = userId, Number = value });
return value;
}
/// <summary>
/// 效验签到时间
/// </summary>
/// <param name="dataTime"></param>
/// <exception cref="UserFriendlyException"></exception>
private void VerifySignInTime(DateTime dataTime)
{
if (dataTime.Date == DateTime.Now.Date)
{
throw new UserFriendlyException("今日你已经签到过了~");
}
}
/// <summary>
/// 获取签到值
/// </summary>
/// <param name="continuousNumber"></param>
/// <returns></returns>
private decimal GetSignInValue(int continuousNumber)
{
//基础数值
var baseValue = new Random().Next(300, 1100) / 100m;
//累加额外的奖励
var extraValue = 0m;
if (baseValue.ToString().EndsWith("9"))
{
extraValue = 1 * baseValue;
}
//累加连续签到的奖励
var signInValue = continuousNumber * 1m;
//获取添加的值
var value = baseValue + extraValue + signInValue;
if (value >= 30)
{
value = 30;
}
return value;
}
/// <summary>
/// 获取连续次数
/// </summary>
private int GetContinuousNumber(SignInEntity sigInLast)
{
var continuousNumber = 1;
//已签到过
if (sigInLast is not null)
{
//签到过,且昨天已签到过,直接使用昨天的连续次数+1
if (sigInLast.CreationTime == DateTime.Now.Date.AddDays(-1))
{
continuousNumber = sigInLast.ContinuousNumber + 1;
}
}
return continuousNumber;
}
}
}

View File

@@ -9,6 +9,7 @@ using Yi.Framework.Core.Extensions;
namespace Yi.Framework.Rbac.Domain.Entities
{
[SugarTable("LoginLog")]
[SugarIndex($"index_{nameof(LoginUser)}", nameof(LoginUser), OrderByType.Asc)]
public class LoginLogEntity : Entity<Guid>, ICreationAuditedObject
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]

View File

@@ -12,6 +12,7 @@ namespace Yi.Framework.Rbac.Domain.Entities
/// 用户表
/// </summary>
[SugarTable("User")]
[SugarIndex($"index_{nameof(UserName)}", nameof(UserName), OrderByType.Asc)]
public class UserEntity : Entity<Guid>, ISoftDelete, IAuditedObject, IOrderNum, IState
{
public UserEntity()

View File

@@ -0,0 +1,32 @@
<template>
<div class="sign-box">
<div class="menuList">菜单栏</div>
<div class="page">
<RouterView />
</div>
</div>
</template>
<script setup></script>
<style lang="scss" scoped>
.sign-box {
display: flex;
justify-content: space-between;
width: 1300px;
height: 100%;
padding: 20px 0 10px;
.menuList {
width: 25%;
height: 100%;
background-color: #fff;
border-radius: 5px;
}
.page {
width: 70%;
height: 100%;
background-color: #fff;
border-radius: 5px;
}
}
</style>

View File

@@ -0,0 +1,83 @@
<template>
<div class="common-layout">
<el-container class="common-container">
<el-header
class="common-header"
ref="header"
:class="[isFixed ? 'fixed' : '']"
>
<AppHeader />
</el-header>
<el-main class="common-main">
<SignBody />
</el-main>
</el-container>
</div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import AppHeader from "../AppHeader.vue";
import SignBody from "./components/signBody.vue";
const header = ref(null);
const isFixed = ref(false);
onMounted(() => {
window.addEventListener("scroll", handleScroll);
});
const handleScroll = () => {
const scrollTop =
window.scrollY ||
document.documentElement.scrollTop ||
document.body.scrollTop;
const currentEle = header.value.$el;
if (scrollTop > currentEle.offsetTop) {
isFixed.value = true;
} else {
isFixed.value = false;
}
};
</script>
<style scoped lang="scss">
.common {
&-layout {
width: 100%;
height: 100%;
}
&-container {
width: 100%;
height: 100%;
}
&-header {
width: 100%;
background-color: #fff;
box-shadow: rgba(0, 0, 0, 0.1) -4px 9px 25px -6px;
height: 60px;
display: flex;
justify-content: center;
}
&-main {
display: flex;
justify-content: center;
width: 100%;
height: calc(100% - 50px);
}
}
.el-main {
margin: 0;
padding: 0;
min-height: 10rem;
background-color: #f0f2f5;
}
.fixed {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 99999;
}
</style>

View File

@@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from "vue-router";
import Layout from "../layout/Index.vue";
import NotFound from "../views/error/404.vue";
import LoginLayout from "../layout/LoginLayout.vue";
import SignInLayout from "../layout/signIn/index.vue";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
scrollBehavior(to, from, savedPosition) {
@@ -98,6 +99,22 @@ const router = createRouter({
},
],
},
{
path: "/sign",
name: "signInLayout",
component: SignInLayout,
redirect: "/sign/everyday",
children: [
{
name: "everyday",
path: "everyday",
component: () => import("../views/signIn/index.vue"),
meta: {
title: "每日签到",
},
},
],
},
{ path: "/:pathMatch(.*)*", name: "NotFound", component: NotFound },
],
});

View File

@@ -85,6 +85,19 @@
</div>
</div>
</div>
<!-- 签到 -->
<el-col :span="24">
<InfoCard header="签到">
<template #content>
<div class="signIn">
<div class="left">欢迎来到意社区</div>
<div class="right">
<div class="signIn-btn" @click="handleToSign">去签到</div>
</div>
</div>
</template>
</InfoCard>
</el-col>
<el-col :span="24">
<InfoCard header="访问统计" class="VisitsLineChart" text="详情">
@@ -176,6 +189,7 @@
<script setup>
import { onMounted, ref, reactive, computed, nextTick, watch } from "vue";
import { useRouter } from "vue-router";
import DisscussCard from "@/components/DisscussCard.vue";
import InfoCard from "@/components/InfoCard.vue";
import PlateCard from "@/components/PlateCard.vue";
@@ -202,6 +216,8 @@ import useSocketStore from "@/stores/socket";
import signalR from "@/utils/signalR";
import useAuths from "@/hooks/useAuths";
const router = useRouter();
const { getToken } = useAuths();
const token = getToken();
@@ -221,7 +237,6 @@ const isAllDiscussFinished = ref(false);
const userAnalyseInfo = ref({});
const onlineNumber = ref(0);
const items = [{ user: "用户1" }, { user: "用户2" }, { user: "用户3" }];
//主题查询参数
const query = reactive({
skipCount: 1,
@@ -281,6 +296,10 @@ const statisOptions = computed(() => {
};
});
const handleToSign = () => {
router.push("/sign");
};
// 推送的实时人数获取
const currentOnlineNum = computed(() => useSocketStore().getOnlineNum());
watch(
@@ -397,6 +416,24 @@ watch(
}
}
}
.signIn {
display: flex;
justify-content: space-between;
align-items: center;
color: #8a919f;
&-btn {
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
width: 74px;
height: 36px;
border-radius: 4px;
border: 1px solid rgba(30, 128, 255, 0.3);
background-color: rgba(30, 128, 255, 0.1);
color: #1e80ff;
}
}
.VisitsLineChart >>> .el-card__body {
padding: 0.5rem;

View File

@@ -0,0 +1,12 @@
<template>
<div class="everyday-box">每日签到页持续coding中~~~</div>
</template>
<script setup></script>
<style lang="scss" scoped>
.everyday-box {
width: 100%;
height: 100%;
}
</style>