Skip to content

Commit f59c5a3

Browse files
authored
fix: export base table with dbtablename (#2324)
* fix: export base table with dbtablename relative issueid: T1388 * fix: template sql query has no permission
1 parent c1ac65c commit f59c5a3

5 files changed

Lines changed: 10 additions & 4 deletions

File tree

apps/nestjs-backend/src/features/auth/permission.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ export class PermissionService {
319319
const tempAuthBaseId = this.cls.get('tempAuthBaseId');
320320
if (tempAuthBaseId === baseId) {
321321
const template = await this.templateModel.getTemplateRawByBaseId(baseId);
322-
return getPermissions(template ? 'viewer' : 'owner');
322+
return template ? TemplatePermissions : getPermissions('owner');
323323
}
324324
const role = await this.getRoleByBaseId(baseId);
325325
const spaceRole = await this.getRoleBySpaceId(

apps/nestjs-backend/src/features/base/base-export.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,15 @@ export class BaseExportService {
409409
const { name: baseName, icon: baseIcon, id: baseId } = baseRaw;
410410
const tables = [] as IBaseJson['tables'];
411411
for (const table of tableRaws) {
412-
const { name, description, order, id, icon } = table;
412+
const { name, description, order, id, icon, dbTableName } = table;
413+
const realDbTableName = dbTableName?.split('.')?.pop();
413414
const tableObject = {
414415
id,
415416
name,
416417
order,
417418
description,
418419
icon,
420+
dbTableName: realDbTableName,
419421
} as IBaseJson['tables'][number];
420422
const currentTableFields = fieldRaws.filter(({ tableId }) => tableId === id);
421423
tableObject.fields = this.generateFieldConfig(

apps/nestjs-backend/src/features/base/base-import.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,12 @@ export class BaseImportService {
343343
const tableIdMap: Record<string, string> = {};
344344

345345
for (const table of tables) {
346-
const { name, icon, description, id: tableId } = table;
346+
const { name, icon, description, id: tableId, dbTableName } = table;
347347
const newTableVo = await this.tableService.createTable(baseId, {
348348
name,
349349
icon,
350350
description,
351+
dbTableName,
351352
});
352353
tableIdMap[tableId] = newTableVo.id;
353354
this.logger.log(`base-duplicate-service: duplicate table item successfully`);

packages/core/src/auth/role/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const TemplateRolePermission: Record<Action, boolean> = {
2626
'base|table_export': false,
2727
'base|authority_matrix_config': false,
2828
'base|db_connection': false,
29-
'base|query_data': false,
29+
'base|query_data': true,
3030
'table|create': false,
3131
'table|delete': false,
3232
'table|update': false,

packages/openapi/src/base/export.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ export const tableJsonSchema = z.object({
7777
order: z.number(),
7878
fields: fieldJsonSchema.array(),
7979
views: viewJsonSchema.array(),
80+
dbTableName: z.string().meta({
81+
description: 'The table name in the physical postgres database.',
82+
}),
8083
});
8184

8285
export const pluginInstallJsonSchema = z.object({

0 commit comments

Comments
 (0)