| | |
| | | package org.springblade.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.system.entity.UserPwdstrategy; |
| | | import org.springblade.system.mapper.UserPwdstrategyMapper; |
| | | import org.springblade.system.service.IUserPwdstrategyService; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.feign.IUserClient; |
| | | import org.springblade.system.vo.UserPwdstrategyVO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户密码策略管理表(UserPwdstrategy)表服务实现类 |
| | |
| | | * @since 2023-03-22 15:24:55 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class UserPwdstrategyServiceImpl extends ServiceImpl<UserPwdstrategyMapper,UserPwdstrategy> implements IUserPwdstrategyService { |
| | | |
| | | @Resource |
| | | private UserPwdstrategyMapper userPwdstrategyMapper; |
| | | |
| | | /** |
| | | * 新增数据 |
| | | * |
| | | * @param userPwdstrategy 实例对象 |
| | | * @return 实例对象 |
| | | * user服务调用类 |
| | | */ |
| | | private final IUserClient userClient; |
| | | |
| | | @Override |
| | | public UserPwdstrategy queryById(Long id) { |
| | | return this.getById(id); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * @param userPwdstrategyVO 实例对象 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean submit(UserPwdstrategy userPwdstrategy) { |
| | | if(Func.isEmpty(userPwdstrategy.getId())){ |
| | | return this.saveOrUpdate(userPwdstrategy); |
| | | }else { |
| | | CacheUtil.clear(SYS_CACHE,Boolean.FALSE); |
| | | return this.saveOrUpdate(userPwdstrategy); |
| | | } |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean submit(UserPwdstrategyVO userPwdstrategyVO) { |
| | | //先删除 |
| | | int eft = 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); |
| | | } |
| | | }); |
| | | return this.saveBatch(userPwdstrategyList); |
| | | } |
| | | |
| | | } |