feat: bbs完善钱钱实时变化
This commit is contained in:
@@ -19,5 +19,10 @@ namespace Yi.Framework.Bbs.Domain.Shared.Enums
|
||||
/// 广播
|
||||
/// </summary>
|
||||
Broadcast,
|
||||
|
||||
/// <summary>
|
||||
/// 钱钱
|
||||
/// </summary>
|
||||
Money
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,13 @@ namespace Yi.Framework.Bbs.Domain.Shared.Etos
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public BbsNoticeEventArgs( NoticeTypeEnum noticeType, Guid acceptUserId, string message)
|
||||
{
|
||||
NoticeType = noticeType;
|
||||
AcceptUserId = acceptUserId;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送广播
|
||||
/// </summary>
|
||||
|
||||
@@ -38,6 +38,13 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
case Shared.Enums.NoticeTypeEnum.Broadcast:
|
||||
_hubContext.Clients.All.SendAsync(NoticeTypeEnum.Broadcast.ToString(), eventData.Message);
|
||||
break;
|
||||
|
||||
case Shared.Enums.NoticeTypeEnum.Money:
|
||||
if (BbsNoticeHub.HubUserModels.TryGetValue(eventData.AcceptUserId.ToString(), out var hubUserModel2))
|
||||
{
|
||||
_hubContext.Clients.Client(hubUserModel2.ConnnectionId).SendAsync(NoticeTypeEnum.Personal.ToString(), eventData.Message,entity.CreationTime);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.EventBus;
|
||||
using Volo.Abp.EventBus.Local;
|
||||
using Yi.Framework.Bbs.Domain.Entities;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Consts;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
@@ -11,9 +13,11 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
public class MoneyChangeEventHandler : ILocalEventHandler<MoneyChangeEventArgs>, ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userInfoRepository;
|
||||
public MoneyChangeEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userInfoRepository)
|
||||
private ILocalEventBus _localEventBus;
|
||||
public MoneyChangeEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userInfoRepository, ILocalEventBus localEventBus)
|
||||
{
|
||||
_userInfoRepository = userInfoRepository;
|
||||
_localEventBus = localEventBus;
|
||||
}
|
||||
public async Task HandleEventAsync(MoneyChangeEventArgs eventData)
|
||||
{
|
||||
@@ -28,6 +32,9 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
await _userInfoRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
||||
.SetColumns(it => it.Money == it.Money + eventData.Number)
|
||||
.Where(x => x.UserId == eventData.UserId).ExecuteCommandAsync();
|
||||
|
||||
|
||||
await _localEventBus.PublishAsync(new BbsNoticeEventArgs(NoticeTypeEnum.Money, eventData.UserId,eventData.Number.ToString()), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import signalR from "@/utils/signalR";
|
||||
import useNoticeStore from "@/stores/notice";
|
||||
import useUserStore from "@/stores/user";
|
||||
import { dayjs } from 'element-plus'
|
||||
const receiveMsg=(connection)=> {
|
||||
|
||||
@@ -11,6 +12,13 @@ const receiveMsg=(connection)=> {
|
||||
creationTime
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
const userStore=useUserStore();
|
||||
connection.on("Money", (message,creationTime) => {
|
||||
const updateMoneyNumber=Number(message)
|
||||
userStore.updateMoney(updateMoneyNumber)
|
||||
});
|
||||
};
|
||||
|
||||
export default ()=>{
|
||||
|
||||
@@ -122,23 +122,6 @@ const useUserStore = defineStore("user", {
|
||||
});
|
||||
});
|
||||
},
|
||||
//找回密码
|
||||
retrievePassword(userInfo)
|
||||
{
|
||||
const password = userInfo.password.trim();
|
||||
const phone = userInfo.phone;
|
||||
const uuid = userInfo.uuid;
|
||||
const code = userInfo.code;
|
||||
return new Promise((resolve, reject) => {
|
||||
retrievePassword(password, phone, code, uuid)
|
||||
.then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 重置用户信息
|
||||
resetInfo() {
|
||||
this.roles = [];
|
||||
@@ -153,9 +136,12 @@ const useUserStore = defineStore("user", {
|
||||
this.codeImageURL = "data:image/jpg;base64," + data.img;
|
||||
this.codeUUid = data.uuid;
|
||||
},
|
||||
updateToken(token)
|
||||
{
|
||||
updateToken(token) {
|
||||
this.token = token;
|
||||
},
|
||||
//更新钱钱
|
||||
updateMoney(updateMoneyNumber){
|
||||
this.money=this.money+updateMoneyNumber
|
||||
}
|
||||
},
|
||||
persist: {
|
||||
|
||||
Reference in New Issue
Block a user