mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix: firstOrCreate
This commit is contained in:
parent
8741c26a86
commit
43767a9212
@ -11,12 +11,12 @@ import { Model, Transaction } from '@nocobase/database';
|
|||||||
import PluginLocalizationServer from '@nocobase/plugin-localization';
|
import PluginLocalizationServer from '@nocobase/plugin-localization';
|
||||||
import { Plugin } from '@nocobase/server';
|
import { Plugin } from '@nocobase/server';
|
||||||
import { tval } from '@nocobase/utils';
|
import { tval } from '@nocobase/utils';
|
||||||
|
import _ from 'lodash';
|
||||||
import * as process from 'node:process';
|
import * as process from 'node:process';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { getAntdLocale } from './antd';
|
import { getAntdLocale } from './antd';
|
||||||
import { getCronLocale } from './cron';
|
import { getCronLocale } from './cron';
|
||||||
import { getCronstrueLocale } from './cronstrue';
|
import { getCronstrueLocale } from './cronstrue';
|
||||||
import _ from 'lodash';
|
|
||||||
|
|
||||||
async function getLang(ctx) {
|
async function getLang(ctx) {
|
||||||
const SystemSetting = ctx.db.getRepository('systemSettings');
|
const SystemSetting = ctx.db.getRepository('systemSettings');
|
||||||
@ -221,7 +221,14 @@ export class PluginClientServer extends Plugin {
|
|||||||
const createModels = tabs
|
const createModels = tabs
|
||||||
.map((x) => !modelsByRouteId[x.get('id')] && { desktopRouteId: x.get('id'), roleName })
|
.map((x) => !modelsByRouteId[x.get('id')] && { desktopRouteId: x.get('id'), roleName })
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
return await repository.create({ values: createModels, transaction });
|
for (const values of createModels) {
|
||||||
|
await repository.firstOrCreate({
|
||||||
|
values,
|
||||||
|
filterKeys: ['desktopRouteId', 'roleName'],
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action === 'remove') {
|
if (action === 'remove') {
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Model, Transaction } from '@nocobase/database';
|
import { Model, Transaction } from '@nocobase/database';
|
||||||
import { Plugin } from '@nocobase/server';
|
|
||||||
import PluginLocalizationServer from '@nocobase/plugin-localization';
|
import PluginLocalizationServer from '@nocobase/plugin-localization';
|
||||||
|
import { Plugin } from '@nocobase/server';
|
||||||
import { tval } from '@nocobase/utils';
|
import { tval } from '@nocobase/utils';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
@ -94,7 +94,14 @@ export class PluginMobileServer extends Plugin {
|
|||||||
const createModels = tabs
|
const createModels = tabs
|
||||||
.map((x) => !modelsByRouteId[x.get('id')] && { mobileRouteId: x.get('id'), roleName })
|
.map((x) => !modelsByRouteId[x.get('id')] && { mobileRouteId: x.get('id'), roleName })
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
return await repository.create({ values: createModels, transaction });
|
for (const values of createModels) {
|
||||||
|
await repository.firstOrCreate({
|
||||||
|
values,
|
||||||
|
filterKeys: ['mobileRouteId', 'roleName'],
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action === 'remove') {
|
if (action === 'remove') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user