From 94f5e5130f941deb0d69537851009ce56c204228 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期二, 10 十月 2023 17:13:22 +0800 Subject: [PATCH] 代码提交 --- Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java | 32 ++++++++++++++++++++------------ 1 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java index 4eceb7b..943f36f 100644 --- a/Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java @@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.vci.ubcs.system.cache.DictCache; +import com.vci.ubcs.system.cache.NacosConfigCache; import com.vci.ubcs.system.cache.ParamCache; import com.vci.ubcs.system.cache.SysCache; import com.vci.ubcs.system.entity.Strategy; @@ -52,14 +53,12 @@ import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.utils.*; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.DigestUtils; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; import static com.vci.ubcs.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD; @@ -78,11 +77,8 @@ private final IUserOauthService userOauthService; private final ISysClient sysClient; private final BladeTenantProperties tenantProperties; - //鎷垮埌閰嶇疆鐨勮秴绠d - @Value("${user-info.id}") - private String adminUserId; - @Value("${user-info.tenant-id}") - private String tenantId; + //鎷垮埌閰嶇疆鐨勮秴绠� + private final NacosConfigCache nacosConfigCache; @Override @Transactional(rollbackFor = Exception.class) @@ -90,7 +86,7 @@ if (StringUtil.isBlank(user.getTenantId())) { // user.setTenantId(BladeConstant.ADMIN_TENANT_ID); // 榛樿璁剧疆涓虹鐞嗙粍涓嬬殑鐢ㄦ埛 - user.setTenantId(this.tenantId); + user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId()); } String tenantId = user.getTenantId(); //Tenant tenant = SysCache.getTenant(tenantId); @@ -171,6 +167,14 @@ public List<User> selectAllUser(User user, Long deptId){ List<Long> deptIdList = SysCache.getDeptChildIds(deptId); List<User> users = baseMapper.selectUserPage(user, deptIdList, (AuthUtil.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? StringPool.EMPTY : AuthUtil.getTenantId())); + return users; + } + + @Override + public List<User> selectAllUser(){ + LambdaQueryWrapper<User> wrapper= Wrappers.lambdaQuery(); + wrapper.eq(User::getIsDeleted,0); + List<User> users = baseMapper.selectList(wrapper); return users; } @@ -380,6 +384,7 @@ @Override @Transactional(rollbackFor = Exception.class) public void importUser(List<UserExcel> data, Boolean isCovered) { + ArrayList<User> addUsers = new ArrayList<>(); data.forEach(userExcel -> { User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class)); // 璁剧疆鐢ㄦ埛骞冲彴 @@ -407,8 +412,10 @@ // 鑾峰彇榛樿瀵嗙爜閰嶇疆 String initPassword = ParamCache.getValue(DEFAULT_PARAM_PASSWORD); user.setPassword(initPassword); - this.submit(user); + addUsers.add(user); + //this.submit(user); }); + this.submitList(addUsers); } @Override @@ -507,12 +514,13 @@ @Override public Long checkRenAndExpr(Long userId) { //瓒呯骇绠$悊鍛樼洿鎺ヨ繑鍥炰笉闇�瑕佹彁閱掑瘑鐮佷慨鏀� - if(adminUserId.equals(userId)){ + if(nacosConfigCache.getAdminUserInfo().getUserId().equals(userId)){ return 0L; } QueryWrapper<User> wrapper = Wrappers.<User>query().eq("ID", userId); + User dbUser = this.getOne(wrapper); //鑾峰彇鍒板瘑鐮佷慨鏀规椂闂� - Date pwdUpdateTime = this.getOne(wrapper).getPwdUpdateTime(); + Date pwdUpdateTime = Func.isNotEmpty(dbUser) ? dbUser.getPwdUpdateTime():new Date(); Long pwdupdateday = 0L; if(!Func.isEmpty(pwdUpdateTime)){ pwdupdateday = dateToDay(pwdUpdateTime); @@ -548,7 +556,7 @@ public List<Map<String,String>> getByRoleUserList(BladeUser user, String roleName) { // 鑰冭檻鍒颁竴涓敤鎴峰彲浠ユ嫢鏈夊绉嶈鑹叉潈闄愶紝鑰岀敤鎴峰叧鑱旇鑹叉潈闄愭槸鐢╮ole_id瀛楁鐢ㄩ�楀彿鍒嗛殧瑙掕壊id鐨勶紝鐩存帴閲囩敤瀛愭煡璇㈡潵in鏌ヨ涓嶈兘瀹炵幇锛屾墍浠ュ厛鏌ヨ瑙掕壊id R<String> roleIds = sysClient.getRoleIds(user.getTenantId(), roleName); - if(roleIds.getCode() != 200){ + if(!roleIds.isSuccess()){ throw new ServiceException("绯荤粺鏈嶅姟feign鎺ュ彛璋冪敤閿欒锛�"); } if(Func.isBlank(roleIds.getData())){ -- Gitblit v1.9.3