Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: subject relation delete issue #614

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- 编辑条目界面多条绑定资源显示不全 #604
- 条目关系查询 API 404 返回格式不是标准 JSON #609
- 条目关系无法正常移除 #608

# 0.13.0

Expand Down
2 changes: 1 addition & 1 deletion console/packages/api-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ npm publish
选择当前目录下的更改进行`git add .`

```bash
git commit -am "build: gen new api-client v0.13.0+4"
git commit -am "build: gen new api-client v0.13.0+5"
```

合成版(powershell),升级 package.json 版本,并启动服务端后,在 api-client 路径下:
Expand Down
2 changes: 1 addition & 1 deletion console/packages/api-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@runikaros/api-client",
"version": "0.13.0+4",
"version": "0.13.0+5",
"description": "Project ikaros console api-client package",
"type": "module",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ export const V1alpha1SubjectRelationApiAxiosParamCreator = function (
"relationSubjects",
relationSubjects
);
const localVarPath = `/api/v1alpha1/subject/relation`;
const localVarPath =
`/api/v1alpha1/subject/relation/subjectId/{subjectId}`.replace(
`{${"subjectId"}}`,
encodeURIComponent(String(subjectId))
);
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
Expand All @@ -300,10 +304,6 @@ export const V1alpha1SubjectRelationApiAxiosParamCreator = function (
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration);

if (subjectId !== undefined) {
localVarQueryParameter["subject_id"] = subjectId;
}

