From 17689ba1cf34c4723ec3baf20c74fe6662311b36 Mon Sep 17 00:00:00 2001 From: wangwenchen <920960949@qq.com> Date: Wed, 7 Jun 2023 19:11:52 +0800 Subject: [PATCH] platfrom entityId --- lib/aspects/application.d.ts | 2 +- lib/context/BackendRuntimeContext.js | 42 ++-- lib/general-app-domain/ExtraFile/Schema.d.ts | 6 +- lib/general-app-domain/ExtraFile/Storage.js | 6 +- src/context/BackendRuntimeContext.ts | 230 ++++++++++--------- 5 files changed, 142 insertions(+), 144 deletions(-) diff --git a/lib/aspects/application.d.ts b/lib/aspects/application.d.ts index 19dcebdae..daeaf9fc5 100644 --- a/lib/aspects/application.d.ts +++ b/lib/aspects/application.d.ts @@ -10,7 +10,7 @@ export declare function signatureJsSDK 0 && userRole$user.find(function (ele) { return ele.role.name === 'root'; }); + this.amIRoot = + userRole$user.length > 0 && + userRole$user.find(function (ele) { return ele.role.name === 'root'; }); userRole$player = player.userRole$user; - this.amIReallyRoot = userRole$player.length > 0 && userRole$player.find(function (ele) { return ele.role.name === 'root'; }); + this.amIReallyRoot = + userRole$player.length > 0 && + userRole$player.find(function (ele) { return ele.role.name === 'root'; }); this.token = token; return [2 /*return*/]; } @@ -172,28 +178,7 @@ var BackendRuntimeContext = /** @class */ (function (_super) { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.select('application', { - data: { - id: 1, - name: 1, - config: 1, - type: 1, - systemId: 1, - style: 1, - system: { - id: 1, - name: 1, - config: 1, - platformId: 1, - style: 1, - folder: 1, - super: 1, - platform: { - id: 1, - config: 1, - style: 1, - }, - }, - }, + data: projection_1.applicationProjection, filter: { id: appId, }, @@ -289,7 +274,8 @@ var BackendRuntimeContext = /** @class */ (function (_super) { } if (this.token) { var userState = this.token.user.userState; - if (['disabled', 'merged'].includes(userState) && !this.isReallyRoot()) { + if (['disabled', 'merged'].includes(userState) && + !this.isReallyRoot()) { throw new Exception_1.OakUserDisabledException(); } } diff --git a/lib/general-app-domain/ExtraFile/Schema.d.ts b/lib/general-app-domain/ExtraFile/Schema.d.ts index a79eb28db..a64dc7478 100644 --- a/lib/general-app-domain/ExtraFile/Schema.d.ts +++ b/lib/general-app-domain/ExtraFile/Schema.d.ts @@ -1,4 +1,4 @@ -import { String, Int, Text } from "oak-domain/lib/types/DataType"; +import { String, Int, Float, Text } from "oak-domain/lib/types/DataType"; import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; import { OneOf } from "oak-domain/lib/types/Polyfill"; import * as SubQuery from "../_SubQuery"; @@ -20,7 +20,7 @@ export declare type OpSchema = EntityShape & { extra1?: Text | null; extension: String<16>; size?: Int<4> | null; - sort?: Int<4> | null; + sort?: Float<4, 2> | null; fileType?: String<128> | null; }; export declare type OpAttr = keyof OpSchema; @@ -38,7 +38,7 @@ export declare type Schema = EntityShape & { extra1?: Text | null; extension: String<16>; size?: Int<4> | null; - sort?: Int<4> | null; + sort?: Float<4, 2> | null; fileType?: String<128> | null; article?: Article.Schema; user?: User.Schema; diff --git a/lib/general-app-domain/ExtraFile/Storage.js b/lib/general-app-domain/ExtraFile/Storage.js index 65cc13c44..50d1d91ba 100644 --- a/lib/general-app-domain/ExtraFile/Storage.js +++ b/lib/general-app-domain/ExtraFile/Storage.js @@ -83,10 +83,10 @@ exports.desc = { } }, sort: { - type: "int", + type: "decimal", params: { - width: 4, - signed: true + precision: 4, + scale: 2 } }, fileType: { diff --git a/src/context/BackendRuntimeContext.ts b/src/context/BackendRuntimeContext.ts index e99d0bc31..63b8bc152 100644 --- a/src/context/BackendRuntimeContext.ts +++ b/src/context/BackendRuntimeContext.ts @@ -2,19 +2,27 @@ import { RuntimeContext } from './RuntimeContext'; import { EntityDict } from '../general-app-domain'; import { SerializedData } from './FrontendRuntimeContext'; import assert from 'assert'; -import { OakTokenExpiredException, OakUserDisabledException } from '../types/Exception'; -import { OakException, OakUnloggedInException } from 'oak-domain/lib/types/Exception'; +import { + OakTokenExpiredException, + OakUserDisabledException, +} from '../types/Exception'; +import { + OakException, + OakUnloggedInException, +} from 'oak-domain/lib/types/Exception'; import { ROOT_TOKEN_ID, ROOT_USER_ID } from '../constants'; import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore'; import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; import { SelectOpResult } from 'oak-domain/lib/types'; -import { - getMpUnlimitWxaCode, -} from '../aspects/wechatQrCode'; +import { applicationProjection } from '../types/projection'; +import { getMpUnlimitWxaCode } from '../aspects/wechatQrCode'; /** * general数据结构要求的后台上下文 */ -export class BackendRuntimeContext extends AsyncContext implements RuntimeContext { +export class BackendRuntimeContext + extends AsyncContext + implements RuntimeContext +{ protected application?: Partial; protected token?: Partial; protected amIRoot?: boolean; @@ -32,23 +40,28 @@ export class BackendRuntimeContext extends AsyncContext; - if (wechatQrCodeData.hasOwnProperty('buffer') && wechatQrCodeData.type === 'wechatMpWxaCode') { - const buffer = await getMpUnlimitWxaCode>( - id, - this, - ); - Object.assign( - wechatQrCodeData, { + const wechatQrCodeData = wechatQrCodeListObj[ + id + ] as Partial< + EntityDict['wechatQrCode']['OpSchema'] + >; + if ( + wechatQrCodeData.hasOwnProperty('buffer') && + wechatQrCodeData.type === 'wechatMpWxaCode' + ) { + const buffer = await getMpUnlimitWxaCode< + ED, + keyof ED, + BackendRuntimeContext + >(id, this); + Object.assign(wechatQrCodeData, { buffer, - } - ) + }); } - } - - } - else if (['application', 'system', 'platform'].includes(entity)) { + } else if ( + ['application', 'system', 'platform'].includes(entity) + ) { // todo 删除掉config中的敏感返回信息 } } @@ -57,73 +70,83 @@ export class BackendRuntimeContext extends AsyncContext 0 && (userRole$user as any).find( - (ele: any) => ele.role.name === 'root' - ); + this.amIRoot = + (userRole$user as any).length > 0 && + (userRole$user as any).find((ele: any) => ele.role.name === 'root'); const { userRole$user: userRole$player } = player!; - this.amIReallyRoot = (userRole$player as any).length > 0 && (userRole$player as any).find( - (ele: any) => ele.role.name === 'root' - ); + this.amIReallyRoot = + (userRole$player as any).length > 0 && + (userRole$player as any).find( + (ele: any) => ele.role.name === 'root' + ); this.token = token; } @@ -131,28 +154,7 @@ export class BackendRuntimeContext extends AsyncContext extends AsyncContext 0, `构建BackendRuntimeContext对应appId「${appId}」找不到application`); + assert( + result.length > 0, + `构建BackendRuntimeContext对应appId「${appId}」找不到application` + ); this.application = result[0]; } @@ -182,13 +187,11 @@ export class BackendRuntimeContext extends AsyncContext extends AsyncContext extends AsyncContext extends AsyncContext