Skip to content

Commit

Permalink
feat: provide v0.11 plugin api and fix some issues. (#488)
Browse files Browse the repository at this point in the history
* feat: upgrade to v0.11.1 and add attachment ref operate for plugin api.

* fix: can not save attachment when not appoint id.

* fix: add prefix for subject cover name repeatedly.

* style: remove some events that not use.

* style: episode group music_dist can not display normally

* style: episode details display not normal.

* feat: add plugin api for attachment exists

* feat: update global search key to ctrl + /

* optimize: attachments.vue and Subjects.vue search input.

* fix: AttachmentReferenceOperate bean not fond for plugin.

* docs: update CHANGELOG.MD
  • Loading branch information
chivehao authored Oct 24, 2023
1 parent b546248 commit 3a07783
Show file tree
Hide file tree
Showing 22 changed files with 198 additions and 67 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

更新日志文档,版本顺序从新到旧,最新版本在最前(上)面。

# 0.11.1

## 问题修复

- 插件无法正常新增附件
- 当没有指定附件ID时无法正常保存附件
- 多次引用同一个封面,会不停地给封面文件名添加前缀
- 剧集的音乐分组DIST无法正常在控制台显示
- 游戏条目绑定了压缩包资源时,剧集详情资源栏目显示异常
- 控制台附件页无法正常输入名称

## 插件

- 番组计划插件升级适配v0.11.1和问题修复
- Jellyfin插件升级适配v0.11.1和问题修复
- 本地导入插件升级适配v0.11.1和问题修复
- 蜜柑计划插件升级适配v0.11.1和问题修复

## 变更

- 控制台全局查询按键更改为`ctrl`+ `/`

# 0.11.0

## 新特性
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ Mono<Void> removeByTypeAndParentIdAndName(


Mono<Attachment> createDirectory(@Nullable Long parentId, @NotBlank String name);

Mono<Boolean> existsByParentIdAndName(@Nullable Long parentId, String name);

Mono<Boolean> existsByTypeAndParentIdAndName(AttachmentType type,
@Nullable Long parentId, String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package run.ikaros.api.core.attachment;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import run.ikaros.api.plugin.AllowPluginOperate;
import run.ikaros.api.store.enums.AttachmentReferenceType;

public interface AttachmentReferenceOperate extends AllowPluginOperate {
Mono<AttachmentReference> save(AttachmentReference attachmentReference);

Flux<AttachmentReference> findAllByTypeAndAttachmentId(
AttachmentReferenceType type, Long attachmentId);

Mono<Void> removeById(Long attachmentRefId);

Mono<Void> removeByTypeAndAttachmentIdAndReferenceId(
AttachmentReferenceType type, Long attachmentId, Long referenceId);

Mono<Void> matchingAttachmentsAndSubjectEpisodes(Long subjectId, Long[] attachmentIds);

Mono<Void> matchingAttachmentsAndSubjectEpisodes(Long subjectId, Long[] attachmentIds,
boolean notify);

Mono<Void> matchingAttachmentsForEpisode(Long episodeId, Long[] attachmentIds);
}
6 changes: 3 additions & 3 deletions console/src/layouts/BasicLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const asideWidth = computed(() => {
const globalSearchDialogVisible = ref(false);
// const isMac = /macintosh|mac os x/i.test(navigator.userAgent);
const isMac = /macintosh|mac os x/i.test(navigator.userAgent);
const handleGlobalSearchKeybinding = (e: KeyboardEvent) => {
const { key } = e;
if (key === '/') {
const { key, ctrlKey, metaKey } = e;
if (key === '/' && ((ctrlKey && !isMac) || metaKey)) {
globalSearchDialogVisible.value = true;
e.preventDefault();
}
Expand Down
5 changes: 5 additions & 0 deletions console/src/modules/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export const episodeGroupLabelMap = new Map([
['COMMERCIAL_MESSAGE', '广告(CM)'],
['LIVE', '直播(Live)'],
['OTHER', '其它(Other)'],
['MUSIC_DIST1', '音乐列表一(MUSIC_DIST1)'],
['MUSIC_DIST2', '音乐列表二(MUSIC_DIST2)'],
['MUSIC_DIST3', '音乐列表三(MUSIC_DIST3)'],
['MUSIC_DIST4', '音乐列表四(MUSIC_DIST4)'],
['MUSIC_DIST5', '音乐列表五(MUSIC_DIST5)'],
]);

export const subjectTypes = [
Expand Down
4 changes: 2 additions & 2 deletions console/src/modules/content/attachment/Attachments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ watch(attachmentCondition.value, () => {
const name = attachmentCondition.value.name;
const parentId = attachmentCondition.value.parentId;
const query = JSON.parse(JSON.stringify(route.query));
if (name !== route.query.searchName) {
query.searchName = base64Encode(name);
if (name !== route.query.name) {
query.name = base64Encode(encodeURI(name));
}
if (parentId !== parseInt(route.query.parentId as string)) {
query.parentId = parentId + '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const urlIsArachivePackage = (url: string | undefined): boolean => {
"
>{{ episode?.resources[0].name }}</router-link
>
<br />
<video
v-if="isVideo(episode.resources[0].url as string)"
style="width: 100%"
Expand Down
8 changes: 7 additions & 1 deletion console/src/modules/content/subject/EpisodePostDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ const episodeElFormRef = ref<FormInstance>();
placeholder="请选择一天"
/>
</el-form-item>
<el-form-item label="剧集分组" prop="group" :label-width="formLabelWidth">
<el-form-item
label="剧集分组"
prop="group"
:label-width="formLabelWidth"
width="110px"
show-overflow-tooltip
>
<el-select v-model="episode.group" clearable placeholder="请选择分组">
<el-option
v-for="item in episodeGroups"
Expand Down
2 changes: 1 addition & 1 deletion console/src/modules/content/subject/EpisodePutDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const onConfirm = async (formEl: FormInstance | undefined) => {
});
};
const formLabelWidth = '85px';
const formLabelWidth = '110px';
const episodeRuleFormRules = reactive<FormRules>({
sequence: [
Expand Down
7 changes: 6 additions & 1 deletion console/src/modules/content/subject/SubjectDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,12 @@ onMounted(fetchDatas);
<el-row>
<el-col :span="24">
<el-table :data="subject.episodes" @row-dblclick="showEpisodeDetails">
<el-table-column label="分组" prop="group" width="100px">
<el-table-column
label="分组"
prop="group"
width="110px"
show-overflow-tooltip
>
<template #default="scoped">
{{ episodeGroupLabelMap.get(scoped.row.group) }}
</template>
Expand Down
7 changes: 6 additions & 1 deletion console/src/modules/content/subject/SubjectPost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,12 @@ const onCloseWithAttachment = (attachment) => {

<el-form-item label="剧集">
<el-table :data="subject.episodes" @row-dblclick="showEpisodeDetails">
<el-table-column label="分组" prop="group" width="100px">
<el-table-column
label="分组"
prop="group"
width="110px"
show-overflow-tooltip
>
<template #default="scoped">
{{ episodeGroupLabelMap.get(scoped.row.group) }}
</template>
Expand Down
7 changes: 6 additions & 1 deletion console/src/modules/content/subject/SubjectPut.vue
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,12 @@ onMounted(() => {

<el-form-item label="剧集">
<el-table :data="subject.episodes" @row-dblclick="showEpisodeDetails">
<el-table-column label="分组" prop="group" width="100px">
<el-table-column
label="分组"
prop="group"
width="110px"
show-overflow-tooltip
>
<template #default="scoped">
{{ episodeGroupLabelMap.get(scoped.row.group) }}
</template>
Expand Down
6 changes: 3 additions & 3 deletions console/src/modules/content/subject/Subjects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ watch(findSubjectsCondition.value, () => {
// console.log('attachmentCondition.value', attachmentCondition.value);
const query = JSON.parse(JSON.stringify(route.query));
const name = findSubjectsCondition.value.name as string;
if (name !== route.query.searchName) {
query.name = base64Encode(name);
if (name !== route.query.name) {
query.name = base64Encode(encodeURI(name));
}
const nameCn = findSubjectsCondition.value.nameCn as string;
if (nameCn !== route.query.nameCn) {
query.nameCn = base64Encode(nameCn);
query.nameCn = base64Encode(encodeURI(nameCn));
}
const nsfw = findSubjectsCondition.value.nsfw as unknown as boolean;
if (nsfw !== (route.query.nsfw as unknown as boolean)) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.11.0
version=0.11.1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Mono<Void> onSubjectAdd(SubjectAddEvent event) {
? ("-" + subjectEntity.getAirTime()
.toInstant(ZoneOffset.of("+8")).toEpochMilli())
: "")
+ "-" + entity.getName()))
+ "-" + entity.getName().substring(entity.getName().lastIndexOf("-") + 1)))
.flatMap(attachmentRepository::save)
.map(AttachmentEntity::getId)
.map(attId -> AttachmentReferenceEntity.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,15 @@ public Mono<Void> removeByTypeAndParentIdAndName(AttachmentType type, @Nullable
public Mono<Attachment> createDirectory(@Nullable Long parentId, String name) {
return service.createDirectory(parentId, name);
}

@Override
public Mono<Boolean> existsByParentIdAndName(@Nullable Long parentId, String name) {
return service.existsByParentIdAndName(parentId, name);
}

@Override
public Mono<Boolean> existsByTypeAndParentIdAndName(AttachmentType type,
@Nullable Long parentId, String name) {
return service.existsByTypeAndParentIdAndName(type, parentId, name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package run.ikaros.server.core.attachment.operator;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import run.ikaros.api.core.attachment.AttachmentReference;
import run.ikaros.api.core.attachment.AttachmentReferenceOperate;
import run.ikaros.api.store.enums.AttachmentReferenceType;
import run.ikaros.server.core.attachment.service.AttachmentReferenceService;

@Slf4j
@Component
public class AttachmentReferenceOperator implements AttachmentReferenceOperate {
private final AttachmentReferenceService service;

public AttachmentReferenceOperator(AttachmentReferenceService service) {
this.service = service;
}

@Override
public Mono<AttachmentReference> save(AttachmentReference attachmentReference) {
return service.save(attachmentReference);
}

@Override
public Flux<AttachmentReference> findAllByTypeAndAttachmentId(AttachmentReferenceType type,
Long attachmentId) {
return service.findAllByTypeAndAttachmentId(type, attachmentId);
}

@Override
public Mono<Void> removeById(Long attachmentRefId) {
return service.removeById(attachmentRefId);
}

@Override
public Mono<Void> removeByTypeAndAttachmentIdAndReferenceId(AttachmentReferenceType type,
Long attachmentId,
Long referenceId) {
return service.removeByTypeAndAttachmentIdAndReferenceId(type, attachmentId, referenceId);
}

@Override
public Mono<Void> matchingAttachmentsAndSubjectEpisodes(Long subjectId, Long[] attachmentIds) {
return service.matchingAttachmentsAndSubjectEpisodes(subjectId, attachmentIds);
}

@Override
public Mono<Void> matchingAttachmentsAndSubjectEpisodes(Long subjectId, Long[] attachmentIds,
boolean notify) {
return service.matchingAttachmentsAndSubjectEpisodes(subjectId, attachmentIds, notify);
}

@Override
public Mono<Void> matchingAttachmentsForEpisode(Long episodeId, Long[] attachmentIds) {
return service.matchingAttachmentsForEpisode(episodeId, attachmentIds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ Mono<Void> receiveAndHandleFragmentUploadChunkFile(@NotBlank String unique,
Mono<Attachment> createDirectory(@Nullable Long parentId, @NotBlank String name);

Mono<List<Attachment>> findAttachmentPathDirsById(Long id);

Mono<Boolean> existsByParentIdAndName(@Nullable Long parentId, String name);

Mono<Boolean> existsByTypeAndParentIdAndName(AttachmentType type,
@Nullable Long parentId, String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ public Mono<Attachment> save(Attachment attachment) {
Assert.notNull(attachment, "'attachment' must not be null.");
attachment.setParentId(Optional.ofNullable(attachment.getParentId())
.orElse(AttachmentConst.ROOT_DIRECTORY_ID));
return repository.findById(attachment.getId())
.flatMap(attachmentEntity -> copyProperties(attachment, attachmentEntity))
Mono<AttachmentEntity> attachmentEntityMono =
Objects.isNull(attachment.getId())
? copyProperties(attachment, new AttachmentEntity())
: repository.findById(attachment.getId())
.flatMap(attachmentEntity -> copyProperties(attachment, attachmentEntity));
return attachmentEntityMono
.flatMap(this::saveEntity)
.flatMap(attachmentEntity -> copyProperties(attachmentEntity, attachment));
}
Expand Down Expand Up @@ -526,6 +530,27 @@ public Mono<List<Attachment>> findAttachmentPathDirsById(Long id) {
.collectList();
}

@Override
public Mono<Boolean> existsByParentIdAndName(@Nullable Long parentId, String name) {
Assert.hasText(name, "'name' must has text.");
if (Objects.isNull(parentId)) {
parentId = AttachmentConst.ROOT_DIRECTORY_ID;
}
return repository.existsByParentIdAndName(parentId, name);
}

@Override
public Mono<Boolean> existsByTypeAndParentIdAndName(AttachmentType type,
@Nullable Long parentId,
String name) {
Assert.notNull(type, "'type' must not null.");
Assert.hasText(name, "'name' must has text.");
if (Objects.isNull(parentId)) {
parentId = AttachmentConst.ROOT_DIRECTORY_ID;
}
return repository.existsByTypeAndParentIdAndName(type, parentId, name);
}

private Mono<List<AttachmentEntity>> findPathDirs(long id, List<AttachmentEntity> entities) {
if (ROOT_DIRECTORY_PARENT_ID.equals(id)) {
Collections.reverse(entities);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
public interface AttachmentRepository extends R2dbcRepository<AttachmentEntity, Long> {
Mono<Boolean> existsByTypeAndParentIdAndName(AttachmentType type, Long parentId, String name);

Mono<Boolean> existsByParentIdAndName(Long parentId, String name);

Mono<Void> removeByTypeAndParentIdAndName(
AttachmentType type, Long parentId, String name);

Expand Down

0 comments on commit 3a07783

Please sign in to comment.