@ruiapp/rapid-core 0.1.69 → 0.1.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8 -6
- package/dist/plugins/setting/SettingService.d.ts +4 -0
- package/dist/plugins/setting/actionHandlers/setSystemSettingValues.d.ts +7 -0
- package/dist/plugins/setting/routes/index.d.ts +1 -1
- package/dist/plugins/setting/routes/setSystemSettingValues.d.ts +12 -0
- package/package.json +1 -1
- package/src/plugins/setting/SettingService.ts +13 -6
- package/src/plugins/setting/actionHandlers/setSystemSettingValues.ts +30 -0
- package/src/plugins/setting/routes/setSystemSettingValues.ts +15 -0
package/dist/index.js
CHANGED
|
@@ -6244,12 +6244,14 @@ class SettingService {
|
|
|
6244
6244
|
],
|
|
6245
6245
|
});
|
|
6246
6246
|
if (settingItem) {
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6247
|
+
if (settingItem.value !== value) {
|
|
6248
|
+
await this.#systemSettingItemManager.updateEntityById({
|
|
6249
|
+
id: settingItem.id,
|
|
6250
|
+
entityToSave: {
|
|
6251
|
+
value,
|
|
6252
|
+
},
|
|
6253
|
+
});
|
|
6254
|
+
}
|
|
6253
6255
|
}
|
|
6254
6256
|
else {
|
|
6255
6257
|
await this.#systemSettingItemManager.createEntity({
|
|
@@ -3,6 +3,10 @@ import { SystemSettingItem, UserSettingItem } from "./SettingPluginTypes";
|
|
|
3
3
|
export interface GetSystemSettingValuesInput {
|
|
4
4
|
groupCode: string;
|
|
5
5
|
}
|
|
6
|
+
export interface SetSystemSettingValuesInput {
|
|
7
|
+
groupCode: string;
|
|
8
|
+
values: Record<string, any>;
|
|
9
|
+
}
|
|
6
10
|
export interface GetUserSettingValuesInput {
|
|
7
11
|
groupCode: string;
|
|
8
12
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ActionHandlerContext } from "../../../core/actionHandler";
|
|
2
|
+
import { RapidPlugin } from "../../../core/server";
|
|
3
|
+
export interface SetSystemSettingValuesOptions {
|
|
4
|
+
groupCode: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const code = "setSystemSettingValues";
|
|
7
|
+
export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: SetSystemSettingValuesOptions): Promise<void>;
|
package/package.json
CHANGED
|
@@ -6,6 +6,11 @@ export interface GetSystemSettingValuesInput {
|
|
|
6
6
|
groupCode: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
export interface SetSystemSettingValuesInput {
|
|
10
|
+
groupCode: string;
|
|
11
|
+
values: Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
export interface GetUserSettingValuesInput {
|
|
10
15
|
groupCode: string;
|
|
11
16
|
}
|
|
@@ -80,12 +85,14 @@ export default class SettingService {
|
|
|
80
85
|
});
|
|
81
86
|
|
|
82
87
|
if (settingItem) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
if (settingItem.value !== value) {
|
|
89
|
+
await this.#systemSettingItemManager.updateEntityById({
|
|
90
|
+
id: settingItem.id,
|
|
91
|
+
entityToSave: {
|
|
92
|
+
value,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
89
96
|
} else {
|
|
90
97
|
await this.#systemSettingItemManager.createEntity({
|
|
91
98
|
entity: {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
|
+
import { RapidPlugin } from "~/core/server";
|
|
3
|
+
import SettingService, { SetSystemSettingValuesInput } from "../SettingService";
|
|
4
|
+
|
|
5
|
+
export interface SetSystemSettingValuesOptions {
|
|
6
|
+
groupCode: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const code = "setSystemSettingValues";
|
|
10
|
+
|
|
11
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: SetSystemSettingValuesOptions) {
|
|
12
|
+
const { server, routerContext } = ctx;
|
|
13
|
+
const { response } = routerContext;
|
|
14
|
+
|
|
15
|
+
const input: SetSystemSettingValuesInput = ctx.input;
|
|
16
|
+
|
|
17
|
+
if (options?.groupCode) {
|
|
18
|
+
input.groupCode = options.groupCode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!input.groupCode) {
|
|
22
|
+
throw new Error(`Group code is required when setting system setting values.`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const settingService = server.getService<SettingService>("settingService");
|
|
26
|
+
|
|
27
|
+
await settingService.setSystemSettingValues(input.groupCode, input.values);
|
|
28
|
+
|
|
29
|
+
ctx.output = {};
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RpdRoute } from "~/types";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
namespace: "svc",
|
|
5
|
+
name: "svc.setSystemSettingValues",
|
|
6
|
+
code: "svc.setSystemSettingValues",
|
|
7
|
+
type: "RESTful",
|
|
8
|
+
method: "PATCH",
|
|
9
|
+
endpoint: "/svc/systemSettingValues",
|
|
10
|
+
actions: [
|
|
11
|
+
{
|
|
12
|
+
code: "setSystemSettingValues",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
} satisfies RpdRoute;
|