From 09b3c4ff8a83d3af62365685b05715a862f34e90 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Wed, 26 Jul 2023 10:36:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E5=AE=B6=E5=AE=A1=E6=A0=B8=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E7=9A=84=E6=97=B6=E5=80=99=E4=BF=9D=E5=AD=98=E8=A7=92?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/expert/manage/ExpertManage.java | 26 ++++++++++------------ .../pmapi/expert/manage/ExpertMetaApplyManage.java | 24 ++++++-------------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java index 2b72cc0..2baafa6 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.expert.manage; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.exception.BizException; import com.ningdatech.file.entity.vo.result.AttachFileVo; @@ -82,16 +83,13 @@ public class ExpertManage { expertMetaApplyManage.autoPassExpertApply(userId); // 增加用户专家角色 - Role expertRole = iRoleService.getOne(Wrappers.lambdaQuery(Role.class).eq(Role::getCode, RoleEnum.EXPERT.name())); - UserRole expertUserRole = iUserRoleService.getOne(Wrappers.lambdaQuery(UserRole.class) - .eq(UserRole::getRoleId, expertRole.getId()).eq(UserRole::getUserId, userId)); - if (Objects.isNull(expertUserRole)) { - expertUserRole = new UserRole(); - expertUserRole.setUserId(userId); - expertUserRole.setRoleId(expertRole.getId()); - expertUserRole.setCreateBy(-1L); - expertUserRole.setCreateOn(LocalDateTime.now()); - iUserRoleService.save(expertUserRole); + Role role = iRoleService.getOne(Wrappers.lambdaQuery(Role.class).eq(Role::getCode, RoleEnum.EXPERT.name())); + UserRole expertRole = iUserRoleService.getOne(userId, role.getId()); + if (Objects.isNull(expertRole)) { + expertRole = new UserRole(); + expertRole.setUserId(userId); + expertRole.setRoleId(role.getId()); + iUserRoleService.save(expertRole); } } @@ -113,13 +111,13 @@ public class ExpertManage { expertRecommendProofSaveCmd.setRecommendationProofFileIdList(recommendProofFile.stream().map(FileBasicInfo::getFileId).collect(Collectors.toList())); } List recommendedWayDictionaryDTOList = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(recommendedWay)) { - recommendedWayDictionaryDTOList = recommendedWay.stream().map(r -> { + if (CollUtil.isNotEmpty(recommendedWay)) { + recommendedWay.forEach(r -> { ExpertDictionaryDTO expertDictionaryDTO = new ExpertDictionaryDTO(); expertDictionaryDTO.setDictionaryCode(r.getDictionaryCode()); expertDictionaryDTO.setExpertInfoField(DictExpertInfoTypeEnum.RECOMMENDED_WAY.getKey()); - return expertDictionaryDTO; - }).collect(Collectors.toList()); + recommendedWayDictionaryDTOList.add(expertDictionaryDTO); + }); } expertRecommendProofSaveCmd.setRecommendedWay(recommendedWayDictionaryDTOList); expertRecommendProofSaveCmd.setUserId(expertUserId); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java index 3bdc985..9810f7a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java @@ -49,10 +49,7 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -66,25 +63,16 @@ public class ExpertMetaApplyManage { private final IExpertMetaApplyService iMetaApplyService; private final IExpertDictionaryService expertDictionaryService; - - // private final IExpertAdminManageService ExpertAdminManageService; private final RegionCacheHelper regionCacheHelper; private final IExpertUserFullInfoService userFullInfoService; private final DictionaryCache dictionaryCache; - private final ExpertInfoService expertInfoService; - private final UserInfoHelper userInfoHelper; - private final RegionLimitHelper regionLimitHelper; - private final ExpertUserInfoHelper expertUserInfoHelper; - private final ExpertAdminManageService expertAdminManageService; - private final IExpertDictionaryService iExpertDictionaryService; - public PageVo metaApplyListQuery(MetaApplyListQuery req) { Long expertAdminUserId = LoginUserUtil.getUserId(); // 筛选符合专家类型的用户id @@ -596,11 +584,13 @@ public class ExpertMetaApplyManage { */ @Transactional(rollbackFor = Exception.class) public void autoPassExpertApply(Long expertUserId) { - List expertIntentionJoinApplyList = iMetaApplyService.list(Wrappers.lambdaQuery(ExpertMetaApply.class) + final List applyTypes = Arrays.asList(ExpertApplyTypeEnum.EXPERT_INTENTION_JOIN.getKey(), + ExpertApplyTypeEnum.EXPERT_STORAGE.getKey()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(ExpertMetaApply.class) .eq(ExpertMetaApply::getUserId, expertUserId) - .in(ExpertMetaApply::getApplyType, ExpertApplyTypeEnum.EXPERT_INTENTION_JOIN.getKey(), ExpertApplyTypeEnum.EXPERT_STORAGE.getKey()) - .eq(ExpertMetaApply::getApplyStatus, ExpertApplyStatusEnum.PENDING_REVIEW.getKey())); - + .in(ExpertMetaApply::getApplyType, applyTypes) + .eq(ExpertMetaApply::getApplyStatus, ExpertApplyStatusEnum.PENDING_REVIEW.getKey()); + List expertIntentionJoinApplyList = iMetaApplyService.list(query); for (ExpertMetaApply expertMetaApply : expertIntentionJoinApplyList) { MetaApplyResultRequest applyResult = new MetaApplyResultRequest(); applyResult.setApplyId(expertMetaApply.getId());