use of com.diboot.iam.entity.IamUserPosition in project diboot by dibo-software.
the class IamPositionServiceImpl method updateUserPositionRelations.
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateUserPositionRelations(String userType, Long userId, List<IamUserPosition> userPositionList) {
if (V.isEmpty(userType) || V.isEmpty(userId)) {
throw new BusinessException(Status.FAIL_OPERATION, "参数错误");
}
// 校验用户ID是否存在
if (V.notEmpty(userPositionList)) {
for (IamUserPosition userPosition : userPositionList) {
userPosition.setUserType(userType);
userPosition.setUserId(userId);
}
}
// 删除所有旧关联数据
LambdaQueryWrapper deleteWrapper = Wrappers.<IamUserPosition>lambdaQuery().eq(IamUserPosition::getUserType, userType).eq(IamUserPosition::getUserId, userId);
long count = iamUserPositionMapper.selectCount(deleteWrapper);
if (count > 0) {
iamUserPositionMapper.delete(deleteWrapper);
}
// 批量设置新的岗位列表
if (V.isEmpty(userPositionList)) {
return true;
}
for (IamUserPosition userPosition : userPositionList) {
userPosition.setId(null);
iamUserPositionMapper.insert(userPosition);
}
return true;
}
Aggregations