- 新增 8 张数据库表: points_account/rule/transaction/product/order/checkin + offline_event/registration - SeaORM Entity: 8 个实体,含完整 Relation 定义 - DTO: 积分规则/商品/订单/签到/线下活动请求响应类型 - Service: FIFO 积分消费、每日打卡(连续奖励)、商品兑换(QR码核销)、线下活动报名 - Handler: 16 个 API 端点 (患者端10 + 管理端6) - 权限: health.points.list / health.points.manage - 12个月滚动过期机制 - 审计日志全量覆盖
33 lines
842 B
Rust
33 lines
842 B
Rust
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "points_checkin")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub id: Uuid,
|
|
pub tenant_id: Uuid,
|
|
pub patient_id: Uuid,
|
|
pub checkin_date: chrono::NaiveDate,
|
|
pub consecutive_days: i32,
|
|
pub created_at: DateTimeUtc,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::patient::Entity",
|
|
from = "Column::PatientId",
|
|
to = "super::patient::Column::Id"
|
|
)]
|
|
Patient,
|
|
}
|
|
|
|
impl Related<super::patient::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Patient.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|