diff --git a/YLErpDAL/Model/ClientChangeKafkaRequest.cs b/YLErpDAL/Model/ClientChangeKafkaRequest.cs index 9541ac0e..1dc06455 100644 --- a/YLErpDAL/Model/ClientChangeKafkaRequest.cs +++ b/YLErpDAL/Model/ClientChangeKafkaRequest.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -19,4 +20,13 @@ namespace YLErp.Model public string Status { get; set; } public bool ForceLoginOut { get; set; } } + + public class SysUserChangeKafkaRequest + { + public int Id { get; set; } + + public int? Status { get; set; } + + public bool? ForceLoginOut { get; set; } + } } diff --git a/YLErpDAL/ModelBase/SystemUser.cs b/YLErpDAL/ModelBase/SystemUser.cs index 7978e103..de3e157a 100644 --- a/YLErpDAL/ModelBase/SystemUser.cs +++ b/YLErpDAL/ModelBase/SystemUser.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using Newtonsoft.Json; +using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using YLErp.Helpers; @@ -217,4 +218,16 @@ namespace BaseOUDAL public string VarietyName { get; set; } } + //定义交换数据类型 + public class SysUserChangeInfo + { + [JsonProperty("SysUserId")] + public int Id { get; set; } + + [JsonProperty("Status")] + public int? Status { get; set; } + + [JsonProperty("ForceLoginOut")] + public bool? ForceLoginOut { get; set; } + } } diff --git a/YLErpDAL/Modules/SystemModule/SysUserKafkaService.cs b/YLErpDAL/Modules/SystemModule/SysUserKafkaService.cs new file mode 100644 index 00000000..33037ad9 --- /dev/null +++ b/YLErpDAL/Modules/SystemModule/SysUserKafkaService.cs @@ -0,0 +1,37 @@ +using BaseOUDAL; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using YLErp.Abstract; +using YLErp.Helpers; +using YLErp.Model; + +namespace YLErp.Modules.SystemModule +{ + public class SysUserKafkaService + { + private IKafkaProduce kafkaProduceHelper; + private string topic = string.Empty; + public SysUserKafkaService(IKafkaProduce kafkaProduce) + { + kafkaProduceHelper = kafkaProduce; + topic = Environment.GetEnvironmentVariable("KafkaConfig_YiLian_SysUserInfoChangeTopic"); + } + public SysUserKafkaService() + { + kafkaProduceHelper = new KafkaProduceHelper(); + topic = Environment.GetEnvironmentVariable("KafkaConfig_YiLian_SysUserInfoChangeTopic"); + } + public void Send(SysUserChangeInfo sysUser) + { + SysUserChangeKafkaRequest sysUserChangeKafkaRequest = new SysUserChangeKafkaRequest(); + sysUserChangeKafkaRequest.Id = sysUser.Id; + if (!string.IsNullOrEmpty(topic)) + { + kafkaProduceHelper.Produce(topic, JsonHelper.Serialize(sysUserChangeKafkaRequest)); + } + } + } +} diff --git a/YLErpWeb/Controllers/SystemController.cs b/YLErpWeb/Controllers/SystemController.cs index 9b34b3c8..017ea1e9 100644 --- a/YLErpWeb/Controllers/SystemController.cs +++ b/YLErpWeb/Controllers/SystemController.cs @@ -1,6 +1,7 @@ using Dapper; using Newtonsoft.Json; using System.Data; +using YLErp.Abstract; using YLErp.BLL; using YLErp.DBModels.Consts; using YLErp.Modules.DictionaryModule; @@ -12,6 +13,11 @@ namespace YLErp.Web.Controllers { readonly ErpBaseContext basedb = new ErpBaseContext(); readonly YLContext yLContext = new YLContext(); + private IKafkaProduce _kafkaProduce; + public SystemController( IKafkaProduce kafkaProduce) + { + _kafkaProduce = kafkaProduce; + } protected override void Dispose(bool disposing) { @@ -861,6 +867,11 @@ namespace YLErp.Web.Controllers //清理缓存 Providers.MemoryCacheProvider.Default.Remove("loginUser" + accountIds); new SysUserService(CurUser).UpdateState(accountIds, 1); + SysUserChangeInfo sysUserChangeInfo= new SysUserChangeInfo(); + sysUserChangeInfo.Id = accountIds; + sysUserChangeInfo.Status = 1; + sysUserChangeInfo.ForceLoginOut = true; + new SysUserKafkaService(_kafkaProduce).Send(sysUserChangeInfo); return JsonSuccess("禁用账户成功", r); } diff --git a/YLErpWeb/appsettings.local.json b/YLErpWeb/appsettings.local.json index 2d971f10..582e49f7 100644 --- a/YLErpWeb/appsettings.local.json +++ b/YLErpWeb/appsettings.local.json @@ -27,45 +27,46 @@ "LicenseContext": "NonCommercial" //The license context used } }, - "KafkaConfig": { - "BootstrapServers": "139.196.109.225:9092", // Kafka 集群的地址 - "Acks": -1, // 消息确认方式,可以是 All(-1)、Leader(1)、None(0) 中的一种 - "EnableAutoCommit": false, //是否自动提交 - "EnableIdempotence": false, // 开启幂等性,确保消息只被发送一次 - "MaxInFlight": 5, // 控制生产者在同一时间最多可以发送的未确认消息数 - "CompressionType": 0, // 消息压缩方式,可以是 None(0)、Gzip(1)、Snappy(2)、Lz4(3)、Zstd(4) 中的一种, - "MessageTimeoutMs": 3000, // 控制生产者等待消息确认的时间,单位是毫秒 - "ClientRateTopic": "ylClientRateTopic", //客户互换费率生产topic - "HedgingAccountTopic": "ylHedgingAccountTopic", //对冲账户生产topic - "AccountCapitalTopicGroupId": "YiLian_OnRspAccountCapitalConsumer", //账户资金消费组 - "ReqAccountCapitalTopic": "ReqAccountCapital", //账户资金请求topic - "OnRspAccountCapitalTopic": "OnRspAccountCapital", //账户资金请求返回topic - "AutoOffsetReset": 1, //Latest(0),Earliest(1),Error(2) - "EnableCalcBongd": false, //是否启用kafka计算 - "ReqClientRiskCheckTopic": "YiLian_ReqClientRiskCheck", //客户风控检查 - "ReqClientRiskCheckConsumerTopic": "YiLian_OnRspClientRiskCheck", //客户风控检查消费者 - "ReqClientRiskCheckTopicGroupId": "YiLian_ReqClientRiskCheckConsumer1", //客户风控检查消费者 - "ReqClientMonitorTopic": "YiLian_ReqClientMonitor", //客户资金监控 - "OnRspClientMonitorConsumerTopic": "YiLian_OnRspClientMonitor", //客户资金监控消费者 - "ReqClientMonitorTopicGroupId": "YiLian_ReqClientMonitorConsumer1", //客户资金监控消费组 - "ReqClientMonitorSingleTopic": "YiLian_ReqClientMonitorSingle", //单个客户资金监控 - "OnRspClientMonitorSingleConsumerTopic": "YiLian_OnRspClientMonitorSingle", //单个客户资金监控 - "ReqClientMonitorSingleTopicGroupId": "YiLian_ReqClientMonitorSingleConsumer1", //单个客户资金监控 - "TrsExchangeTradeConsumerTopic": "YiLian_HedgingOrder", //TRS对冲交易消费 topic - "TrsExchangeTradeConsumerTopicGroupId": "YiLian_HedgingOrderGroup1", //TRS对冲交易消费 Group - "YiLian_ReqHedgingOrderCancelTopic": "YiLian_ReqHedgingOrderCancel", //TRS对冲交易撤单请求消费 topic - "YiLian_ReqHedgingOrderCancelTopicGroupId": "YiLian_ReqHedgingOrderCancelGroup1", //TRS对冲交易撤单请求消费 Group - "YiLian_RespHedgingOrderCancelTopic": "YiLian_RespHedgingOrderCancel", //TRS对冲交易撤单请求回应 topic - "YiLian_ClientInfoChangeTopic": "YiLian_ClientInfoChangeTopic", //客户信息变更通知客户端 topic - "YiLian_CashCalcConsumerTopic": "YiLian_CashCalc", //客户资金计算 topic - "YiLian_CashCalcConsumerGroup": "YiLian_CashCalcGroup1", //客户资金计算消费组 topic - "YiLian_CashNoticeConsumerTopic": "YiLian_CashNotice", //客户资金通知 topic - "YiLian_CashNoticeConsumerGroup": "YiLian_CashNoticeGroup", //客户资金通知消费组 topic - "YiLian_HolidayResetTopic": "YiLian_HolidayReset", //交易日历缓存重新加载 topic - "YiLian_HolidayResetGroupId": "YiLian_HedgingOrderGroup1", //交易日历缓存重新加载消费 Group - "YiLian_SwapFlowTopic": "YiLian_SwapFlow", //交易端同步流水 - "YiLian_SwapFlowGroup": "YiLian_SwapFlowGroup1" //交易端同步流水消费组 - }, + "KafkaConfig": { + "BootstrapServers": "139.196.109.225:9092", // Kafka 集群的地址 + "Acks": -1, // 消息确认方式,可以是 All(-1)、Leader(1)、None(0) 中的一种 + "EnableAutoCommit": false, //是否自动提交 + "EnableIdempotence": false, // 开启幂等性,确保消息只被发送一次 + "MaxInFlight": 5, // 控制生产者在同一时间最多可以发送的未确认消息数 + "CompressionType": 0, // 消息压缩方式,可以是 None(0)、Gzip(1)、Snappy(2)、Lz4(3)、Zstd(4) 中的一种, + "MessageTimeoutMs": 3000, // 控制生产者等待消息确认的时间,单位是毫秒 + "ClientRateTopic": "ylClientRateTopic", //客户互换费率生产topic + "HedgingAccountTopic": "ylHedgingAccountTopic", //对冲账户生产topic + "AccountCapitalTopicGroupId": "YiLian_OnRspAccountCapitalConsumer", //账户资金消费组 + "ReqAccountCapitalTopic": "ReqAccountCapital", //账户资金请求topic + "OnRspAccountCapitalTopic": "OnRspAccountCapital", //账户资金请求返回topic + "AutoOffsetReset": 1, //Latest(0),Earliest(1),Error(2) + "EnableCalcBongd": false, //是否启用kafka计算 + "ReqClientRiskCheckTopic": "YiLian_ReqClientRiskCheck", //客户风控检查 + "ReqClientRiskCheckConsumerTopic": "YiLian_OnRspClientRiskCheck", //客户风控检查消费者 + "ReqClientRiskCheckTopicGroupId": "YiLian_ReqClientRiskCheckConsumer1", //客户风控检查消费者 + "ReqClientMonitorTopic": "YiLian_ReqClientMonitor", //客户资金监控 + "OnRspClientMonitorConsumerTopic": "YiLian_OnRspClientMonitor", //客户资金监控消费者 + "ReqClientMonitorTopicGroupId": "YiLian_ReqClientMonitorConsumer1", //客户资金监控消费组 + "ReqClientMonitorSingleTopic": "YiLian_ReqClientMonitorSingle", //单个客户资金监控 + "OnRspClientMonitorSingleConsumerTopic": "YiLian_OnRspClientMonitorSingle", //单个客户资金监控 + "ReqClientMonitorSingleTopicGroupId": "YiLian_ReqClientMonitorSingleConsumer1", //单个客户资金监控 + "TrsExchangeTradeConsumerTopic": "YiLian_HedgingOrder", //TRS对冲交易消费 topic + "TrsExchangeTradeConsumerTopicGroupId": "YiLian_HedgingOrderGroup1", //TRS对冲交易消费 Group + "YiLian_ReqHedgingOrderCancelTopic": "YiLian_ReqHedgingOrderCancel", //TRS对冲交易撤单请求消费 topic + "YiLian_ReqHedgingOrderCancelTopicGroupId": "YiLian_ReqHedgingOrderCancelGroup1", //TRS对冲交易撤单请求消费 Group + "YiLian_RespHedgingOrderCancelTopic": "YiLian_RespHedgingOrderCancel", //TRS对冲交易撤单请求回应 topic + "YiLian_ClientInfoChangeTopic": "YiLian_ClientInfoChangeTopic", //客户信息变更通知客户端 topic + "YiLian_CashCalcConsumerTopic": "YiLian_CashCalc", //客户资金计算 topic + "YiLian_CashCalcConsumerGroup": "YiLian_CashCalcGroup1", //客户资金计算消费组 topic + "YiLian_CashNoticeConsumerTopic": "YiLian_CashNotice", //客户资金通知 topic + "YiLian_CashNoticeConsumerGroup": "YiLian_CashNoticeGroup", //客户资金通知消费组 topic + "YiLian_HolidayResetTopic": "YiLian_HolidayReset", //交易日历缓存重新加载 topic + "YiLian_HolidayResetGroupId": "YiLian_HedgingOrderGroup1", //交易日历缓存重新加载消费 Group + "YiLian_SwapFlowTopic": "YiLian_SwapFlow", //交易端同步流水 + "YiLian_SwapFlowGroup": "YiLian_SwapFlowGroup1", //交易端同步流水消费组 + "YiLian_SysUserInfoChangeTopic": "YiLian_SysUserInfoChangeTopic"//管理端系统用户变更 + }, "BondOmsInterface": { "BaseUrl": "http://trs.yiliantech.com:8080/trs_hub_api" },