Refactor PersonRepositoryImpl class for better readability

The refactoring simplified the 'insertInto' method within the PersonRepositoryImpl class. Now, instead of transforming the item to a Multi and collecting the last item, it directly finds the person by Id. This change enhances the code's readability and maintainability.
This commit is contained in:
Struchkov Mark 2024-03-09 21:24:59 +03:00
parent 7c414bae64
commit 9d5df57645
No known key found for this signature in database
GPG Key ID: A3F0AC3F0FA52F3C

View File

@ -35,9 +35,7 @@ public class PersonRepositoryImpl implements PersonRepository {
return Uni.createFrom().item(dsl.insertInto(PERSON).set(mapper.toRecord(person)).getSQL(ParamType.NAMED_OR_INLINED))
.map(pgPool::query)
.flatMap(Query::execute)
.onItem().transformToMulti(RowSet::toMulti)
.collect().last()
.onItem().ifNotNull().transform(toDomain());
.flatMap(ignore -> findById(person.getId()));
}
@Override