Skip to content

Commit

Permalink
新增用户更换部门时发送部门转移cap消息
Browse files Browse the repository at this point in the history
  • Loading branch information
zhontai committed Dec 15, 2024
1 parent 39e9e82 commit 7996060
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/modules/admin/ZhonTai.Admin/Core/Consts/SubscribeNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ public class SubscribeNames
/// </summary>
[Description("邮箱验证码发送")]
public const string EmailSendCode = "zhontai.admin.email:sendCode";

/// <summary>
/// 用户部门转移
/// </summary>
[Description("用户部门转移")]
public const string UserOrgChange = "zhontai.admin.user.orgChange";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;

namespace ZhonTai.Admin.Services.User.Events;

/// <summary>
/// 部门转移
/// </summary>
public class UserOrgChangeEvent
{
/// <summary>
/// 用户Id列表
/// </summary>
public long[] UserIds { get; set; }

/// <summary>
/// 所属部门Ids
/// </summary>
public virtual long[] OrgIds { get; set; }

/// <summary>
/// 主属部门Id
/// </summary>
public long OrgId { get; set; }
}
10 changes: 8 additions & 2 deletions src/modules/admin/ZhonTai.Admin/Services/User/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
using ZhonTai.Admin.Domain.Permission;
using Microsoft.Extensions.Options;
using ZhonTai.Admin.Core.Db;
using DotNetCore.CAP;
using ZhonTai.Admin.Services.Email.Events;
using ZhonTai.Admin.Services.User.Events;
using Mapster;

namespace ZhonTai.Admin.Services.User;

Expand Down Expand Up @@ -858,8 +862,10 @@ public virtual async Task BatchSetOrgAsync(UserBatchSetOrgInput input)
await _userOrgRep.InsertAsync(orgs);
}

//发送cap消息

var capPublisher= AppInfo.GetRequiredService<ICapPublisher>();
//发送部门转移
var userOrgChangeEvent = input.Adapt<UserOrgChangeEvent>();
await capPublisher.PublishAsync(SubscribeNames.UserOrgChange, userOrgChangeEvent);
}

/// <summary>
Expand Down

0 comments on commit 7996060

Please sign in to comment.