xiejun
2023-10-19 421ee711aa469f00eaff610cfa85ad1d4b755688
Source/UBCS/ubcs-service/ubcs-user/src/main/java/com/vci/ubcs/system/user/service/impl/UserServiceImpl.java
@@ -53,15 +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.Autowired;
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;
@@ -87,7 +84,7 @@
   @Transactional(rollbackFor = Exception.class)
   public boolean submit(User user) {
      if (StringUtil.isBlank(user.getTenantId())) {
         // user.setTenantId(BladeConstant.ADMIN_TENANT_ID);
         // user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId());
         // 默认设置为管理组下的用户
         user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId());
      }
@@ -109,7 +106,7 @@
      Boolean flag = true;
      for (User user : users){
         if (StringUtil.isBlank(user.getTenantId())) {
            user.setTenantId(BladeConstant.ADMIN_TENANT_ID);
            user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId());
         }
         String tenantId = user.getTenantId();
         if (Func.isNotEmpty(user.getPassword())) {
@@ -169,7 +166,7 @@
   @Override
   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()));
      List<User> users = baseMapper.selectUserPage(user, deptIdList, (AuthUtil.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) ? StringPool.EMPTY : AuthUtil.getTenantId()));
      return users;
   }
@@ -529,6 +526,9 @@
         pwdupdateday = dateToDay(pwdUpdateTime);
      }
      Strategy strategy = sysClient.getByUserId(userId).getData();
      if(Func.isNotEmpty(strategy)){
         throw new ServiceException("密码策略查询为空,请检查当前租户下是否存在默认密码策略!");
      }
      //是否提醒通过最后一次修改密码的时间加上过期时间减去当前时间,如果小于过期提醒时间就进行提醒,如果<=0就提醒必须修改密码
      long reminder = pwdupdateday+strategy.getExpirationTime()-dateToDay(new Date());
      //提醒用户必须修改密码
@@ -573,6 +573,21 @@
      return list.stream().distinct().collect(Collectors.toList());
   }
   /***
    * 更新用户启用停用状态
    * @param userIds
    * @param status
    * @return
    */
   @Override
   public boolean updateUserStatus(String userIds, boolean status) {
      Integer userStatus = 0;
      if(!status){
         userStatus = 1;
      }
      return this.update(Wrappers.<User>lambdaUpdate().in(User::getId, Func.toLongList(userIds)).set(User::getUserStatus,userStatus));
   }
   /**
    * 日期时间格式转天
    * @param date