feat: initialize Nuanji (Warm Notes) project
- Base platform from base.git (ERP base: auth, core, config, message, workflow, plugin) - Created erp-diary module skeleton (lib.rs, dto.rs, error.rs, event.rs, state.rs) - Integrated erp-diary into workspace and erp-server - Added DiaryModule registration in main.rs - Added DiaryState FromRef in state.rs - Diary routes mounted (empty routes, ready for implementation) - Product design spec v1.2 preserved in docs/ - Implementation plan preserved in plans/ Cargo check: OK Cargo test: OK (78+ base tests passing)
This commit is contained in:
45
crates/erp-plugin/src/entity/market_entry.rs
Normal file
45
crates/erp-plugin/src/entity/market_entry.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "plugin_market_entries")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: Uuid,
|
||||
pub plugin_id: String,
|
||||
pub name: String,
|
||||
pub version: String,
|
||||
pub description: Option<String>,
|
||||
pub author: Option<String>,
|
||||
pub category: Option<String>,
|
||||
pub tags: Option<serde_json::Value>,
|
||||
pub icon_url: Option<String>,
|
||||
pub screenshots: Option<serde_json::Value>,
|
||||
#[serde(skip)]
|
||||
pub wasm_binary: Vec<u8>,
|
||||
#[serde(skip_serializing)]
|
||||
pub manifest_toml: String,
|
||||
pub wasm_hash: String,
|
||||
pub min_platform_version: Option<String>,
|
||||
pub status: String,
|
||||
pub download_count: i32,
|
||||
pub rating_avg: Decimal,
|
||||
pub rating_count: i32,
|
||||
pub changelog: Option<String>,
|
||||
pub created_at: DateTimeUtc,
|
||||
pub updated_at: DateTimeUtc,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::market_review::Entity")]
|
||||
MarketReview,
|
||||
}
|
||||
|
||||
impl Related<super::market_review::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::MarketReview.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
33
crates/erp-plugin/src/entity/market_review.rs
Normal file
33
crates/erp-plugin/src/entity/market_review.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "plugin_market_reviews")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: Uuid,
|
||||
pub tenant_id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub market_entry_id: Uuid,
|
||||
pub rating: i32,
|
||||
pub review_text: Option<String>,
|
||||
pub created_at: DateTimeUtc,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::market_entry::Entity",
|
||||
from = "Column::MarketEntryId",
|
||||
to = "super::market_entry::Column::Id"
|
||||
)]
|
||||
MarketEntry,
|
||||
}
|
||||
|
||||
impl Related<super::market_entry::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::MarketEntry.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
5
crates/erp-plugin/src/entity/mod.rs
Normal file
5
crates/erp-plugin/src/entity/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
pub mod market_entry;
|
||||
pub mod market_review;
|
||||
pub mod plugin;
|
||||
pub mod plugin_entity;
|
||||
pub mod plugin_event_subscription;
|
||||
54
crates/erp-plugin/src/entity/plugin.rs
Normal file
54
crates/erp-plugin/src/entity/plugin.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "plugins")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: Uuid,
|
||||
pub tenant_id: Uuid,
|
||||
pub name: String,
|
||||
#[sea_orm(column_name = "plugin_version")]
|
||||
pub plugin_version: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub description: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub author: Option<String>,
|
||||
pub status: String,
|
||||
pub manifest_json: serde_json::Value,
|
||||
#[serde(skip)]
|
||||
pub wasm_binary: Vec<u8>,
|
||||
pub wasm_hash: String,
|
||||
pub config_json: serde_json::Value,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub error_message: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub installed_at: Option<DateTimeUtc>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub enabled_at: Option<DateTimeUtc>,
|
||||
pub created_at: DateTimeUtc,
|
||||
pub updated_at: DateTimeUtc,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub created_by: Option<Uuid>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub updated_by: Option<Uuid>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub deleted_at: Option<DateTimeUtc>,
|
||||
pub version: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::plugin_entity::Entity")]
|
||||
PluginEntity,
|
||||
#[sea_orm(has_many = "super::plugin_event_subscription::Entity")]
|
||||
PluginEventSubscription,
|
||||
}
|
||||
|
||||
impl Related<super::plugin_entity::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::PluginEntity.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
43
crates/erp-plugin/src/entity/plugin_entity.rs
Normal file
43
crates/erp-plugin/src/entity/plugin_entity.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "plugin_entities")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: Uuid,
|
||||
pub tenant_id: Uuid,
|
||||
pub plugin_id: Uuid,
|
||||
pub entity_name: String,
|
||||
pub table_name: String,
|
||||
pub schema_json: serde_json::Value,
|
||||
pub manifest_id: String,
|
||||
pub is_public: bool,
|
||||
pub created_at: DateTimeUtc,
|
||||
pub updated_at: DateTimeUtc,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub created_by: Option<Uuid>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub updated_by: Option<Uuid>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub deleted_at: Option<DateTimeUtc>,
|
||||
pub version: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::plugin::Entity",
|
||||
from = "Column::PluginId",
|
||||
to = "super::plugin::Column::Id"
|
||||
)]
|
||||
Plugin,
|
||||
}
|
||||
|
||||
impl Related<super::plugin::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Plugin.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
30
crates/erp-plugin/src/entity/plugin_event_subscription.rs
Normal file
30
crates/erp-plugin/src/entity/plugin_event_subscription.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "plugin_event_subscriptions")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: Uuid,
|
||||
pub plugin_id: Uuid,
|
||||
pub event_pattern: String,
|
||||
pub created_at: DateTimeUtc,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::plugin::Entity",
|
||||
from = "Column::PluginId",
|
||||
to = "super::plugin::Column::Id"
|
||||
)]
|
||||
Plugin,
|
||||
}
|
||||
|
||||
impl Related<super::plugin::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Plugin.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Reference in New Issue
Block a user