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;
|
||||
token: any;
|
||||
};
|
||||
isRoot(): Promise<boolean>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ var tslib_1 = require("tslib");
|
|||
var UniversalContext_1 = require("oak-domain/lib/store/UniversalContext");
|
||||
var concurrent_1 = require("oak-domain/lib/utils/concurrent");
|
||||
var assert_1 = require("oak-domain/lib/utils/assert");
|
||||
var constants_1 = require("./constants");
|
||||
var GeneralRuntimeContext = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(GeneralRuntimeContext, _super);
|
||||
function GeneralRuntimeContext(store, applicationId) {
|
||||
|
|
@ -100,7 +101,7 @@ var GeneralRuntimeContext = /** @class */ (function (_super) {
|
|||
filter: {
|
||||
id: tokenValue,
|
||||
ableState: 'enabled',
|
||||
}
|
||||
},
|
||||
}, this, {})];
|
||||
case 1:
|
||||
_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,
|
||||
};
|
||||
};
|
||||
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;
|
||||
}(UniversalContext_1.UniversalContext));
|
||||
exports.GeneralRuntimeContext = GeneralRuntimeContext;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
/// <reference types="react" />
|
||||
import '@wangeditor/editor/dist/css/style.css';
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
export default function render(this: any): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
/// <reference types="react" />
|
||||
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 { assert } from 'oak-domain/lib/utils/assert';
|
||||
import { ROOT_ROLE_ID } from './constants';
|
||||
|
||||
type AppType = SelectRowShape<EntityDict['application']['Schema'], {
|
||||
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 application?: AppType;
|
||||
private token?: string;
|
||||
private rwLockApplication: RWLock;
|
||||
|
||||
constructor(store: RowStore<ED, GeneralRuntimeContext<ED>>, applicationId?: string) {
|
||||
constructor(
|
||||
store: RowStore<ED, GeneralRuntimeContext<ED>>,
|
||||
applicationId?: string
|
||||
) {
|
||||
super(store);
|
||||
this.rwLockApplication = new RWLock();
|
||||
this.applicationId = applicationId;
|
||||
|
|
@ -53,9 +59,12 @@ export abstract class GeneralRuntimeContext<ED extends EntityDict> extends Unive
|
|||
await this.rwLockApplication.acquire('X');
|
||||
if (this.application) {
|
||||
result = this.application;
|
||||
}
|
||||
else if (this.applicationId) {
|
||||
const { result: [application]} = await this.rowStore.select('application', {
|
||||
} else if (this.applicationId) {
|
||||
const {
|
||||
result: [application],
|
||||
} = await this.rowStore.select(
|
||||
'application',
|
||||
{
|
||||
data: {
|
||||
id: 1,
|
||||
name: 1,
|
||||
|
|
@ -71,7 +80,10 @@ export abstract class GeneralRuntimeContext<ED extends EntityDict> extends Unive
|
|||
filter: {
|
||||
id: this.applicationId,
|
||||
},
|
||||
}, this, {});
|
||||
},
|
||||
this,
|
||||
{}
|
||||
);
|
||||
result = application as AppType;
|
||||
this.application = application as AppType;
|
||||
}
|
||||
|
|
@ -89,7 +101,11 @@ export abstract class GeneralRuntimeContext<ED extends EntityDict> extends Unive
|
|||
async getToken() {
|
||||
const tokenValue = this.token;
|
||||
if (tokenValue) {
|
||||
const { result: [token] } = await this.rowStore.select('token', {
|
||||
const {
|
||||
result: [token],
|
||||
} = (await this.rowStore.select(
|
||||
'token',
|
||||
{
|
||||
data: {
|
||||
id: 1,
|
||||
userId: 1,
|
||||
|
|
@ -98,8 +114,14 @@ export abstract class GeneralRuntimeContext<ED extends EntityDict> extends Unive
|
|||
filter: {
|
||||
id: tokenValue,
|
||||
ableState: 'enabled',
|
||||
}
|
||||
}, this, {}) as SelectionResult<ED['token']['Schema'], { id: 1, userId: 1, playerId: 1 }>;
|
||||
},
|
||||
},
|
||||
this,
|
||||
{}
|
||||
)) as SelectionResult<
|
||||
ED['token']['Schema'],
|
||||
{ id: 1; userId: 1; playerId: 1 }
|
||||
>;
|
||||
|
||||
return token;
|
||||
}
|
||||
|
|
@ -133,11 +155,7 @@ export abstract class GeneralRuntimeContext<ED extends EntityDict> extends Unive
|
|||
}
|
||||
|
||||
protected static fromString(strCxt: string) {
|
||||
const {
|
||||
applicationId,
|
||||
scene,
|
||||
token,
|
||||
} = JSON.parse(strCxt);
|
||||
const { applicationId, scene, token } = JSON.parse(strCxt);
|
||||
|
||||
return {
|
||||
applicationId,
|
||||
|
|
@ -145,4 +163,60 @@ export abstract class GeneralRuntimeContext<ED extends EntityDict> extends Unive
|
|||
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