From 8df5cd172b20ece0058ec37eaee8d058226efd52 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Mon, 29 Apr 2024 10:50:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=BF=94=E5=9B=9E=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/chint/application/out/LoginController.java | 2 ++ src/main/java/com/chint/domain/aggregates/user/User.java | 6 ++---- .../chint/domain/aggregates/user/UserDepartmentInfo.java | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/chint/application/out/LoginController.java b/src/main/java/com/chint/application/out/LoginController.java index 26611a9e..543a7381 100644 --- a/src/main/java/com/chint/application/out/LoginController.java +++ b/src/main/java/com/chint/application/out/LoginController.java @@ -3,6 +3,7 @@ package com.chint.application.out; import com.chint.application.commands.OrderCreateCommand; import com.chint.application.commands.UserLoginCommand; +import com.chint.application.commands.UserSFCommand; import com.chint.application.services.login.strategy.ANFeiShuLoginStrategy; import com.chint.application.services.login.strategy.FeishuLoginStrategy; import com.chint.application.services.login.strategy.PailaLoginStrategy; @@ -162,6 +163,7 @@ public class LoginController { private void loginEventBoarder(User user) { + Command.of(UserSFCommand.class).user(user).sendToQueue(); Command.of(UserLoginCommand.class).user(user).sendToQueue(); user.setSyncTime(LocalDateTime.now()); userRepository.save(user); diff --git a/src/main/java/com/chint/domain/aggregates/user/User.java b/src/main/java/com/chint/domain/aggregates/user/User.java index 7ac142f7..2fb565dc 100644 --- a/src/main/java/com/chint/domain/aggregates/user/User.java +++ b/src/main/java/com/chint/domain/aggregates/user/User.java @@ -372,7 +372,7 @@ public class User implements Serializable { userData.getGender(), userData.getStatus()); UserDepartmentInfo userDepartmentInfo = builder.finish(); - if (userData.getPersonIdExternal().equals(userData.getLoginUsername())) { + if (userData.getPersonIdExternal().equals(userData.getUserId())) { userDepartmentInfo.setIfPrimary(1); } else { userDepartmentInfo.setIfPrimary(0); @@ -380,9 +380,7 @@ public class User implements Serializable { List userDepartmentInfoList = this.getUserDepartmentInfoList(); List result = new ArrayList<>(); if (userDepartmentInfoList != null && !userDepartmentInfoList.isEmpty()) { - if (userDepartmentInfoList.contains(userDepartmentInfo)) { - return this; - } + userDepartmentInfoList.removeIf(departmentInfo -> departmentInfo.equals(userDepartmentInfo)); List list = userDepartmentInfoList.stream().distinct().toList(); if (userDepartmentInfo.ifPrimary()) { list.forEach(it -> it.setIfPrimary(0)); diff --git a/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java b/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java index 37719f70..5a25c6a3 100644 --- a/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java +++ b/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java @@ -82,13 +82,12 @@ public class UserDepartmentInfo implements Serializable { && Objects.equals(departmentCodeSix, that.departmentCodeSix) && Objects.equals(departmentNameSix, that.departmentNameSix) && Objects.equals(departmentCodeSeven, that.departmentCodeSeven) - && Objects.equals(departmentNameSeven, that.departmentNameSeven) - && Objects.equals(ifPrimary, that.ifPrimary); + && Objects.equals(departmentNameSeven, that.departmentNameSeven); } @Override public int hashCode() { - return Objects.hash(companyCode, companyName, departmentCodeOne, departmentNameOne, departmentCodeTwo, departmentNameTwo, departmentCodeThree, departmentNameThree, departmentCodeFour, departmentNameFour, departmentCodeFive, departmentNameFive, departmentCodeSix, departmentNameSix, departmentCodeSeven, departmentNameSeven, ifPrimary); + return Objects.hash(companyCode, companyName, departmentCodeOne, departmentNameOne, departmentCodeTwo, departmentNameTwo, departmentCodeThree, departmentNameThree, departmentCodeFour, departmentNameFour, departmentCodeFive, departmentNameFive, departmentCodeSix, departmentNameSix, departmentCodeSeven, departmentNameSeven); } public Builder start() {