merge upstream
This commit is contained in:
commit
233b076618
7 changed files with 76 additions and 2 deletions
|
|
@ -49,7 +49,11 @@ class Postgres(object):
|
|||
cur = self.conn.cursor()
|
||||
cur.execute(sql)
|
||||
updated_rows = cur.rowcount
|
||||
<<<<<<< HEAD
|
||||
self.conn.commit()
|
||||
=======
|
||||
conn.commit()
|
||||
>>>>>>> upstream/main
|
||||
cur.close()
|
||||
return updated_rows
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -142,7 +142,6 @@ async fn mv(params: web::Json<MvParams>, data: web::Data<AppState>) -> Result<Ht
|
|||
.body(serde_json::to_string(&json_response)?))
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct NewFoldParams {
|
||||
pub uid: i64,
|
||||
|
|
|
|||
58
src/api/tag.rs
Normal file
58
src/api/tag.rs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
use std::collections::HashMap;
|
||||
use actix_web::{get, HttpResponse, post, web};
|
||||
use actix_web::http::Error;
|
||||
use crate::api::JsonResponse;
|
||||
use crate::AppState;
|
||||
use crate::entity::tag_info;
|
||||
use crate::service::tag_info::{Mutation, Query};
|
||||
|
||||
#[post("/v1.0/create_tag")]
|
||||
async fn create(model: web::Json<tag_info::Model>, data: web::Data<AppState>) -> Result<HttpResponse, Error> {
|
||||
let model = Mutation::create_tag(&data.conn, model.into_inner()).await.unwrap();
|
||||
|
||||
let mut result = HashMap::new();
|
||||
result.insert("tid", model.tid.unwrap());
|
||||
|
||||
let json_response = JsonResponse {
|
||||
code: 200,
|
||||
err: "".to_owned(),
|
||||
data: result,
|
||||
};
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type("application/json")
|
||||
.body(serde_json::to_string(&json_response).unwrap()))
|
||||
}
|
||||
|
||||
#[post("/v1.0/delete_tag")]
|
||||
async fn delete(model: web::Json<tag_info::Model>, data: web::Data<AppState>) -> Result<HttpResponse, Error> {
|
||||
let _ = Mutation::delete_tag(&data.conn, model.tid).await.unwrap();
|
||||
|
||||
let json_response = JsonResponse {
|
||||
code: 200,
|
||||
err: "".to_owned(),
|
||||
data: (),
|
||||
};
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type("application/json")
|
||||
.body(serde_json::to_string(&json_response).unwrap()))
|
||||
}
|
||||
|
||||
#[get("/v1.0/tags")]
|
||||
async fn list(data: web::Data<AppState>) -> Result<HttpResponse, Error> {
|
||||
let tags = Query::find_tag_infos(&data.conn).await.unwrap();
|
||||
|
||||
let mut result = HashMap::new();
|
||||
result.insert("tags", tags);
|
||||
|
||||
let json_response = JsonResponse {
|
||||
code: 200,
|
||||
err: "".to_owned(),
|
||||
data: result,
|
||||
};
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type("application/json")
|
||||
.body(serde_json::to_string(&json_response).unwrap()))
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ pub struct Model {
|
|||
pub kb_id: i64,
|
||||
#[sea_orm(index)]
|
||||
pub did: i64,
|
||||
<<<<<<< HEAD
|
||||
#[serde(skip_deserializing)]
|
||||
pub kb_progress: f32,
|
||||
#[serde(skip_deserializing)]
|
||||
|
|
@ -19,6 +20,8 @@ pub struct Model {
|
|||
pub updated_at: DateTime<FixedOffset>,
|
||||
#[serde(skip_deserializing)]
|
||||
pub is_deleted: bool,
|
||||
=======
|
||||
>>>>>>> upstream/main
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, EnumIter)]
|
||||
|
|
|
|||
|
|
@ -11,12 +11,19 @@ pub struct Model {
|
|||
#[sea_orm(index)]
|
||||
pub uid: i64,
|
||||
pub tag_name: String,
|
||||
<<<<<<< HEAD
|
||||
#[serde(skip_deserializing)]
|
||||
pub regx: String,
|
||||
pub color: i16,
|
||||
pub icon: i16,
|
||||
#[serde(skip_deserializing)]
|
||||
pub folder_id: i64,
|
||||
=======
|
||||
pub regx: Option<String>,
|
||||
pub color: u16,
|
||||
pub icon: u16,
|
||||
pub dir: Option<String>,
|
||||
>>>>>>> upstream/main
|
||||
|
||||
#[serde(skip_deserializing)]
|
||||
pub created_at: DateTime<FixedOffset>,
|
||||
|
|
|
|||
|
|
@ -98,8 +98,11 @@ fn init(cfg: &mut web::ServiceConfig) {
|
|||
cfg.service(api::kb_info::delete);
|
||||
cfg.service(api::kb_info::list);
|
||||
cfg.service(api::kb_info::add_docs_to_kb);
|
||||
<<<<<<< HEAD
|
||||
cfg.service(api::kb_info::anti_kb_docs);
|
||||
cfg.service(api::kb_info::all_relevents);
|
||||
=======
|
||||
>>>>>>> upstream/main
|
||||
|
||||
cfg.service(api::doc_info::list);
|
||||
cfg.service(api::doc_info::delete);
|
||||
|
|
|
|||
|
|
@ -162,4 +162,4 @@ impl Mutation {
|
|||
pub async fn delete_all_kb_infos(db: &DbConn) -> Result<DeleteResult, DbErr> {
|
||||
Entity::delete_many().exec(db).await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue