This commit is contained in:
ろむねこ 2023-12-14 11:09:11 +09:00
parent 9c30879084
commit e033eb754d
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -9,10 +9,12 @@ import one.nem.lacerta.data.Document;
import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.path.DocumentPath;
import one.nem.lacerta.model.document.tag.DocumentTag;
import one.nem.lacerta.source.database.LacertaDatabase;
import one.nem.lacerta.source.database.entity.DocumentEntity;
import one.nem.lacerta.source.database.entity.LibraryEntity;
import one.nem.lacerta.source.database.entity.TagEntity;
@ -43,7 +45,21 @@ public class DocumentImpl implements Document{
DocumentDetail documentDetail = new DocumentDetail();
DocumentEntity documentEntity = database.documentDao().findById(id);
// タグデータ作成
ArrayList<TagEntity> tagEntities = database.tagDao().findByIds(documentEntity.tagIds);
ArrayList<DocumentTag> documentTags = new ArrayList<>();
for (TagEntity tagEntity : tagEntities) {
DocumentTag documentTag = new DocumentTag();
documentTag.setId(tagEntity.id);
documentTag.setName(tagEntity.tagName);
documentTag.setColor(tagEntity.color);
documentTags.add(documentTag);
}
// パス取得
LibraryEntity libraryEntity = database.libraryDao().findById(id)
DocumentPath documentPath = new DocumentPath(libraryEntity.rootPath, libraryEntity.path);
// 組み立て処理
// TODO-rca: 切り出すべきかも?
DocumentMeta documentMeta = new DocumentMeta();
@ -51,6 +67,10 @@ public class DocumentImpl implements Document{
documentMeta.setTitle(documentEntity.title);
documentMeta.setCreatedAt(documentEntity.createdAt);
documentMeta.setUpdatedAt(documentEntity.updatedAt);
documentMeta.setTags(documentTags);
documentDetail.setMeta(documentMeta);
documentDetail.setAuthor(documentEntity.author);
documentDetail.setPath(new DocumentPath(documentEntity.defaultBranch));
}