Oper增加了bornAt域

This commit is contained in:
Xu Chang 2024-02-06 19:45:05 +08:00
parent 1d193f0f81
commit dd787d5581
7 changed files with 19 additions and 3 deletions

View File

@ -3,7 +3,7 @@ import { Q_DateValue, Q_NumberValue, Q_StringValue, NodeId, MakeFilter, ExprOp,
import { OneOf } from "../../types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult, EntityShape } from "../../types/Entity";
import { AppendOnlyAction } from "../../actions/action";
import { String } from "../../types/DataType";
import { String, Datetime } from "../../types/DataType";
import * as User from "../User/Schema";
import * as OperEntity from "../OperEntity/Schema";
export type OpSchema = EntityShape & {
@ -13,6 +13,7 @@ export type OpSchema = EntityShape & {
extra?: Object | null;
operatorId?: ForeignKey<"user"> | null;
targetEntity: String<32>;
bornAt: Datetime;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
@ -22,6 +23,7 @@ export type Schema = EntityShape & {
extra?: Object | null;
operatorId?: ForeignKey<"user"> | null;
targetEntity: String<32>;
bornAt: Datetime;
operator?: User.Schema | null;
operEntity$oper?: Array<OperEntity.Schema>;
operEntity$oper$$aggr?: AggregationResult<OperEntity.Schema>;
@ -40,6 +42,7 @@ type AttrFilter = {
operatorId: Q_StringValue;
operator: User.Filter;
targetEntity: Q_StringValue;
bornAt: Q_DateValue;
operEntity$oper: OperEntity.Filter & SubQueryPredicateMetadata;
};
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
@ -57,6 +60,7 @@ export type Projection = {
operatorId?: number;
operator?: User.Projection;
targetEntity?: number;
bornAt?: number;
operEntity$oper?: OperEntity.Selection & {
$entity: "operEntity";
};
@ -86,6 +90,8 @@ export type SortAttr = {
operator: User.SortAttr;
} | {
targetEntity: number;
} | {
bornAt: number;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>;

View File

@ -31,6 +31,10 @@ exports.desc = {
params: {
length: 32
}
},
bornAt: {
notNull: true,
type: "datetime"
}
},
actionType: "appendOnly",

View File

@ -1,4 +1,4 @@
import { String } from '../types/DataType';
import { String, Datetime } from '../types/DataType';
import { EntityShape } from '../types/Entity';
import { Schema as User } from './User';
export interface Schema extends EntityShape {
@ -8,4 +8,5 @@ export interface Schema extends EntityShape {
extra?: Object;
operator?: User;
targetEntity: String<32>;
bornAt: Datetime;
}

View File

@ -12,6 +12,7 @@ const entityDesc = {
extra: '其它',
operator: '操作者',
targetEntity: '关联对象',
bornAt: '诞生时间'
},
},
},

View File

@ -54,6 +54,7 @@ export type Operation<A extends string, D extends Projection, F extends Filter |
action: A;
data: D;
sorter?: S;
bornAt?: number;
} & FilterPart<A, F>;
export type Selection<A extends ReadOnlyAction, D extends Projection, F extends Filter | undefined = undefined, S extends Sorter | undefined = undefined> = {
id?: string;

View File

@ -10,6 +10,7 @@ export interface Schema extends EntityShape {
extra?: Object;
operator?: User;
targetEntity: String<32>;
bornAt: Datetime;
};
const entityDesc: EntityDesc<Schema> = {
@ -23,6 +24,7 @@ const entityDesc: EntityDesc<Schema> = {
extra: '其它',
operator: '操作者',
targetEntity: '关联对象',
bornAt: '诞生时间'
},
},
},

View File

@ -60,10 +60,11 @@ export type Operation<A extends string,
D extends Projection,
F extends Filter | undefined = undefined,
S extends Sorter | undefined = undefined> = {
id: string; // 为了一致性每个operation也应当保证唯一id
id: string; // 为了一致性每个operation也应当保证唯一id
action: A;
data: D;
sorter?: S;
bornAt?: number; // operation的实际诞生时间分布式环境下用
} & FilterPart<A, F>;
export type Selection<A extends ReadOnlyAction,