Skip to content

Commit

Permalink
fix: fix collection children api
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Nov 25, 2023
1 parent 3b30ec8 commit 5bd4bca
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 41 deletions.
62 changes: 36 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "writing"
version = "1.3.12"
version = "1.3.13"
edition = "2021"
rust-version = "1.64"
description = ""
Expand Down
2 changes: 2 additions & 0 deletions src/api/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ pub async fn list_children(
output.status = doc.status;
output.updated_at = doc.updated_at;
output.language = to.with(doc.language);
output.version = doc.version;
output.title = doc.title;
output.summary = doc.summary;
output.kind = 1;
Expand All @@ -1104,6 +1105,7 @@ pub async fn list_children(
output.status = doc.status;
output.updated_at = doc.updated_at;
output.language = to.with(doc.language);
output.version = doc.version;
output.title = doc.title;
output.summary = doc.summary;
output.kind = 0;
Expand Down
5 changes: 0 additions & 5 deletions src/api/publication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,6 @@ pub struct UpdatePublicationInput {
#[validate(range(min = 1, max = 10000))]
pub version: i16,
pub updated_at: i64,
#[validate(length(min = 2, max = 16))]
pub model: Option<String>,
#[validate(length(min = 1, max = 256))]
pub title: Option<String>,
#[validate(url)]
Expand All @@ -804,9 +802,6 @@ pub struct UpdatePublicationInput {
impl UpdatePublicationInput {
fn into(self) -> anyhow::Result<ColumnsMap> {
let mut cols = ColumnsMap::new();
if let Some(model) = self.model {
cols.set_as("model", &model);
}
if let Some(title) = self.title {
cols.set_as("title", &title);
}
Expand Down
14 changes: 11 additions & 3 deletions src/db/model_creation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,17 @@ impl Creation {
}

let mut select_fields = select_fields;
let language = "language".to_string(); // language 字段在 meilisearch 中用作 PK,必须存在
if !select_fields.contains(&language) {
select_fields.push(language);
let field = "language".to_string(); // language 字段在 meilisearch 中用作 PK,必须存在
if !select_fields.contains(&field) {
select_fields.push(field);
}
let field = "version".to_string();
if !select_fields.contains(&field) {
select_fields.push(field);
}
let field = "status".to_string();
if !select_fields.contains(&field) {
select_fields.push(field);
}

if with_pk {
Expand Down
6 changes: 0 additions & 6 deletions src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ pub async fn new(cfg: conf::Conf) -> anyhow::Result<(Arc<api::AppState>, Router)
.nest(
"/v1/publication",
Router::new()
// .nest(
// "/comment",
// Router::new()
// .route("/", routing::post(todo).get(todo).patch(todo).delete(todo))
// .route("/list", routing::post(todo)),
// )
.route(
"/",
routing::post(api::publication::create)
Expand Down

0 comments on commit 5bd4bca

Please sign in to comment.