|
|
@@ -0,0 +1,45 @@
|
|
|
+package org.dromara.server.mq.event.kafka.impl.cloud;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.dromara.backstage.api.RemoteUserAccountService;
|
|
|
+import org.dromara.backstage.api.domain.bo.RemoteUserAccountBo;
|
|
|
+import org.dromara.backstage.api.domain.vo.RemoteUserAccountVo;
|
|
|
+import org.dromara.common.core.constant.CloudMqEventConstants;
|
|
|
+import org.dromara.server.mq.event.kafka.IEventStrategy;
|
|
|
+import org.dromara.system.api.RemoteUserService;
|
|
|
+import org.dromara.system.api.domain.bo.RemoteUserBo;
|
|
|
+import org.dromara.system.api.domain.vo.RemoteUserVo;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName PushUserAccountEventStrategyImpl
|
|
|
+ * @Description 处理一卡通账户消息队列
|
|
|
+ * @Author luoyibo
|
|
|
+ * @Date 2024-11-12 11:52
|
|
|
+ * @Version 1.0
|
|
|
+ * @since jdk17
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Service(CloudMqEventConstants.ACCOUNT)
|
|
|
+public class PushUserAccountEventStrategyImpl implements IEventStrategy {
|
|
|
+ @DubboReference
|
|
|
+ private final RemoteUserAccountService remoteAccountService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doMsgHandle(JSONObject data) {
|
|
|
+ RemoteUserAccountBo remoteBo = JSONUtil.toBean(data, RemoteUserAccountBo.class);
|
|
|
+ log.info("[处理云端一卡通账户同步请求]-[账户信息:{}]", JSONUtil.toJsonStr(remoteBo));
|
|
|
+ RemoteUserAccountVo remoteVo = remoteAccountService.getUserAccountVoById(remoteBo.getUserId());
|
|
|
+ if(ObjectUtil.isEmpty(remoteVo)){
|
|
|
+ remoteAccountService.insertByBo(remoteBo);
|
|
|
+ } else {
|
|
|
+ remoteAccountService.updateByBo(remoteBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|