-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from Enraged-Dun-Cookie-Development-Team/feat…
…/tool-link 增加 tool_link 的 crud
- Loading branch information
Showing
38 changed files
with
736 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod tool_link; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use std::ops::Deref; | ||
|
||
use db_ops_prelude::database_operates::sub_operate::{ | ||
SubOperate, SuperOperate, | ||
}; | ||
|
||
use crate::OperationDatabaseOperate; | ||
|
||
pub struct ToolLinkOperate<'c, C>(&'c C); | ||
|
||
impl<'c, C> Deref for ToolLinkOperate<'c, C> { | ||
type Target = C; | ||
|
||
fn deref(&self) -> &Self::Target { self.0 } | ||
} | ||
|
||
impl<'c, C> SubOperate<'c> for ToolLinkOperate<'c, C> { | ||
type Parent = OperationDatabaseOperate<'c, C>; | ||
|
||
fn from_parent(parent: &'c Self::Parent) -> Self { Self(parent) } | ||
} | ||
|
||
impl<'db, Conn> OperationDatabaseOperate<'db, Conn> { | ||
pub fn tool_link(&self) -> ToolLinkOperate<'_, Conn> { self.child() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
persistence/dao/ceobe-operate/src/mongo/tool_link/create.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use db_ops_prelude::mongo_connection::MongoDbCollectionTrait; | ||
use tracing::instrument; | ||
|
||
use super::{OperateResult, ToolLinkOperate}; | ||
use crate::tool_link_mongodb::models::ToolLink; | ||
|
||
impl<'db, Conn> ToolLinkOperate<'db, Conn> | ||
where | ||
Conn: MongoDbCollectionTrait<'db, ToolLink>, | ||
{ | ||
#[instrument(skip(self))] | ||
pub async fn create(&'db self, tool_link: ToolLink) -> OperateResult<()> { | ||
let db = self.get_collection()?; | ||
|
||
db.doing(|collection| collection.insert_one(tool_link, None)) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
persistence/dao/ceobe-operate/src/mongo/tool_link/delete.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use db_ops_prelude::{ | ||
mongo_connection::MongoDbCollectionTrait, | ||
mongodb::bson::{doc, Uuid}, | ||
}; | ||
use tracing::instrument; | ||
|
||
use super::{OperateResult, ToolLinkOperate}; | ||
use crate::tool_link_mongodb::models::ToolLink; | ||
|
||
impl<'db, Conn> ToolLinkOperate<'db, Conn> | ||
where | ||
Conn: MongoDbCollectionTrait<'db, ToolLink>, | ||
{ | ||
#[instrument(skip(self))] | ||
pub async fn delete(&'db self, id: Uuid) -> OperateResult<()> { | ||
let db = self.get_collection()?; | ||
|
||
db.doing(|collection| collection.delete_one(doc! {"id": id}, None)) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.