zl程序教程

您现在的位置是:首页 >  其他

当前栏目

SAP Spartacus B2B模块 State的设计原理

SAP模块原理 设计 Spartacus State B2B
2023-09-14 09:02:54 时间

Spartacus stores everything related to Organization in entities and lists of IDs separately. Associated data for a subsection is stored with its own feature, but for specific views, Spartacus uses a combination of ID and query parameters to store a list of IDs and other information.

export interface Management<Type> extends StateUtils.EntityListState<Type> {}

展开:

Management<UserGroup> 

相当于

StateUtils.EntityListState<UserGroup>:

export interface EntityListState<Type> {
  list: EntityLoaderState<ListModel>;
  entities: EntityLoaderState<Type>;
}

相当于:

EntityListState<UserGroup>{
list: EntityLoaderState<ListModel>;
entity: EntityLoaderState<UserGroup>;
}

export type EntityLoaderState = EntityState<LoaderState>;

相当于:

EntityListState<UserGroup>{
list: EntityState<LoaderState<ListModel>;
entity: EntityState<LoaderState<UserGroup>;
}

相当于:

EntityListState<UserGroup>{
list: EntityState<loading, error, success, value: ListModel>;
entity: EntityState<loading, error, success, value: UserGroup>;
}

相当于:

EntityListState<UserGroup>{
list: EntityState<loading, error, success, value: ListModel>;
entity: EntityState<loading, error, success, value: UserGroup>;
}

相当于:

EntityListState<UserGroup>{
list: entities: {
    [id: string]: loading, error, success, value: ListModel
  }
entity: entities: {
    [id: string]: loading, error, success, value: UserGroup
  };
}

例子:

  • entities stores real user group objects, which are key mapped to status flags and values
  • list stores a list of user groups IDs for specified pages, with keys based on query parameters, such as pagination and sorts
  • customers stores IDs for a subsection, with keys based on the ID of the user group and query parameters
  • permisions stores IDs for a subsection, with keys based on the ID of the user group and query parameters
  • pageSize=2147483647 indicates that Spartacus fetches all possible items, up to the maximum safe Java integer

更多Jerry的原创文章,尽在:“汪子熙”: