Skip to content

Commit

Permalink
Modify the usage of TrimString.
Browse files Browse the repository at this point in the history
  • Loading branch information
gudaoxuri committed May 7, 2024
1 parent a337fa4 commit 8eb7b4d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ run_script = { version = "0.10" }
testcontainers-modules = { version = "0.3", features = ["redis"] }
strum = { version = "0.26", features = ["derive"] }
# tardis
# tardis = { version = "0.1.0-rc.11" }
# tardis = { path = "../tardis/tardis" }
tardis = { git = "https://github.com/ideal-world/tardis.git", rev = "694ff92" }
# tardis = { version = "0.1.0-rc.13" }
tardis = { path = "../tardis/tardis" }
# tardis = { git = "https://github.com/ideal-world/tardis.git", rev = "694ff92" }
#spacegate

# spacegate-kernel = { git = "https://github.com/ideal-world/spacegate.git", rev = "f37a81a", features = [
Expand Down
10 changes: 5 additions & 5 deletions backend/basic/src/rbum/serv/rbum_cert_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ impl RbumCrudOperation<rbum_cert_conf::ActiveModel, RbumCertConfAddReq, RbumCert
Query::select()
.column(rbum_cert_conf::Column::Id)
.from(rbum_cert_conf::Entity)
.and_where(Expr::col(rbum_cert_conf::Column::Kind).eq(add_req.kind.as_str()))
.and_where(Expr::col(rbum_cert_conf::Column::Supplier).eq(add_req.supplier.as_ref().unwrap_or(&TrimString("".to_string())).as_str()))
.and_where(Expr::col(rbum_cert_conf::Column::Kind).eq(add_req.kind.to_string()))
.and_where(Expr::col(rbum_cert_conf::Column::Supplier).eq(add_req.supplier.as_ref().unwrap_or(&TrimString::from("")).to_string()))
.and_where(Expr::col(rbum_cert_conf::Column::RelRbumDomainId).eq(add_req.rel_rbum_domain_id.as_str()))
.and_where(Expr::col(rbum_cert_conf::Column::RelRbumItemId).eq(add_req.rel_rbum_item_id.as_ref().unwrap_or(&"".to_string()).as_str())),
)
Expand Down Expand Up @@ -415,7 +415,7 @@ impl RbumCrudOperation<rbum_cert::ActiveModel, RbumCertAddReq, RbumCertModifyReq
.column(rbum_cert::Column::Id)
.from(rbum_cert::Entity)
.and_where(Expr::col(rbum_cert::Column::RelRbumKind).eq(add_req.rel_rbum_kind.to_int()))
.and_where(Expr::col(rbum_cert::Column::Ak).eq(add_req.ak.as_str()))
.and_where(Expr::col(rbum_cert::Column::Ak).eq(add_req.ak.to_string()))
.and_where(Expr::col(rbum_cert::Column::RelRbumCertConfId).eq(add_req.rel_rbum_cert_conf_id.clone()))
.and_where(Expr::col(rbum_cert::Column::OwnPaths).like(format!("{}%", ctx.own_paths).as_str())),
)
Expand Down Expand Up @@ -520,7 +520,7 @@ impl RbumCrudOperation<rbum_cert::ActiveModel, RbumCertAddReq, RbumCertModifyReq
}
}
if let Some(vcode) = &add_req.vcode {
Self::add_vcode_to_cache(add_req.ak.as_str(), vcode.as_str(), rel_rbum_cert_conf_id, funs, &ctx).await?;
Self::add_vcode_to_cache(&add_req.ak, vcode, rel_rbum_cert_conf_id, funs, &ctx).await?;
}
}
Ok(())
Expand Down Expand Up @@ -596,7 +596,7 @@ impl RbumCrudOperation<rbum_cert::ActiveModel, RbumCertAddReq, RbumCertModifyReq
Query::select()
.column(rbum_cert::Column::Id)
.from(rbum_cert::Entity)
.and_where(Expr::col(rbum_cert::Column::Ak).eq(modify_req.ak.as_ref().expect("ignore").as_str()))
.and_where(Expr::col(rbum_cert::Column::Ak).eq(modify_req.ak.as_ref().expect("ignore").to_string()))
.and_where(Expr::col(rbum_cert::Column::RelRbumCertConfId).eq(rbum_cert_conf.id.clone()))
.and_where(Expr::col(rbum_cert::Column::OwnPaths).like(format!("{}%", ctx.own_paths).as_str()))
.and_where(Expr::col(rbum_cert::Column::Id).ne(id.to_string().as_str())),
Expand Down
4 changes: 2 additions & 2 deletions backend/basic/src/rbum/serv/rbum_domain_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ impl RbumCrudOperation<rbum_domain::ActiveModel, RbumDomainAddReq, RbumDomainMod
}

