ke
2024-07-19 08a962d2925baa255207fdf979e6fee794f1773b
skjcmanager/skjcmanager-service/skjcmanager-user/src/main/java/cn/gistack/system/user/service/impl/UserServiceImpl.java
@@ -32,6 +32,7 @@
import cn.gistack.system.user.excel.UserExcel;
import cn.gistack.system.user.mapper.UserMapper;
import cn.gistack.system.user.service.IUserDeptService;
import cn.gistack.system.user.service.IUserEncipherService;
import cn.gistack.system.user.service.IUserOauthService;
import cn.gistack.system.user.service.IUserService;
import cn.gistack.system.user.supo.UserSUPO;
@@ -73,6 +74,7 @@
 */
@Service
@AllArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implements IUserService {
   private static final String GUEST_NAME = "guest";
@@ -82,6 +84,8 @@
   private final BladeTenantProperties tenantProperties;
   private final IPwdClient pwdClient;
   private final IUserEncipherService userEncipherService;
   @Override
   @Transactional(rollbackFor = Exception.class)
@@ -145,10 +149,13 @@
   @Override
   @Transactional(rollbackFor = Exception.class)
   public boolean save(User entity) {
      //对User进行加密
      encryptUserInfo(entity);
      return super.save(entity);
      boolean saveUser = super.save(entity);
      boolean saveUserEncipher = userEncipherService.save(new UserEncipher(entity));
      return saveUserEncipher && saveUser;
   }
   @Override
@@ -174,11 +181,14 @@
   }
   @Override
   @Transactional(rollbackFor = Exception.class)
   public boolean updateById(User entity) {
      encryptUserInfo(entity);
      boolean updateUser = super.updateById(entity);
      boolean updateUserEncipher = userEncipherService.updateById(new UserEncipher(entity));
      return super.updateById(entity);
      return updateUser&&updateUserEncipher;
   }
   private boolean submitUserDept(User user) {
@@ -198,17 +208,22 @@
    * 自定义分页查询
    * @param page
    * @param user
    * @param deptId
    * @param deptIds
    * @param tenantId
    * @return
    */
   @Override
   public IPage<UserVO> selectUserPage(IPage<UserVO> page, UserVO user, Long deptId, String tenantId) {
   public IPage<UserVO> selectUserPage(IPage<UserVO> page, UserVO user, String deptIds, String tenantId) {
      List<Long> deptIdList = new ArrayList<>();
      String [] deptidsStr = deptIds.split(",");
      if (null!=user.getIsDept()) {
         deptIdList.add(deptId);
         for (String str:deptidsStr) {
            deptIdList.add(Long.parseLong(str));
         }
      }else {
         deptIdList = SysCache.getDeptChildIds(deptId);
         for (String str:deptidsStr) {
            deptIdList.addAll(SysCache.getDeptChildIds(Long.parseLong(str)));
         }
      }
      return page.setRecords(baseMapper.selectUserPage(page, user, deptIdList, tenantId));
   }
@@ -377,11 +392,12 @@
   }
   @Override
   @Transactional(rollbackFor = Exception.class)
   public boolean removeUser(String userIds) {
      if (Func.contains(Func.toLongArray(userIds), AuthUtil.getUserId())) {
         throw new ServiceException("不能删除本账号!");
      }
      return deleteLogic(Func.toLongList(userIds));
      return deleteLogic(Func.toLongList(userIds)) && userEncipherService.deleteLogic(Func.toLongList(userIds));
   }
   @Override
@@ -401,6 +417,7 @@
         if (!AuthUtil.isAdministrator() || StringUtil.isBlank(user.getTenantId())) {
            user.setTenantId(AuthUtil.getTenantId());
         }
         user.setType(userExcel.getType());
         // 覆盖数据
         if (isCovered) {
            // 查询用户是否存在
@@ -412,7 +429,9 @@
            }
         }
         // 获取默认密码配置
         String initPassword = ParamCache.getValue(DEFAULT_PARAM_PASSWORD);
//         String initPassword = ParamCache.getValue(DEFAULT_PARAM_PASSWORD);
         String initPassword = CommonConstant.DEFAULT_PASSWORD;
         user.setPassword(initPassword);
         this.submit(user);
      });
@@ -541,4 +560,13 @@
   public List<User> getUserByPhoneIds(String phoneIds) {
      return baseMapper.getUserByPhoneIds(phoneIds);
   }
   @Override
   public int getSysUserNum(String adCode) {
      List<Long> deptIdList = new ArrayList<>();
         deptIdList = SysCache.getDeptChildIds(Long.parseLong(adCode));
      int number = baseMapper.getSysUserNum(deptIdList);
      return number;
   }
}