diff --git a/safety-eval-infrastructure/src/main/java/org/qinan/safetyeval/infrastructure/adapter/gbs/GbsUserFacadeClient.java b/safety-eval-infrastructure/src/main/java/org/qinan/safetyeval/infrastructure/adapter/gbs/GbsUserFacadeClient.java index 44c141f..d210ecd 100644 --- a/safety-eval-infrastructure/src/main/java/org/qinan/safetyeval/infrastructure/adapter/gbs/GbsUserFacadeClient.java +++ b/safety-eval-infrastructure/src/main/java/org/qinan/safetyeval/infrastructure/adapter/gbs/GbsUserFacadeClient.java @@ -3,10 +3,7 @@ package org.qinan.safetyeval.infrastructure.adapter.gbs; import com.alibaba.cola.dto.Response; import com.alibaba.cola.dto.SingleResponse; import com.jjb.saas.system.client.user.facade.UserFacade; -import com.jjb.saas.system.client.user.request.RoleDeptAddCmd; -import com.jjb.saas.system.client.user.request.UserAddCmd; -import com.jjb.saas.system.client.user.request.UserUpdatePasswordCmd; -import com.jjb.saas.system.client.user.request.UserUpdateQuitCmd; +import com.jjb.saas.system.client.user.request.*; import lombok.RequiredArgsConstructor; import org.apache.dubbo.config.annotation.DubboReference; import org.qinan.safetyeval.domain.exception.BizException; @@ -54,4 +51,8 @@ public class GbsUserFacadeClient { public void restoreJob(UserUpdateQuitCmd cmd) { userFacade.restoreJob(cmd); } + + public void updateStatusEnumBatch(FacadeUserUpdateStatusEnumBatchCmd cmd) { + userFacade.updateStatusEnumBatch(cmd); + } } \ No newline at end of file diff --git a/safety-eval-infrastructure/src/main/java/org/qinan/safetyeval/infrastructure/gatewayimpl/OrgInfoGatewayImpl.java b/safety-eval-infrastructure/src/main/java/org/qinan/safetyeval/infrastructure/gatewayimpl/OrgInfoGatewayImpl.java index 9da1072..15cf68a 100644 --- a/safety-eval-infrastructure/src/main/java/org/qinan/safetyeval/infrastructure/gatewayimpl/OrgInfoGatewayImpl.java +++ b/safety-eval-infrastructure/src/main/java/org/qinan/safetyeval/infrastructure/gatewayimpl/OrgInfoGatewayImpl.java @@ -3,14 +3,13 @@ package org.qinan.safetyeval.infrastructure.gatewayimpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.jjb.saas.system.client.user.facade.UserFacade; +import com.jjb.saas.framework.enums.enums.BooleanEnum; +import com.jjb.saas.system.client.user.request.FacadeUserUpdateStatusEnumBatchCmd; import com.jjb.saas.system.client.user.request.UserUpdatePasswordCmd; import com.jjb.saas.system.client.user.request.UserUpdateQuitCmd; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import com.zcloud.gbscommon.utils.MD5; import com.zcloud.gbscommon.utils.Sm2Util; -import org.apache.dubbo.config.annotation.DubboReference; +import lombok.extern.slf4j.Slf4j; import org.qinan.safetyeval.domain.entity.OrgInfoEntity; import org.qinan.safetyeval.domain.gateway.OrgInfoGateway; import org.qinan.safetyeval.domain.query.OrgInfoQuery; @@ -23,6 +22,8 @@ import org.qinan.safetyeval.infrastructure.mapper.OrgInfoMapper; import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelMapper; import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults; import org.qinan.safetyeval.infrastructure.support.OrgInfoCascadeDeleter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -40,6 +41,7 @@ import java.util.stream.Collectors; * @author safety-eval */ @Component +@Slf4j public class OrgInfoGatewayImpl implements OrgInfoGateway { private static final Logger LOGGER = LoggerFactory.getLogger(OrgInfoGatewayImpl.class); @@ -78,7 +80,8 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway { OrgInfoDO dataObject = orgInfoMapper.selectById(id); return toEntity(dataObject); } -@Override + + @Override public OrgInfoEntity getByCreditCode(String creditCode) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(OrgInfoDO::getCreditCode, creditCode); @@ -125,33 +128,38 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway { update.setState(state); InsertFieldDefaults.applyForUpdate(update); orgInfoMapper.updateById(update); + List departUserId = orgInfoMapper.selectList(new LambdaQueryWrapper() + .select(OrgInfoDO::getCreateId) + .eq(OrgInfoDO::getId, id)).stream() + .map(OrgInfoDO::getCreateId).collect(Collectors.toList()); + + boolean enabled = state == 1; + FacadeUserUpdateStatusEnumBatchCmd cmd = new FacadeUserUpdateStatusEnumBatchCmd(); + cmd.setIds(departUserId); + cmd.setStatusEnum(enabled ? BooleanEnum.FALSE.getValue() : BooleanEnum.TRUE.getValue()); + gbsUserFacadeClient.updateStatusEnumBatch(cmd); + // 同步启用禁用gbs用户 - List orgPersonnelDOIdS = orgPersonnelMapper.selectList(new LambdaQueryWrapper() + List userIdList = orgPersonnelMapper.selectList(new LambdaQueryWrapper() + .select(OrgPersonnelDO::getId) .eq(OrgPersonnelDO::getOrgId, id)).stream().map(OrgPersonnelDO::getId).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(orgPersonnelDOIdS)) { - for (Long orgPersonnelDOId : orgPersonnelDOIdS) { - UserUpdateQuitCmd userUpdateQuitCmd = new UserUpdateQuitCmd(); - userUpdateQuitCmd.setId(orgPersonnelDOId); - if (state == 1) { - // 禁用 - syncGbsUser("quit user", new Runnable() { - @Override - public void run() { - gbsUserFacadeClient.quit(userUpdateQuitCmd); - } - }); - } else { - // 启用 - syncGbsUser("restore user job", new Runnable() { - @Override - public void run() { - gbsUserFacadeClient.restoreJob(userUpdateQuitCmd); - } - }); - } + if (CollectionUtils.isEmpty(userIdList)) { + log.info("部门下面没有用户,不用启用禁用数据"); + return; + } + for (Long orgPersonnelDOId : userIdList) { + UserUpdateQuitCmd userUpdateQuitCmd = new UserUpdateQuitCmd(); + userUpdateQuitCmd.setId(orgPersonnelDOId); + if (enabled) { + // 禁用 + gbsUserFacadeClient.quit(userUpdateQuitCmd); + } else { + // 启用 + gbsUserFacadeClient.restoreJob(userUpdateQuitCmd); } } + } @Override @@ -245,6 +253,7 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway { } } } + private OrgInfoDO toDO(OrgInfoEntity entity) { OrgInfoDO dataObject = new OrgInfoDO(); dataObject.setUnitName(entity.getUnitName());