async fn before_add_rbum(add_req: &mut RbumDomainAddReq, funs: &TardisFunsInst, _: &TardisContext) -> TardisResult<()> {
if !R_URL_PART_CODE.is_match(add_req.code.as_str()) {
if !R_URL_PART_CODE.is_match(&add_req.code) {
return Err(funs.err().bad_request(&Self::get_obj_name(), "add", &format!("code {} is invalid", add_req.code), "400-rbum-*-code-illegal"));
}
if funs
.db()
.count(Query::select().column(rbum_domain::Column::Id).from(rbum_domain::Entity).and_where(Expr::col(rbum_domain::Column::Code).eq(add_req.code.as_str())))
.count(Query::select().column(rbum_domain::Column::Id).from(rbum_domain::Entity).and_where(Expr::col(rbum_domain::Column::Code).eq(add_req.code.to_string())))
.await?
> 0
{
Expand Down
4 changes: 2 additions & 2 deletions backend/basic/src/rbum/serv/rbum_item_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl RbumCrudOperation<rbum_item::ActiveModel, RbumItemAddReq, RbumItemKernelMod
rbum_kind::Entity,
Expr::col((rbum_kind::Entity, rbum_kind::Column::Id)).equals((rbum_item::Entity, rbum_item::Column::RelRbumKindId)),
)
.and_where(Expr::col((rbum_item::Entity, rbum_item::Column::Code)).eq(code.as_str())),
.and_where(Expr::col((rbum_item::Entity, rbum_item::Column::Code)).eq(code.to_string())),
)
.await?
> 0
Expand Down Expand Up @@ -114,7 +114,7 @@ impl RbumCrudOperation<rbum_item::ActiveModel, RbumItemAddReq, RbumItemKernelMod
rbum_kind::Entity,
Expr::col((rbum_kind::Entity, rbum_kind::Column::Id)).equals((rbum_item::Entity, rbum_item::Column::RelRbumKindId)),
)
.and_where(Expr::col((rbum_item::Entity, rbum_item::Column::Code)).eq(code.as_str()))
.and_where(Expr::col((rbum_item::Entity, rbum_item::Column::Code)).eq(code.to_string()))
.and_where(Expr::col((rbum_item::Entity, rbum_item::Column::Id)).ne(id)),
)
.await?
Expand Down
8 changes: 4 additions & 4 deletions backend/basic/src/rbum/serv/rbum_kind_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ impl RbumCrudOperation<rbum_kind::ActiveModel, RbumKindAddReq, RbumKindModifyReq
}

async fn before_add_rbum(add_req: &mut RbumKindAddReq, funs: &TardisFunsInst, _: &TardisContext) -> TardisResult<()> {
if !R_URL_PART_CODE.is_match(add_req.code.as_str()) {
if !R_URL_PART_CODE.is_match(&add_req.code) {
return Err(funs.err().bad_request(&Self::get_obj_name(), "add", &format!("code {} is invalid", add_req.code), "400-rbum-*-code-illegal"));
}
if funs.db().count(Query::select().column(rbum_kind::Column::Id).from(rbum_kind::Entity).and_where(Expr::col(rbum_kind::Column::Code).eq(add_req.code.as_str()))).await? > 0
if funs.db().count(Query::select().column(rbum_kind::Column::Id).from(rbum_kind::Entity).and_where(Expr::col(rbum_kind::Column::Code).eq(add_req.code.to_string()))).await? > 0
{
return Err(funs.err().conflict(&Self::get_obj_name(), "add", &format!("code {} already exists", add_req.code), "409-rbum-*-code-exist"));
}
Expand Down Expand Up @@ -151,8 +151,8 @@ impl RbumCrudOperation<rbum_kind_attr::ActiveModel, RbumKindAttrAddReq, RbumKind
Query::select()
.column(rbum_kind_attr::Column::Id)
.from(rbum_kind_attr::Entity)
.and_where(Expr::col(rbum_kind_attr::Column::Name).eq(add_req.name.as_str()))
.and_where(Expr::col(rbum_kind_attr::Column::Module).eq(add_req.module.as_ref().unwrap_or(&TrimString("".to_string())).as_str()))
.and_where(Expr::col(rbum_kind_attr::Column::Name).eq(add_req.name.to_string()))
.and_where(Expr::col(rbum_kind_attr::Column::Module).eq(add_req.module.as_ref().unwrap_or(&TrimString("".to_string())).to_string()))
.and_where(Expr::col(rbum_kind_attr::Column::RelRbumKindId).eq(add_req.rel_rbum_kind_id.as_str()))
.and_where(Expr::col(rbum_kind_attr::Column::OwnPaths).like(format!("{}%", ctx.own_paths).as_str())),
)
Expand Down

0 comments on commit 8eb7b4d

Please sign in to comment.