|
14 | 14 | import run.ikaros.api.core.attachment.AttachmentReferenceOperate; |
15 | 15 | import run.ikaros.api.core.subject.Subject; |
16 | 16 | import run.ikaros.api.core.subject.SubjectOperate; |
| 17 | +import run.ikaros.api.core.tag.Tag; |
| 18 | +import run.ikaros.api.core.tag.TagOperate; |
17 | 19 | import run.ikaros.api.infra.properties.IkarosProperties; |
18 | 20 | import run.ikaros.api.infra.utils.FileUtils; |
19 | | -import run.ikaros.api.store.enums.AttachmentReferenceType; |
20 | | -import run.ikaros.api.store.enums.AttachmentType; |
21 | | -import run.ikaros.api.store.enums.FileType; |
22 | | -import run.ikaros.api.store.enums.SubjectSyncPlatform; |
| 21 | +import run.ikaros.api.store.enums.*; |
23 | 22 | import run.ikaros.plugin.mikan.qbittorrent.QbTorrentInfoFilter; |
24 | 23 | import run.ikaros.plugin.mikan.qbittorrent.QbittorrentClient; |
25 | 24 | import run.ikaros.plugin.mikan.qbittorrent.model.QbTorrentInfo; |
@@ -47,18 +46,20 @@ public class MikanSubHandler { |
47 | 46 | private final SubjectOperate subjectOperate; |
48 | 47 | private final AttachmentOperate attachmentOperate; |
49 | 48 | private final AttachmentReferenceOperate attachmentReferenceOperate; |
| 49 | + private final TagOperate tagOperate; |
50 | 50 | private final IkarosProperties ikarosProperties; |
51 | 51 | private RuntimeMode pluginRuntimeMode; |
52 | 52 |
|
53 | 53 | public MikanSubHandler(MikanClient mikanClient, QbittorrentClient qbittorrentClient, |
54 | 54 | SubjectOperate subjectOperate, AttachmentOperate attachmentOperate, |
55 | | - AttachmentReferenceOperate attachmentReferenceOperate, |
| 55 | + AttachmentReferenceOperate attachmentReferenceOperate, TagOperate tagOperate, |
56 | 56 | IkarosProperties ikarosProperties) { |
57 | 57 | this.mikanClient = mikanClient; |
58 | 58 | this.qbittorrentClient = qbittorrentClient; |
59 | 59 | this.subjectOperate = subjectOperate; |
60 | 60 | this.attachmentOperate = attachmentOperate; |
61 | 61 | this.attachmentReferenceOperate = attachmentReferenceOperate; |
| 62 | + this.tagOperate = tagOperate; |
62 | 63 | this.ikarosProperties = ikarosProperties; |
63 | 64 | } |
64 | 65 |
|
@@ -177,9 +178,16 @@ private Mono<Subject> matchingSingleFile(Subject subject, String fileName, Long |
177 | 178 | return attachmentOperate.findByTypeAndParentIdAndName(AttachmentType.File, parentId, |
178 | 179 | fileName) |
179 | 180 | .map(Attachment::getId) |
180 | | - .flatMap(attId -> attachmentReferenceOperate |
| 181 | + .flatMap(attId -> tagOperate.create(Tag.builder() |
| 182 | + .createTime(LocalDateTime.now()) |
| 183 | + .type(TagType.ATTACHMENT) |
| 184 | + .masterId(attId) |
| 185 | + .name("subject:" + subject.getId()) |
| 186 | + .userId(-1L) |
| 187 | + .build())) |
| 188 | + .flatMap(tag -> attachmentReferenceOperate |
181 | 189 | .matchingAttachmentsAndSubjectEpisodes( |
182 | | - subject.getId(), new Long[]{attId}, true)) |
| 190 | + subject.getId(), new Long[]{tag.getMasterId()}, true)) |
183 | 191 | .then(Mono.just(subject)); |
184 | 192 | } |
185 | 193 |
|
|
0 commit comments