use of com.dtstack.taier.common.enums.ReadWriteLockType in project Taier by DTStack.
the class ReadWriteLockService method getLocks.
/**
* 根据 锁对象ids 批量获取锁信息
* @param tenantId
* @param type
* @param relationIds
* @param userId
* @param names
* @return
*/
public Map<Long, ReadWriteLockVO> getLocks(Long tenantId, ReadWriteLockType type, List<Long> relationIds, long userId, Map<Long, String> names) {
List<BatchReadWriteLock> ls = developReadWriteLockDao.getLocksByIds(tenantId, type.name(), relationIds);
Map<Long, BatchReadWriteLock> records = ls.stream().collect(Collectors.toMap(r -> r.getRelationId(), r -> r, (v1, v2) -> v2));
Map<Long, ReadWriteLockVO> result = Maps.newHashMap();
for (Long id : relationIds) {
if (records.containsKey(id)) {
BatchReadWriteLock readWriteLock = records.get(id);
ReadWriteLockVO readWriteLockVO = ReadWriteLockVO.toVO(readWriteLock);
readWriteLockVO.setLastKeepLockUserName(getUserNameInMemory(names, readWriteLockVO.getModifyUserId()));
result.put(id, readWriteLockVO);
} else {
ReadWriteLockVO readWriteLockVO = new ReadWriteLockVO();
readWriteLockVO.setLastKeepLockUserName(null);
readWriteLockVO.setGmtModified(null);
result.put(id, readWriteLockVO);
}
}
return result;
}
Aggregations