BLOG-78 refactor: rename to_entity methods to into_entity for consistency
All checks were successful
PR Title Check / pr-title-check (pull_request) Successful in 16s
Frontend CI / build (push) Successful in 1m5s

This commit is contained in:
SquidSpirit 2025-07-27 13:04:22 +08:00
parent aaf43f21bd
commit f5c12ce56d
8 changed files with 19 additions and 18 deletions

View File

@ -60,13 +60,14 @@ impl ImageController for ImageControllerImpl {
return Err(ImageError::UnsupportedMimeType);
}
let mime_type = image.mime_type.clone();
let id = self
.upload_image_use_case
.execute(image.to_entity())
.execute(image.into_entity())
.await?;
Ok(ImageInfoResponseDto {
id: id,
mime_type: image.mime_type,
mime_type: mime_type,
})
}

View File

@ -6,11 +6,11 @@ pub struct ImageRequestDto {
}
impl ImageRequestDto {
pub fn to_entity(&self) -> Image {
pub fn into_entity(self) -> Image {
Image {
id: None,
mime_type: self.mime_type.clone(),
data: self.data.clone(),
mime_type: self.mime_type,
data: self.data,
}
}
}

View File

@ -6,10 +6,10 @@ pub struct ImageDbMapper {
}
impl ImageDbMapper {
pub fn to_entity(&self) -> Image {
pub fn into_entity(self) -> Image {
Image {
id: self.id,
mime_type: self.mime_type.clone(),
mime_type: self.mime_type,
data: Vec::new(),
}
}

View File

@ -5,7 +5,7 @@ pub struct ColorMapper {
}
impl ColorMapper {
pub fn to_entity(&self) -> Color {
pub fn into_entity(self) -> Color {
Color {
red: (self.value >> 24) as u8,
green: ((self.value >> 16) & 0xFF) as u8,

View File

@ -7,11 +7,11 @@ pub struct LabelMapper {
}
impl LabelMapper {
pub fn to_entity(&self) -> Label {
pub fn into_entity(self) -> Label {
Label {
id: self.id,
name: self.name.clone(),
color: self.color.to_entity(),
name: self.name,
color: self.color.into_entity(),
}
}
}

View File

@ -7,11 +7,11 @@ pub struct PostMapper {
}
impl PostMapper {
pub fn to_entity(&self) -> Post {
pub fn into_entity(self) -> Post {
Post {
id: self.id,
info: self.info.to_entity(),
content: self.content.clone(),
info: self.info.into_entity(),
content: self.content,
}
}
}

View File

@ -12,7 +12,7 @@ pub struct PostInfoMapper {
}
impl PostInfoMapper {
pub fn to_entity(&self) -> PostInfo {
pub fn into_entity(self) -> PostInfo {
PostInfo {
id: self.id,
title: self.title.clone(),
@ -21,7 +21,7 @@ impl PostInfoMapper {
published_time: self
.published_time
.map(|dt| DateTime::<Utc>::from_naive_utc_and_offset(dt, Utc)),
labels: self.labels.iter().map(LabelMapper::to_entity).collect(),
labels: self.labels.into_iter().map(LabelMapper::into_entity).collect(),
}
}
}

View File

@ -28,7 +28,7 @@ impl PostRepository for PostRepositoryImpl {
.map(|mappers| {
mappers
.into_iter()
.map(|mapper| mapper.to_entity())
.map(|mapper| mapper.into_entity())
.collect::<Vec<PostInfo>>()
})
}
@ -37,6 +37,6 @@ impl PostRepository for PostRepositoryImpl {
self.post_db_service
.get_full_post(id)
.await
.map(|mapper| mapper.to_entity())
.map(|mapper| mapper.into_entity())
}
}