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); return Err(ImageError::UnsupportedMimeType);
} }
let mime_type = image.mime_type.clone();
let id = self let id = self
.upload_image_use_case .upload_image_use_case
.execute(image.to_entity()) .execute(image.into_entity())
.await?; .await?;
Ok(ImageInfoResponseDto { Ok(ImageInfoResponseDto {
id: id, id: id,
mime_type: image.mime_type, mime_type: mime_type,
}) })
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ pub struct PostInfoMapper {
} }
impl PostInfoMapper { impl PostInfoMapper {
pub fn to_entity(&self) -> PostInfo { pub fn into_entity(self) -> PostInfo {
PostInfo { PostInfo {
id: self.id, id: self.id,
title: self.title.clone(), title: self.title.clone(),
@ -21,7 +21,7 @@ impl PostInfoMapper {
published_time: self published_time: self
.published_time .published_time
.map(|dt| DateTime::<Utc>::from_naive_utc_and_offset(dt, Utc)), .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| { .map(|mappers| {
mappers mappers
.into_iter() .into_iter()
.map(|mapper| mapper.to_entity()) .map(|mapper| mapper.into_entity())
.collect::<Vec<PostInfo>>() .collect::<Vec<PostInfo>>()
}) })
} }
@ -37,6 +37,6 @@ impl PostRepository for PostRepositoryImpl {
self.post_db_service self.post_db_service
.get_full_post(id) .get_full_post(id)
.await .await
.map(|mapper| mapper.to_entity()) .map(|mapper| mapper.into_entity())
} }
} }