fix
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
use che_tauri::{Filter, FilterSet};
|
||||
|
||||
use super::models::Project;
|
||||
|
||||
static PROJECT_FILTERS: &[Filter] = &[
|
||||
Filter::exact("id"),
|
||||
Filter::exact("name"),
|
||||
Filter::contains("name"),
|
||||
Filter::exact("short_name"),
|
||||
Filter::contains("short_name"),
|
||||
];
|
||||
|
||||
pub fn project_filterset() -> FilterSet<Project> {
|
||||
FilterSet::new(PROJECT_FILTERS)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS project (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
full_name TEXT NOT NULL,
|
||||
short_name TEXT NOT NULL,
|
||||
locality_id INTEGER,
|
||||
locality_name TEXT
|
||||
);
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"table": "project",
|
||||
"fields": [
|
||||
{
|
||||
"name": "id",
|
||||
"ty": "integer",
|
||||
"primary_key": true,
|
||||
"nullable": false,
|
||||
"auto": true,
|
||||
"unique": false,
|
||||
"max_length": null,
|
||||
"default": null,
|
||||
"foreign_key": null
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"ty": "text",
|
||||
"primary_key": false,
|
||||
"nullable": false,
|
||||
"auto": false,
|
||||
"unique": false,
|
||||
"max_length": null,
|
||||
"default": null,
|
||||
"foreign_key": null
|
||||
},
|
||||
{
|
||||
"name": "full_name",
|
||||
"ty": "text",
|
||||
"primary_key": false,
|
||||
"nullable": false,
|
||||
"auto": false,
|
||||
"unique": false,
|
||||
"max_length": null,
|
||||
"default": null,
|
||||
"foreign_key": null
|
||||
},
|
||||
{
|
||||
"name": "short_name",
|
||||
"ty": "text",
|
||||
"primary_key": false,
|
||||
"nullable": false,
|
||||
"auto": false,
|
||||
"unique": false,
|
||||
"max_length": null,
|
||||
"default": null,
|
||||
"foreign_key": null
|
||||
},
|
||||
{
|
||||
"name": "locality_id",
|
||||
"ty": "integer",
|
||||
"primary_key": false,
|
||||
"nullable": true,
|
||||
"auto": false,
|
||||
"unique": false,
|
||||
"max_length": null,
|
||||
"default": null,
|
||||
"foreign_key": null
|
||||
},
|
||||
{
|
||||
"name": "locality_name",
|
||||
"ty": "text",
|
||||
"primary_key": false,
|
||||
"nullable": true,
|
||||
"auto": false,
|
||||
"unique": false,
|
||||
"max_length": null,
|
||||
"default": null,
|
||||
"foreign_key": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
pub mod filters;
|
||||
pub mod models;
|
||||
pub mod serializers;
|
||||
|
||||
use che_tauri::{AppModule, ModuleContext};
|
||||
|
||||
pub fn module() -> ProjectModule {
|
||||
ProjectModule
|
||||
}
|
||||
|
||||
pub struct ProjectModule;
|
||||
|
||||
impl AppModule for ProjectModule {
|
||||
fn name(&self) -> &'static str {
|
||||
"projectapp"
|
||||
}
|
||||
|
||||
fn init(&self, ctx: &mut ModuleContext) {
|
||||
ctx.resource::<models::Project>(
|
||||
"project",
|
||||
serializers::project_serializer(),
|
||||
filters::project_filterset(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
use che_orm::Model;
|
||||
|
||||
#[derive(Debug, Clone, Model)]
|
||||
#[model(table = "project")]
|
||||
pub struct Project {
|
||||
#[field(primary_key)]
|
||||
pub id: i64,
|
||||
|
||||
pub name: String,
|
||||
pub full_name: String,
|
||||
pub short_name: String,
|
||||
pub locality_id: Option<i64>,
|
||||
pub locality_name: Option<String>,
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
use che_tauri::{Field, ModelSerializer};
|
||||
|
||||
use super::models::Project;
|
||||
|
||||
static PROJECT_FIELDS: &[Field] = &[
|
||||
Field::new("id").read_only(),
|
||||
Field::new("name"),
|
||||
Field::new("full_name"),
|
||||
Field::new("short_name"),
|
||||
Field::new("locality_id").required(false).nullable(),
|
||||
Field::new("locality_name").required(false).nullable(),
|
||||
];
|
||||
|
||||
pub fn project_serializer() -> ModelSerializer<Project> {
|
||||
ModelSerializer::new(PROJECT_FIELDS)
|
||||
}
|
||||
Reference in New Issue
Block a user