if (relationType !== undefined) {
localVarQueryParameter["relation_type"] = relationType;
}
Expand Down
8 changes: 4 additions & 4 deletions console/packages/api-client/src/models/paging-wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ export interface PagingWrap {
*/
items: Array<object>;
/**
* Indicates whether current page is the first page.
* Indicates whether current page is the last page.
* @type {boolean}
* @memberof PagingWrap
*/
firstPage: boolean;
lastPage: boolean;
/**
* Indicates whether current page is the last page.
* Indicates whether current page is the first page.
* @type {boolean}
* @memberof PagingWrap
*/
lastPage: boolean;
firstPage: boolean;
/**
* Indicates whether current page has previous page.
* @type {boolean}
Expand Down
2 changes: 1 addition & 1 deletion console/src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ module:
type: Type
dialog:
delete:
title: Subject Relation Add
title: Subject Relation Delete
message:
validate-fail: >-
Submit cancellation, please check whether any necessary items are
Expand Down
2 changes: 1 addition & 1 deletion console/src/locales/zh-CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ module:
type: 类型
dialog:
delete:
title: 条目关系新增
title: 条目关系删除
message:
validate-fail: 提交取消,请检查是否有必要项缺失,必要项:【副条目】【类型】。
remove-success: 移除条目关系成功
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<script setup lang="ts">
import {
Subject,
SubjectRelation,
SubjectRelationRelationTypeEnum,
} from '@runikaros/api-client';
import { computed, ref } from 'vue';
import { ElDrawer, ElTable, ElTableColumn } from 'element-plus';
import { useSubjectStore } from '@/stores/subject';
import { useI18n } from 'vue-i18n';
import {Subject, SubjectRelation,} from '@runikaros/api-client';
import {computed, ref} from 'vue';
import {ElDrawer, ElTable, ElTableColumn} from 'element-plus';
import {useSubjectStore} from '@/stores/subject';
import {useI18n} from 'vue-i18n';

const subjectStore = useSubjectStore();
const { t } = useI18n();
Expand Down Expand Up @@ -49,8 +45,10 @@ const handleClose = () => {
const selectionSubjectMap = new Map<string, number[]>();
const selectionSubjectReactions = ref<SubjectRelation[]>([]);
const handleSelectionChange = (selection) => {
// console.log('selection', selection);
// console.debug('selection', selection);
// console.debug('props.relationSubjects', props.relationSubjects);
selectionSubjectMap.clear();
selectionSubjectReactions.value = [];
selection.forEach((sub) => {
let ids: number[] = selectionSubjectMap.get(sub.type) as number[];
if (ids) {
Expand All @@ -60,18 +58,17 @@ const handleSelectionChange = (selection) => {
ids.push(sub.id);
selectionSubjectMap.set(sub.type, ids);
}
var subjectRelation = props.relationSubjects.find(rel => {
var result = false;
rel.relation_subjects.forEach(relId => {
if (relId === sub.id) result = true;
});
return result;
}) as SubjectRelation;
// console.debug('subjectRelation', subjectRelation);
selectionSubjectReactions.value.push(subjectRelation);
});
// console.log('selectionSubjectIdSet', selectionSubjectIdSet);
selectionSubjectReactions.value = [];
selectionSubjectMap.forEach((ids, type) => {
let subRel: SubjectRelation = {
subject: props.masterSubjectId,
relation_type: type as SubjectRelationRelationTypeEnum,
relation_subjects: new Set(ids),
};
selectionSubjectReactions.value.push(subRel);
});
// console.log('selectionSubjectReactions', selectionSubjectReactions);
// console.debug('selectionSubjectReactions', selectionSubjectReactions);
};

const subjectIdMapCache = new Map<number, Subject>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import {
ElDialog,
ElForm,
ElFormItem,
ElButton,
ElInput,
ElMessage,
ElPopconfirm,
} from 'element-plus';
import { Tickets } from '@element-plus/icons-vue';
import {computed, ref} from 'vue';
import {ElButton, ElDialog, ElForm, ElFormItem, ElInput, ElMessage, ElPopconfirm,} from 'element-plus';
import {Tickets} from '@element-plus/icons-vue';
import SubjectRelactionDeleteDrawer from './SubjectRelactionDeleteDrawer.vue';
import { SubjectRelation } from '@runikaros/api-client';
import { apiClient } from '@/utils/api-client';
import { useSubjectStore } from '@/stores/subject';
import { useI18n } from 'vue-i18n';
import {SubjectRelation} from '@runikaros/api-client';
import {apiClient} from '@/utils/api-client';
import {useSubjectStore} from '@/stores/subject';
import {useI18n} from 'vue-i18n';

const subjectStore = useSubjectStore();
const { t } = useI18n();
Expand Down Expand Up @@ -57,7 +49,7 @@ const slaveSubjectTypesStr = ref('[]');
const slaveSubjectIdsStr = ref('[]');
const subjectRelations = ref<SubjectRelation[]>([]);
const onSelectionsChange = (subjectRels) => {
// console.log('receive subjectRelations', subjectRelations);
console.log('receive subjectRelations', subjectRelations);
subjectRelations.value = subjectRels;
let types = new Set<string>();
let ids = new Set<number>();
Expand All @@ -82,8 +74,6 @@ const reqRemoveRelaction = async () => {
return;
}
reqRemoveRelactionBtnLoading.value = true;
// await apiClient.subjectRelation.removeSubjectRelation({
// });
await subjectRelations.value.forEach(async (subRel) => {
const subIdSet = subRel.relation_subjects;
let ids: number[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ public RouterFunction<ServerResponse> endpoint() {
.required(true)
.description("SubjectRelation")
.implementation(SubjectRelation.class)))
.DELETE("/subject/relation", this::removeSubjectRelation,
.DELETE("/subject/relation/subjectId/{subjectId}", this::removeSubjectRelation,
builder -> builder
.tag(tag)
.operationId("RemoveSubjectRelation")
.description("Remove subject relation")
.parameter(parameterBuilder()
.required(true)
.in(ParameterIn.QUERY)
.name("subject_id")
.in(ParameterIn.PATH)
.name("subjectId")
.description("Subject id")
.implementation(Long.class))
.parameter(parameterBuilder()
Expand Down Expand Up @@ -138,14 +138,14 @@ private Mono<ServerResponse> createSubjectRelation(ServerRequest request) {


private Mono<ServerResponse> removeSubjectRelation(ServerRequest request) {
Optional<String> subjectId = request.queryParam("subject_id");
Assert.isTrue(subjectId.isPresent(), "'subject_id' must not be empty");
String subjectId = request.pathVariable("subjectId");
Assert.hasText(subjectId, "subjectId must not be empty");
Optional<String> relationType = request.queryParam("relation_type");
Assert.isTrue(relationType.isPresent(), "'relation_type' must not be empty");
Optional<String> relationSubjects = request.queryParam("relation_subjects");
Assert.isTrue(relationSubjects.isPresent(), "'relation_subjects' must not be empty");
SubjectRelation subjectRelation = SubjectRelation.builder()
.subject(Long.valueOf(subjectId.get()))
.subject(Long.valueOf(subjectId))
.relationType(
StringUtils.isNumeric(relationType.get())
? SubjectRelationType.codeOf(Integer.valueOf(relationType.get()))
Expand Down
Loading