feat(dashboard): add transactions and users management pages with CRUD functionality

feat(auth): implement login page and authentication middleware
feat(sidebar): create sidebar component with user info and navigation links
feat(api): establish API client for interacting with backend services
This commit is contained in:
2026-03-10 15:17:32 +08:00
parent 9a2668fae5
commit 2cb89c74b3
32 changed files with 4648 additions and 83 deletions

View File

@@ -66,6 +66,12 @@ export const chargePoint = pgTable('charge_point', {
lastBootNotificationAt: timestamp('last_boot_notification_at', {
withTimezone: true,
}),
/**
* 电价(单位:分/kWh即 0.01 CNY/kWh
* 交易结束时按实际用电量从储值卡扣费fee = ceil(energyWh * feePerKwh / 1000)
* 默认为 0即不计费
*/
feePerKwh: integer('fee_per_kwh').notNull().default(0),
createdAt: timestamp('created_at', { withTimezone: true })
.notNull()
.defaultNow(),
@@ -271,6 +277,11 @@ export const idTag = pgTable('id_tag', {
* 允许将 RFID 卡与注册用户绑定,支持 Web/App 远程查询充电记录
*/
userId: text('user_id').references(() => user.id, { onDelete: 'set null' }),
/**
* 储值卡余额(单位:分)
* 以整数存储1 分 = 0.01 CNY前端显示时除以 100
*/
balance: integer('balance').notNull().default(0),
createdAt: timestamp('created_at', { withTimezone: true })
.notNull()
.defaultNow(),
@@ -361,6 +372,12 @@ export const transaction = pgTable(
'DeAuthorized',
],
}),
/**
* 本次充电扣费金额(单位:分)
* 由 StopTransaction 处理时根据实际用电量和充电桩电价计算写入
* null 表示未计费(如免费充电桩或交易异常终止)
*/
chargeAmount: integer('charge_amount'),
/**
* 关联的预约 ID若本次充电由预约触发
* StartTransaction.req.reservationIdoptional