Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-general-business into dev
This commit is contained in:
commit
d2b5d97db2
|
|
@ -49,5 +49,6 @@ export declare abstract class GeneralRuntimeContext<ED extends EntityDict> exten
|
||||||
scene: any;
|
scene: any;
|
||||||
token: any;
|
token: any;
|
||||||
};
|
};
|
||||||
|
isRoot(): Promise<boolean>;
|
||||||
}
|
}
|
||||||
export {};
|
export {};
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ var tslib_1 = require("tslib");
|
||||||
var UniversalContext_1 = require("oak-domain/lib/store/UniversalContext");
|
var UniversalContext_1 = require("oak-domain/lib/store/UniversalContext");
|
||||||
var concurrent_1 = require("oak-domain/lib/utils/concurrent");
|
var concurrent_1 = require("oak-domain/lib/utils/concurrent");
|
||||||
var assert_1 = require("oak-domain/lib/utils/assert");
|
var assert_1 = require("oak-domain/lib/utils/assert");
|
||||||
|
var constants_1 = require("./constants");
|
||||||
var GeneralRuntimeContext = /** @class */ (function (_super) {
|
var GeneralRuntimeContext = /** @class */ (function (_super) {
|
||||||
tslib_1.__extends(GeneralRuntimeContext, _super);
|
tslib_1.__extends(GeneralRuntimeContext, _super);
|
||||||
function GeneralRuntimeContext(store, applicationId) {
|
function GeneralRuntimeContext(store, applicationId) {
|
||||||
|
|
@ -100,7 +101,7 @@ var GeneralRuntimeContext = /** @class */ (function (_super) {
|
||||||
filter: {
|
filter: {
|
||||||
id: tokenValue,
|
id: tokenValue,
|
||||||
ableState: 'enabled',
|
ableState: 'enabled',
|
||||||
}
|
},
|
||||||
}, this, {})];
|
}, this, {})];
|
||||||
case 1:
|
case 1:
|
||||||
_a = tslib_1.__read.apply(void 0, [(_b.sent()).result, 1]), token = _a[0];
|
_a = tslib_1.__read.apply(void 0, [(_b.sent()).result, 1]), token = _a[0];
|
||||||
|
|
@ -156,6 +157,47 @@ var GeneralRuntimeContext = /** @class */ (function (_super) {
|
||||||
token: token,
|
token: token,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
GeneralRuntimeContext.prototype.isRoot = function () {
|
||||||
|
var _a, _b, _c;
|
||||||
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||||
|
var tokenValue, _d, token;
|
||||||
|
return tslib_1.__generator(this, function (_e) {
|
||||||
|
switch (_e.label) {
|
||||||
|
case 0:
|
||||||
|
tokenValue = this.token;
|
||||||
|
if (!tokenValue) {
|
||||||
|
return [2 /*return*/, false];
|
||||||
|
}
|
||||||
|
return [4 /*yield*/, this.rowStore.select('token', {
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
ableState: 1,
|
||||||
|
player: {
|
||||||
|
id: 1,
|
||||||
|
userRole$user: {
|
||||||
|
$entity: 'userRole',
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
roleId: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: tokenValue,
|
||||||
|
},
|
||||||
|
}, this, {})];
|
||||||
|
case 1:
|
||||||
|
_d = tslib_1.__read.apply(void 0, [(_e.sent()).result, 1]), token = _d[0];
|
||||||
|
return [2 /*return*/, ((_a = token === null || token === void 0 ? void 0 : token.player) === null || _a === void 0 ? void 0 : _a.userRole$user).length > 0
|
||||||
|
? ((_c = ((_b = token === null || token === void 0 ? void 0 : token.player) === null || _b === void 0 ? void 0 : _b.userRole$user)[0]) === null || _c === void 0 ? void 0 : _c.roleId) === constants_1.ROOT_ROLE_ID
|
||||||
|
: false];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
return GeneralRuntimeContext;
|
return GeneralRuntimeContext;
|
||||||
}(UniversalContext_1.UniversalContext));
|
}(UniversalContext_1.UniversalContext));
|
||||||
exports.GeneralRuntimeContext = GeneralRuntimeContext;
|
exports.GeneralRuntimeContext = GeneralRuntimeContext;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(): JSX.Element;
|
export default function render(): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(): JSX.Element;
|
export default function render(): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
/// <reference types="react" />
|
||||||
import '@wangeditor/editor/dist/css/style.css';
|
import '@wangeditor/editor/dist/css/style.css';
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(): JSX.Element;
|
export default function render(): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(): JSX.Element;
|
export default function render(): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(): JSX.Element;
|
export default function render(): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(): JSX.Element;
|
export default function render(): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
/// <reference types="react" />
|
||||||
export default function render(this: any): JSX.Element;
|
export default function render(this: any): JSX.Element;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { RowStore } from 'oak-domain/lib/types';
|
||||||
|
|
||||||
import { RWLock } from 'oak-domain/lib/utils/concurrent';
|
import { RWLock } from 'oak-domain/lib/utils/concurrent';
|
||||||
import { assert } from 'oak-domain/lib/utils/assert';
|
import { assert } from 'oak-domain/lib/utils/assert';
|
||||||
|
import { ROOT_ROLE_ID } from './constants';
|
||||||
|
|
||||||
type AppType = SelectRowShape<EntityDict['application']['Schema'], {
|
type AppType = SelectRowShape<EntityDict['application']['Schema'], {
|
||||||
id: 1,
|
id: 1,
|
||||||
|
|
@ -20,13 +21,18 @@ type AppType = SelectRowShape<EntityDict['application']['Schema'], {
|
||||||
},
|
},
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export abstract class GeneralRuntimeContext<ED extends EntityDict> extends UniversalContext<ED> {
|
export abstract class GeneralRuntimeContext<
|
||||||
|
ED extends EntityDict
|
||||||
|
> extends UniversalContext<ED> {
|
||||||
private applicationId?: string;
|
private applicationId?: string;
|
||||||
private application?: AppType;
|
private application?: AppType;
|
||||||
private token?: string;
|
private token?: string;
|
||||||
private rwLockApplication: RWLock;
|
private rwLockApplication: RWLock;
|
||||||
|
|
||||||
constructor(store: RowStore<ED, GeneralRuntimeContext<ED>>, applicationId?: string) {
|
constructor(
|
||||||
|
store: RowStore<ED, GeneralRuntimeContext<ED>>,
|
||||||
|
applicationId?: string
|
||||||
|
) {
|
||||||
super(store);
|
super(store);
|
||||||
this.rwLockApplication = new RWLock();
|
this.rwLockApplication = new RWLock();
|
||||||
this.applicationId = applicationId;
|
this.applicationId = applicationId;
|
||||||
|
|
@ -53,25 +59,31 @@ export abstract class GeneralRuntimeContext<ED extends EntityDict> extends Unive
|
||||||
await this.rwLockApplication.acquire('X');
|
await this.rwLockApplication.acquire('X');
|
||||||
if (this.application) {
|
if (this.application) {
|
||||||
result = this.application;
|
result = this.application;
|
||||||
}
|
} else if (this.applicationId) {
|
||||||
else if (this.applicationId) {
|
const {
|
||||||
const { result: [application]} = await this.rowStore.select('application', {
|
result: [application],
|
||||||
data: {
|
} = await this.rowStore.select(
|
||||||
id: 1,
|
'application',
|
||||||
name: 1,
|
{
|
||||||
config: 1,
|
data: {
|
||||||
type: 1,
|
|
||||||
systemId: 1,
|
|
||||||
system: {
|
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 1,
|
name: 1,
|
||||||
config: 1,
|
config: 1,
|
||||||
|
type: 1,
|
||||||
|
systemId: 1,
|
||||||
|
system: {
|
||||||
|
id: 1,
|
||||||
|
name: 1,
|
||||||
|
config: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: this.applicationId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
filter: {
|
this,
|
||||||
id: this.applicationId,
|
{}
|
||||||
},
|
);
|
||||||
}, this, {});
|
|
||||||
result = application as AppType;
|
result = application as AppType;
|
||||||
this.application = application as AppType;
|
this.application = application as AppType;
|
||||||
}
|
}
|
||||||
|
|
@ -89,17 +101,27 @@ export abstract class GeneralRuntimeContext<ED extends EntityDict> extends Unive
|
||||||
async getToken() {
|
async getToken() {
|
||||||
const tokenValue = this.token;
|
const tokenValue = this.token;
|
||||||
if (tokenValue) {
|
if (tokenValue) {
|
||||||
const { result: [token] } = await this.rowStore.select('token', {
|
const {
|
||||||
data: {
|
result: [token],
|
||||||
id: 1,
|
} = (await this.rowStore.select(
|
||||||
userId: 1,
|
'token',
|
||||||
playerId: 1,
|
{
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
playerId: 1,
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: tokenValue,
|
||||||
|
ableState: 'enabled',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
filter: {
|
this,
|
||||||
id: tokenValue,
|
{}
|
||||||
ableState: 'enabled',
|
)) as SelectionResult<
|
||||||
}
|
ED['token']['Schema'],
|
||||||
}, this, {}) as SelectionResult<ED['token']['Schema'], { id: 1, userId: 1, playerId: 1 }>;
|
{ id: 1; userId: 1; playerId: 1 }
|
||||||
|
>;
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
@ -133,11 +155,7 @@ export abstract class GeneralRuntimeContext<ED extends EntityDict> extends Unive
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static fromString(strCxt: string) {
|
protected static fromString(strCxt: string) {
|
||||||
const {
|
const { applicationId, scene, token } = JSON.parse(strCxt);
|
||||||
applicationId,
|
|
||||||
scene,
|
|
||||||
token,
|
|
||||||
} = JSON.parse(strCxt);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
applicationId,
|
applicationId,
|
||||||
|
|
@ -145,4 +163,60 @@ export abstract class GeneralRuntimeContext<ED extends EntityDict> extends Unive
|
||||||
token,
|
token,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async isRoot(): Promise<boolean> {
|
||||||
|
const tokenValue = this.token;
|
||||||
|
if (!tokenValue) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const {
|
||||||
|
result: [token],
|
||||||
|
} = (await this.rowStore.select(
|
||||||
|
'token',
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
ableState: 1,
|
||||||
|
player: {
|
||||||
|
id: 1,
|
||||||
|
userRole$user: {
|
||||||
|
$entity: 'userRole',
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
roleId: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id: tokenValue,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
this,
|
||||||
|
{}
|
||||||
|
)) as SelectionResult<
|
||||||
|
ED['token']['Schema'],
|
||||||
|
{
|
||||||
|
id: 1;
|
||||||
|
userId: 1;
|
||||||
|
ableState: 1;
|
||||||
|
player: {
|
||||||
|
id: 1;
|
||||||
|
userRole$user: {
|
||||||
|
$entity: 'userRole';
|
||||||
|
data: {
|
||||||
|
id: 1;
|
||||||
|
userId: 1;
|
||||||
|
roleId: 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
return (token?.player?.userRole$user as any).length > 0
|
||||||
|
? (token?.player?.userRole$user as any)[0]?.roleId === ROOT_ROLE_ID
|
||||||
|
: false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Loading…
Reference in New Issue