-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mis): charge_record 表增加字段 user_id 及 metadata 以存储更多的信息 (#1072)
## 一、charge_record 表增加字段 user_id 及 metadata charge 接口增加可选入参 user_id charge 接口增加可选入参 metadata ## 二、在各消费记录页面中增加以下内容 1.查询结果中的用户显示 2.按用户ID检索 3.增加可选导出用户ID功能 ![image](https://github.com/PKUHPC/SCOW/assets/43978285/1c1a43d3-de3e-491c-879e-c2bbd89dcedb) ![image](https://github.com/PKUHPC/SCOW/assets/43978285/6ae69f70-5622-4fb3-bba0-7d6dc4e36344) ![image](https://github.com/PKUHPC/SCOW/assets/43978285/dd8e42e5-d162-47b2-85ff-32aabc6c6cb5) ## 三、mis.yaml中增加jobChargeMetadata配置 ``` # 自定义消费表单其他存储内容 jobChargeMetadata: # 可选。需要保存的作业的字段,字段参考src/entities/JobInfo savedFields: ["idJob", "account"] # 可选。定义显示出来的格式。如果不配置,直接显示上面保存的字段的信息 displayFormats: # i18n格式,在不同语言下,把元数据按不同格式显示出来 # 或字符串格式,直接显示字符串 i18n: default: "账户 {{ account }} 的作业ID {{ idJob }} 的计费" en: "The billing for jobId {{ idJob }} of Account {{ account }}" zh_cn: "账户 {{ account }} 的作业ID {{ idJob }} 的计费" ``` ## metadata前端展示效果 ### 1.没有配置jobChargeMetadata中的saveFields,不展示相关信息 ![image](https://github.com/PKUHPC/SCOW/assets/43978285/bd67cc4e-4c69-4244-bd77-7979940b6b11) ### 2.已配置jobChargeMetadata中的saveFields ### (1).displayFormats的类型为i18n对象时 ![image](https://github.com/PKUHPC/SCOW/assets/43978285/cdd8628f-9a6b-4e16-a40c-23fff8a383ae) ![image](https://github.com/PKUHPC/SCOW/assets/43978285/b66c76bd-fac0-4aa9-87cd-abfad52deecf) ### (2).displayFormats的类型为字符串时 (支持使用占位符 {{ 属性名 }}) ![image](https://github.com/PKUHPC/SCOW/assets/43978285/5f1e1603-492b-4a1c-a5ea-5d3c70ffa9b3) ### (3).没有配置displayFormats时 ![image](https://github.com/PKUHPC/SCOW/assets/43978285/18873592-98da-412f-9bc1-e31d979254a8) ### 3.特殊情况: 配置的jobChargeMetadata发生改动 之前保存的信息与当前displayFormats占位属性不一致,则之前没有保存过的占位属性显示为"-" ![image](https://github.com/PKUHPC/SCOW/assets/43978285/bc6d2acf-59f3-4d76-a9b6-3b90e871f7b9) ### 上述字段及接口的修改,测试时需要注意的地方为 1. 同步成功作业扣费时 2. 修改作业价格时 3. 其他服务调用scow计费api时 --------- Co-authored-by: picca Sun <[email protected]>
- Loading branch information
Showing
36 changed files
with
559 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@scow/lib-config": patch | ||
"@scow/config": patch | ||
--- | ||
|
||
在 mis.yaml 中增加 jobChargeMetadata 可选配置可记录需要存储的扣费作业的字段信息 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@scow/mis-server": patch | ||
--- | ||
|
||
charge_record 表增加字段 user_id 及 metadata, 以及增加了 time,tenant,account,user_id,type 各字段的索引 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@scow/mis-server": patch | ||
"@scow/mis-web": patch | ||
--- | ||
|
||
增加消费记录中用户的显示、筛选及导出功能 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@scow/grpc-api": minor | ||
--- | ||
|
||
charge接口增加可选入参user_id,metadata, 消费记录查询接口增加查询参数user_ids,增加返回值user_id与metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20240118021127 extends Migration { | ||
|
||
async up(): Promise<void> { | ||
this.addSql('alter table `charge_record` add `user_id` varchar(255) null, add `metadata` json null;'); | ||
this.addSql('alter table `charge_record` add index `time`(`time`);'); | ||
this.addSql('alter table `charge_record` add index `charge_record_tenant_name_index`(`tenant_name`);'); | ||
this.addSql('alter table `charge_record` add index `charge_record_account_name_index`(`account_name`);'); | ||
this.addSql('alter table `charge_record` add index `charge_record_user_id_index`(`user_id`);'); | ||
this.addSql('alter table `charge_record` add index `charge_record_type_index`(`type`);'); | ||
|
||
this.addSql('alter table `tenant` modify `create_time` DATETIME(6) not null default current_timestamp(6);'); | ||
|
||
this.addSql('alter table `user` modify `create_time` DATETIME(6) not null default current_timestamp(6);'); | ||
} | ||
|
||
async down(): Promise<void> { | ||
this.addSql('alter table `charge_record` drop index `time`;'); | ||
this.addSql('alter table `charge_record` drop index `charge_record_tenant_name_index`;'); | ||
this.addSql('alter table `charge_record` drop index `charge_record_account_name_index`;'); | ||
this.addSql('alter table `charge_record` drop index `charge_record_user_id_index`;'); | ||
this.addSql('alter table `charge_record` drop index `charge_record_type_index`;'); | ||
this.addSql('alter table `charge_record` drop `user_id`;'); | ||
this.addSql('alter table `charge_record` drop `metadata`;'); | ||
|
||
this.addSql('alter table `tenant` modify `create_time` DATETIME(6) not null default current_timestamp(0);'); | ||
|
||
this.addSql('alter table `user` modify `create_time` DATETIME(6) not null default current_timestamp(0);'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.