Эх сурвалжийг харах

♻️ refactor(payment): 统一数据库字段命名格式

- 为所有实体属性添加显式name属性,采用下划线命名法
- 保持字段功能和类型不变,仅规范化命名以符合数据库最佳实践
- 涉及字段: externalOrderId→external_order_id, userId→user_id, totalAmount→total_amount等
yourname 3 долоо хоног өмнө
parent
commit
0bcadd2311

+ 10 - 9
packages/mini-payment/src/entities/payment.entity.ts

@@ -6,38 +6,39 @@ export class PaymentEntity {
   @PrimaryGeneratedColumn({ comment: '支付记录ID' })
   id!: number;
 
-  @Column({ type: 'int', unsigned: true, comment: '外部订单ID(用于与业务系统集成)' })
+  @Column({ type: 'int', unsigned: true, name: 'external_order_id', comment: '外部订单ID(用于与业务系统集成)' })
   externalOrderId!: number;
 
-  @Column({ type: 'int', unsigned: true, comment: '用户ID' })
+  @Column({ type: 'int', unsigned: true, name: 'user_id', comment: '用户ID' })
   userId!: number;
 
-  @Column({ type: 'int', unsigned: true, comment: '支付金额(分)' })
+  @Column({ type: 'int', unsigned: true, name: 'total_amount', comment: '支付金额(分)' })
   totalAmount!: number;
 
-  @Column({ type: 'varchar', length: 128, comment: '支付描述' })
+  @Column({ type: 'varchar', length: 128, name: 'description', comment: '支付描述' })
   description!: string;
 
   @Column({
     type: 'enum',
     enum: PaymentStatus,
     default: PaymentStatus.PENDING,
+    name: 'payment_status',
     comment: '支付状态'
   })
   paymentStatus!: PaymentStatus;
 
-  @Column({ type: 'varchar', length: 64, nullable: true, comment: '微信支付交易ID' })
+  @Column({ type: 'varchar', length: 64, nullable: true, name: 'wechat_transaction_id', comment: '微信支付交易ID' })
   wechatTransactionId?: string;
 
-  @Column({ type: 'varchar', length: 64, nullable: true, comment: '商户订单号' })
+  @Column({ type: 'varchar', length: 64, nullable: true, name: 'out_trade_no', comment: '商户订单号' })
   outTradeNo?: string;
 
-  @Column({ type: 'varchar', length: 64, comment: '用户OpenID' })
+  @Column({ type: 'varchar', length: 64, name: 'openid', comment: '用户OpenID' })
   openid!: string;
 
-  @CreateDateColumn({ comment: '创建时间' })
+  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
   createdAt!: Date;
 
-  @UpdateDateColumn({ comment: '更新时间' })
+  @UpdateDateColumn({ name: 'updated_at', comment: '更新时间' })
   updatedAt!: Date;
 }