Skip to content

Commit

Permalink
🎨 cargo clippy & fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
phidiaLam committed May 19, 2024
1 parent fb4fe5c commit 7417485
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 68 deletions.
6 changes: 4 additions & 2 deletions logic/ceobe_operation_logic/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::convert::Infallible;

use persistence::ceobe_operate::tool_link::OperateError as ToolLinkIOperateError;
use persistence::ceobe_operate::{
models::tool_link::CheckError,
tool_link::OperateError as ToolLinkIOperateError,
};
use status_err::StatusErr;
use thiserror::Error;
use persistence::ceobe_operate::models::tool_link::CheckError;

#[derive(Debug, Error, StatusErr)]
pub enum LogicError {
Expand Down
53 changes: 26 additions & 27 deletions logic/ceobe_operation_logic/src/impletements/tool_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ use page_size::{
};
use persistence::{
ceobe_operate::{
models::tool_link::{
self,
checkers::tool_link_data::{
CeobeOperationToolLink, CeobeOperationToolLinkUncheck,
PreCheckCeobeOperationToolLinkChecker,
},
models::model_tool_link,
models::tool_link::checkers::tool_link_data::{
CeobeOperationToolLinkUncheck,
PreCheckCeobeOperationToolLinkChecker,
},
ToCeobeOperation,
},
Expand Down Expand Up @@ -103,18 +99,18 @@ impl CeobeOperateLogic {
let tool_list = tool_list?;
let mut tool_links = Vec::<ToolLinkBackend>::new();
for tool in tool_list {
tool_links.push(ToolLinkBackend::builder()
.id(Some(tool.id))
.avatar(tool.avatar)
.nickname(tool.nickname)
.jump_url(tool.jump_url)
.slogen(tool.slogen)
.description(tool.description)
.tags(serde_json::from_str::<Vec<String>>(&tool.tags)?)
.build())
tool_links.push(
ToolLinkBackend::builder()
.id(Some(tool.id))
.avatar(tool.avatar)
.nickname(tool.nickname)
.jump_url(tool.jump_url)
.slogen(tool.slogen)
.description(tool.description)
.tags(serde_json::from_str::<Vec<String>>(&tool.tags)?)
.build(),
)
}



let resp = tool_links.with_page_info(page_size, count?);

Expand All @@ -124,18 +120,21 @@ impl CeobeOperateLogic {
pub async fn find_tool_link_list(
sql: SqlDatabaseOperate,
) -> LogicResult<Vec<ToolLinkFront>> {
let tool_list = sql.ceobe().operation().tool_link().find_list().await?;
let tool_list =
sql.ceobe().operation().tool_link().find_list().await?;

let mut tool_links = Vec::<ToolLinkFront>::new();
for tool in tool_list {
tool_links.push(ToolLinkFront::builder()
.avatar(tool.avatar)
.nickname(tool.nickname)
.jump_url(tool.jump_url)
.slogen(tool.slogen)
.description(tool.description)
.tags(serde_json::from_str::<Vec<String>>(&tool.tags)?)
.build())
tool_links.push(
ToolLinkFront::builder()
.avatar(tool.avatar)
.nickname(tool.nickname)
.jump_url(tool.jump_url)
.slogen(tool.slogen)
.description(tool.description)
.tags(serde_json::from_str::<Vec<String>>(&tool.tags)?)
.build(),
)
}

Ok(tool_links)
Expand Down
1 change: 0 additions & 1 deletion logic/ceobe_operation_logic/src/view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use serde::{Deserialize, Serialize};
use typed_builder::TypedBuilder;
use url::Url;

#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
pub struct DeleteOneToolLinkReq {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

use sea_orm_migration::prelude::*;

use super:: m20220722_082735_change_user_table_name::AdminUser;
use sql_models::admin_user::{AuthLevel, Column::Auth};

use super::m20220722_082735_change_user_table_name::AdminUser;

pub struct Migration;
impl MigrationName for Migration {
Expand All @@ -15,7 +13,7 @@ impl MigrationTrait for Migration {
let mut al = sea_query::Table::alter();
al.table(AdminUser::Table).modify_column(
ColumnDef::new_with_type(Auth, AuthLevel::column_type())
.not_null(),
.not_null(),
);
manager.alter_table(al).await?;

Expand All @@ -27,7 +25,7 @@ impl MigrationTrait for Migration {
let mut al = sea_query::Table::alter();
al.table(AdminUser::Table).modify_column(
ColumnDef::new_with_type(Auth, AuthLevel::column_type())
.not_null(),
.not_null(),
);
manager.alter_table(al).await?;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

use sea_orm_migration::prelude::*;

use super::CeobeOperationToolLink;


pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str { "m20240519_004238_ceobe_operation_tool_link_add_infos" }
fn name(&self) -> &str {
"m20240519_004238_ceobe_operation_tool_link_add_infos"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
Expand All @@ -15,21 +15,21 @@ impl MigrationTrait for Migration {
al.table(CeobeOperationToolLink::Table)
.add_column(
ColumnDef::new(CeobeOperationToolLink::Slogen)
.string_len(16)
.not_null()
.default(""),
.string_len(16)
.not_null()
.default(""),
)
.add_column(
ColumnDef::new(CeobeOperationToolLink::Description)
.string_len(64)
.not_null()
.default(""),
.string_len(64)
.not_null()
.default(""),
)
.add_column(
ColumnDef::new(CeobeOperationToolLink::Tags)
.string_len(64)
.not_null()
.default("[]"),
.string_len(64)
.not_null()
.default("[]"),
);
manager.alter_table(al).await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use checker::{
prefabs::{
no_check::NoCheck, option_checker::OptionChecker,
str_len_checker::StrMaxCharLenChecker, url_checker::UrlChecker,
}, ToCheckRequire,
},
ToCheckRequire,
};
use sea_orm::{IntoActiveModel, Set};
use sql_connection::ext_traits::active_or_set::ActiveOrSet;
Expand Down
1 change: 0 additions & 1 deletion src/router/back_end/ceobe_operation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ new_auth_level! {
Outsourcing
]
}

27 changes: 12 additions & 15 deletions src/serves/backend/ceobe_operation/tool_link/controllers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ use axum::{
};
use ceobe_cookie_logic::view::AvatarId;
use ceobe_operation_logic::{
impletements::CeobeOperateLogic, view::{DeleteOneToolLinkReq, ToolLinkBackend},
impletements::CeobeOperateLogic,
view::{DeleteOneToolLinkReq, ToolLinkBackend},
};
use ceobe_qiniu_upload::QiniuManager;
use checker::{CheckExtract, JsonCheckExtract};
use checker::CheckExtract;
use page_size::response::ListWithPageInfo;
use persistence::{
ceobe_operate::models::tool_link::{
self, checkers::tool_link_data::PreCheckCeobeOperationToolLinkChecker,
},
mysql::SqlDatabaseOperate,
};
use persistence::mysql::SqlDatabaseOperate;
use qiniu_cdn_upload::UploadWrap;
use resp_result::{resp_try, MapReject};
use tracing::instrument;
Expand All @@ -29,17 +25,15 @@ use crate::{
},
};

type CeobeOperationToolLinkCheck = JsonCheckExtract<
PreCheckCeobeOperationToolLinkChecker,
OperateToolLinkError,
>;

impl CeobeOpToolLink {
/// 新增一个工具
#[instrument(ret, skip(sql))]
pub async fn create_one(
sql: SqlDatabaseOperate,
MapReject(tool_link): MapReject<Json<ToolLinkBackend>, OperateToolLinkError>,
MapReject(tool_link): MapReject<
Json<ToolLinkBackend>,
OperateToolLinkError,
>,
) -> OperateToolLinkRResult<()> {
resp_try(async move {
CeobeOperateLogic::create_tool_link(sql, tool_link).await?;
Expand All @@ -52,7 +46,10 @@ impl CeobeOpToolLink {
#[instrument(ret, skip(sql))]
pub async fn update_one(
sql: SqlDatabaseOperate,
MapReject(tool_link): MapReject<Json<ToolLinkBackend>, OperateToolLinkError>,
MapReject(tool_link): MapReject<
Json<ToolLinkBackend>,
OperateToolLinkError,
>,
) -> OperateToolLinkRResult<()> {
resp_try(async move {
CeobeOperateLogic::update_tool_link(sql, tool_link).await?;
Expand Down
7 changes: 3 additions & 4 deletions src/serves/frontend/ceobe/operation/tool_link/controllers.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use ceobe_operation_logic::{impletements::CeobeOperateLogic, view::ToolLinkFront};
use persistence::{
ceobe_operate::models::tool_link::models::model_tool_link::FrontendToolLink,
mysql::SqlDatabaseOperate,
use ceobe_operation_logic::{
impletements::CeobeOperateLogic, view::ToolLinkFront,
};
use persistence::mysql::SqlDatabaseOperate;
use resp_result::resp_try;
use tracing::instrument;

Expand Down

0 comments on commit 7417485

Please sign in to comment.