| | |
| | | package com.vci.ubcs.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.system.entity.UserPwdstrategy; |
| | | import com.vci.ubcs.system.mapper.UserPwdstrategyMapper; |
| | | import com.vci.ubcs.system.service.IUserPwdstrategyService; |
| | | import com.vci.ubcs.system.user.entity.User; |
| | | import com.vci.ubcs.system.user.feign.IUserClient; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.vci.ubcs.common.constant.CommonConstant; |
| | | import com.vci.ubcs.system.entity.UserPwdstrategy; |
| | | import com.vci.ubcs.system.vo.UserPwdstrategyVO; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean submit(UserPwdstrategyVO userPwdstrategyVO) { |
| | | if(Func.isEmpty(userPwdstrategyVO.getUserIds())){ |
| | | throw new ServiceException("必填参数为空"); |
| | | } |
| | | //先删除 |
| | | int eft = this.userPwdstrategyMapper.deleteByUserIds(userPwdstrategyVO.getUserIds()); |
| | | this.userPwdstrategyMapper.deleteByUserIds(userPwdstrategyVO.getUserIds()); |
| | | //在新增 |
| | | List<UserPwdstrategy> userPwdstrategyList = new ArrayList<>(); |
| | | userPwdstrategyVO.getUserIds().forEach(id->{ |
| | | boolean temp = userPwdstrategyList.add(new UserPwdstrategy(id, userPwdstrategyVO.getPwdstrategyId())); |
| | | if(temp){ |
| | | //密码策略改动成功之后修改用户状态 |
| | | User user = new User(); |
| | | user.setId(id); |
| | | user.setStrategyUpdateStatus(CommonConstant.TOP_PARENT_ID); |
| | | userClient.updateUser(user); |
| | | } |
| | | userPwdstrategyList.add(new UserPwdstrategy(id, userPwdstrategyVO.getPwdstrategyId())); |
| | | }); |
| | | return this.saveBatch(userPwdstrategyList); |
| | | //密码策略改动成功之后修改用户状态 |
| | | Boolean temp = userClient.updateStrategyStatus(userPwdstrategyVO.getUserIds()).getData(); |
| | | return temp && this.saveBatch(userPwdstrategyList); |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> queryByUseISDefault(Long strategyId) { |
| | | if(Func.isEmpty(strategyId)){ |
| | | throw new ServiceException("设置默认密码策略出错!"); |
| | | } |
| | | return this.userPwdstrategyMapper.queryByUseISDefault(strategyId); |
| | | } |
| | | |
| | | } |