| | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | |
| | | import com.vci.ubcs.system.user.cache.UserCache; |
| | | import com.vci.ubcs.system.user.entity.*; |
| | | import com.vci.ubcs.system.user.enums.UserEnum; |
| | | import com.vci.ubcs.system.user.enums.UserStatus; |
| | | import com.vci.ubcs.system.user.excel.UserExcel; |
| | | import com.vci.ubcs.system.user.mapper.UserMapper; |
| | | import com.vci.ubcs.system.user.service.IUserDeptService; |
| | |
| | | import com.vci.ubcs.system.user.vo.UserVO; |
| | | import com.vci.ubcs.system.user.wrapper.UserWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.core.log.annotation.GrantLog; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | |
| | | if (Func.isNotEmpty(user.getPassword())) { |
| | | user.setPassword(DigestUtil.encrypt(user.getPassword())); |
| | | } |
| | | if(Func.isEmpty(user.getUserStatus())){ |
| | | user.setUserStatus(UserStatus.Enable.getValue()); |
| | | } |
| | | Long userCount = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, user.getAccount())); |
| | | if (userCount > 0L && Func.isEmpty(user.getId())) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @GrantLog("grantUser") |
| | | public boolean updateUser(User user) { |
| | | String tenantId = user.getTenantId(); |
| | | Long userCount = baseMapper.selectCount( |
| | |
| | | .eq(User::getAccount, user.getAccount()) |
| | | .notIn(User::getId, user.getId()) |
| | | ); |
| | | // 判断是否被修改为已存在的用户名 |
| | | if (userCount > 0L) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | |
| | | return updateById(user); |
| | | } |
| | | |
| | | /** |
| | | * 根据旧账号,修改为新账号名 |
| | | * @param oldAccount |
| | | * @param newAccount |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateByAccount(String oldAccount,String newAccount) { |
| | | User user = this.userByAccount(AuthUtil.getTenantId(), oldAccount); |
| | | if(Func.isEmpty(user)){ |
| | | return true; |
| | | } |
| | | user.setAccount(newAccount); |
| | | return this.updateUser(user); |
| | | } |
| | | |
| | | /** |
| | | * 据账号,修改为用户状态 |
| | | * @param accounts |
| | | * @param status |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateStatusByAccount(String accounts, String status) { |
| | | LambdaUpdateWrapper<User> updateWrapper = Wrappers.<User>update() |
| | | .lambda().in(User::getAccount, accounts) |
| | | .set(User::getUserStatus, status); |
| | | return this.update(updateWrapper); |
| | | } |
| | | |
| | | private boolean submitUserDept(User user) { |
| | | List<Long> deptIdList = Func.toLongList(user.getDeptId()); |
| | | if(deptIdList.isEmpty()){ |
| | | return true; |
| | | } |
| | | List<UserDept> userDeptList = new ArrayList<>(); |
| | | deptIdList.forEach(deptId -> { |
| | | UserDept userDept = new UserDept(); |
| | |
| | | return this.update(user, Wrappers.<User>update().lambda().in(User::getId, Func.toLongList(userIds))); |
| | | } |
| | | |
| | | /** |
| | | * 授权日志插入操作 |
| | | * @param res |
| | | */ |
| | | @Override |
| | | @GrantLog("grantUser") |
| | | public boolean grantLog(String res, boolean isException){ |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean resetPassword(String userIds) { |
| | | User user = new User(); |