mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-04-19 12:39:59 +08:00
fix: created_at & updated_at (#5)
Co-authored-by: kould <2435992353@qq.com>
This commit is contained in:
parent
57a709cd26
commit
95c6cbbf45
@ -16,6 +16,7 @@ serde_json = "1.0"
|
||||
tracing-subscriber = "0.3.18"
|
||||
dotenvy = "0.15.7"
|
||||
listenfd = "1.0.1"
|
||||
chrono = "0.4.31"
|
||||
migration = { path = "./migration" }
|
||||
|
||||
[[bin]]
|
||||
|
@ -11,7 +11,7 @@ async fn create(model: web::Json<tag_info::Model>, data: web::Data<AppState>) ->
|
||||
let model = Mutation::create_tag(&data.conn, model.into_inner()).await.unwrap();
|
||||
|
||||
let mut result = HashMap::new();
|
||||
result.insert("tid", model.uid.unwrap());
|
||||
result.insert("tid", model.tid.unwrap());
|
||||
|
||||
let json_response = JsonResponse {
|
||||
code: 200,
|
||||
|
@ -11,7 +11,9 @@ pub struct Model {
|
||||
pub dialog_name: String,
|
||||
pub history: String,
|
||||
|
||||
#[serde(skip_deserializing)]
|
||||
pub created_at: Date,
|
||||
#[serde(skip_deserializing)]
|
||||
pub updated_at: Date,
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@ pub struct Model {
|
||||
pub r#type: String,
|
||||
pub kb_progress: f64,
|
||||
|
||||
#[serde(skip_deserializing)]
|
||||
pub created_at: Date,
|
||||
#[serde(skip_deserializing)]
|
||||
pub updated_at: Date,
|
||||
#[sea_orm(soft_delete_column)]
|
||||
pub is_deleted: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
@ -11,7 +11,9 @@ pub struct Model {
|
||||
pub kn_name: String,
|
||||
pub icon: i64,
|
||||
|
||||
#[serde(skip_deserializing)]
|
||||
pub created_at: Date,
|
||||
#[serde(skip_deserializing)]
|
||||
pub updated_at: Date,
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,9 @@ pub struct Model {
|
||||
pub icon: i64,
|
||||
pub dir: String,
|
||||
|
||||
#[serde(skip_deserializing)]
|
||||
pub created_at: Date,
|
||||
#[serde(skip_deserializing)]
|
||||
pub updated_at: Date,
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,10 @@ pub struct Model {
|
||||
pub list_style: String,
|
||||
pub language: String,
|
||||
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
#[serde(skip_deserializing)]
|
||||
pub created_at: Date,
|
||||
#[serde(skip_deserializing)]
|
||||
pub updated_at: Date,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
@ -1,3 +1,4 @@
|
||||
use chrono::{Local, NaiveDate};
|
||||
use sea_orm::{ActiveModelTrait, DbConn, DbErr, DeleteResult, EntityTrait, PaginatorTrait, QueryOrder};
|
||||
use sea_orm::ActiveValue::Set;
|
||||
use crate::entity::tag_info;
|
||||
@ -38,15 +39,15 @@ impl Mutation {
|
||||
form_data: tag_info::Model,
|
||||
) -> Result<tag_info::ActiveModel, DbErr> {
|
||||
tag_info::ActiveModel {
|
||||
tid: Set(form_data.tid.to_owned()),
|
||||
tid: Default::default(),
|
||||
uid: Set(form_data.uid.to_owned()),
|
||||
tag_name: Set(form_data.tag_name.to_owned()),
|
||||
regx: Set(form_data.regx.to_owned()),
|
||||
color: Set(form_data.color.to_owned()),
|
||||
icon: Set(form_data.icon.to_owned()),
|
||||
dir: Set(form_data.dir.to_owned()),
|
||||
created_at: Default::default(),
|
||||
updated_at: Default::default(),
|
||||
created_at: Set(Local::now().date_naive()),
|
||||
updated_at: Set(Local::now().date_naive()),
|
||||
}
|
||||
.save(db)
|
||||
.await
|
||||
@ -60,7 +61,7 @@ impl Mutation {
|
||||
let tag: tag_info::ActiveModel = Entity::find_by_id(id)
|
||||
.one(db)
|
||||
.await?
|
||||
.ok_or(DbErr::Custom("Cannot find post.".to_owned()))
|
||||
.ok_or(DbErr::Custom("Cannot find tag.".to_owned()))
|
||||
.map(Into::into)?;
|
||||
|
||||
tag_info::ActiveModel {
|
||||
@ -72,7 +73,7 @@ impl Mutation {
|
||||
icon: Set(form_data.icon.to_owned()),
|
||||
dir: Set(form_data.dir.to_owned()),
|
||||
created_at: Default::default(),
|
||||
updated_at: Default::default(),
|
||||
updated_at: Set(Local::now().date_naive()),
|
||||
}
|
||||
.update(db)
|
||||
.await
|
||||
|
Loading…
x
Reference in New Issue
Block a user