getProjection函数 cache.getCurrentUserId传入true

This commit is contained in:
Wang Kejun 2023-03-15 14:04:58 +08:00
parent 64aec594c8
commit a116d34acb
5 changed files with 7 additions and 7 deletions

View File

@ -12,7 +12,7 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict, Cxt extends A
private contextBuilder?;
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>, contextBuilder: () => FrontCxt, store: CacheStore<ED, FrontCxt>);
getSchema(): import("oak-domain/lib/types").StorageSchema<ED>;
getCurrentUserId(): string | undefined;
getCurrentUserId(allowUnloggedIn?: boolean): string | undefined;
exec<K extends keyof AD>(name: K, params: Parameters<AD[K]>[0], callback?: (result: Awaited<ReturnType<AD[K]>>, opRecords?: OpRecord<ED>[]) => void): Promise<{
result: Awaited<ReturnType<AD[K]>>;
message: string | null | undefined;

View File

@ -32,9 +32,9 @@ var Cache = /** @class */ (function (_super) {
Cache.prototype.getSchema = function () {
return this.cacheStore.getSchema();
};
Cache.prototype.getCurrentUserId = function () {
Cache.prototype.getCurrentUserId = function (allowUnloggedIn) {
var context = this.contextBuilder && this.contextBuilder();
return context === null || context === void 0 ? void 0 : context.getCurrentUserId();
return context === null || context === void 0 ? void 0 : context.getCurrentUserId(allowUnloggedIn);
};
Cache.prototype.exec = function (name, params, callback) {
return tslib_1.__awaiter(this, void 0, void 0, function () {

View File

@ -227,7 +227,7 @@ var Node = /** @class */ (function (_super) {
var e_1, _a, e_2, _b;
var projection = typeof this.projection === 'function' ? this.projection() : (this.projection && (0, lodash_1.cloneDeep)(this.projection));
// 根据actions和cascadeActions的定义将对应的projection构建出来
var userId = this.cache.getCurrentUserId();
var userId = this.cache.getCurrentUserId(true);
if (userId && projection) {
if (this.actions) {
var actions = typeof this.actions === 'function' ? this.actions() : this.actions;

View File

@ -53,9 +53,9 @@ export class Cache<
return this.cacheStore.getSchema();
}
getCurrentUserId() {
getCurrentUserId(allowUnloggedIn?: boolean) {
const context = this.contextBuilder && this.contextBuilder();
return context?.getCurrentUserId();
return context?.getCurrentUserId(allowUnloggedIn);
}
async exec<K extends keyof AD>(

View File

@ -299,7 +299,7 @@ abstract class Node<
protected getProjection(): ED[T]['Selection']['data'] | undefined {
const projection = typeof this.projection === 'function' ? (this.projection as Function)() : (this.projection && cloneDeep(this.projection));
// 根据actions和cascadeActions的定义将对应的projection构建出来
const userId = this.cache.getCurrentUserId();
const userId = this.cache.getCurrentUserId(true);
if (userId && projection) {
if (this.actions) {
const actions = typeof this.actions === 'function' ? this.actions() : this.actions;