mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
refac: mappers, file names
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
package article
|
||||
|
||||
import (
|
||||
domain "RenewCMS/internal/domain/image"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Article struct {
|
||||
ID uint32 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Images []*domain.Image `json:"images"`
|
||||
IsOnline bool `json:"is_online"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func FromApi(
|
||||
title string,
|
||||
body string,
|
||||
) Article {
|
||||
return Article{
|
||||
Title: title,
|
||||
Body: body,
|
||||
}
|
||||
}
|
||||
|
||||
func FromDb(
|
||||
id uint32,
|
||||
title string,
|
||||
body string,
|
||||
images []*domain.Image,
|
||||
isOnline bool,
|
||||
createdAt time.Time,
|
||||
updatedAt time.Time,
|
||||
) Article {
|
||||
return Article{
|
||||
ID: id,
|
||||
Title: title,
|
||||
Body: body,
|
||||
Images: images,
|
||||
IsOnline: isOnline,
|
||||
CreatedAt: createdAt,
|
||||
UpdatedAt: updatedAt,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package article
|
||||
|
||||
import (
|
||||
domain "RenewCMS/internal/domain/image"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Article struct {
|
||||
ID uint32 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Images []*domain.Image `json:"images"`
|
||||
IsOnline bool `json:"is_online"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
@@ -11,13 +11,3 @@ type Image struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func FromDB(id uint32, path string, articleId uint32, createdAt time.Time, updatedAt time.Time) Image {
|
||||
return Image{
|
||||
ID: id,
|
||||
Path: path,
|
||||
ArticleID: articleId,
|
||||
CreatedAt: createdAt,
|
||||
UpdatedAt: updatedAt,
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID uint32 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
PasswordResetCode string `json:"password_reset_code"`
|
||||
Email string `json:"email"`
|
||||
IsVerified bool `json:"is_verified"`
|
||||
VerificationCode string `json:"verification_code"`
|
||||
VerificationExpiration time.Time `json:"verification_expiration"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func FromApi(
|
||||
username string,
|
||||
password string,
|
||||
passwordResetCode string,
|
||||
email string,
|
||||
verificationCode string,
|
||||
) User {
|
||||
expiration := time.Now().Add(2 * time.Hour)
|
||||
return User{
|
||||
Username: username,
|
||||
Password: password,
|
||||
PasswordResetCode: passwordResetCode,
|
||||
Email: email,
|
||||
IsVerified: false,
|
||||
VerificationCode: verificationCode,
|
||||
VerificationExpiration: expiration,
|
||||
}
|
||||
}
|
||||
|
||||
func FromDb(
|
||||
id uint32,
|
||||
username string,
|
||||
password string,
|
||||
passwordResetCode string,
|
||||
email string,
|
||||
isVerified bool,
|
||||
verificationCode string,
|
||||
verificationExpiration time.Time,
|
||||
createdAt time.Time,
|
||||
updatedAt time.Time,
|
||||
) User {
|
||||
return User{
|
||||
ID: id,
|
||||
Username: username,
|
||||
Password: password,
|
||||
PasswordResetCode: passwordResetCode,
|
||||
Email: email,
|
||||
IsVerified: isVerified,
|
||||
VerificationCode: verificationCode,
|
||||
VerificationExpiration: verificationExpiration,
|
||||
CreatedAt: createdAt,
|
||||
UpdatedAt: updatedAt,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID uint32 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
PasswordResetCode string `json:"password_reset_code"`
|
||||
Email string `json:"email"`
|
||||
IsVerified bool `json:"is_verified"`
|
||||
VerificationCode string `json:"verification_code"`
|
||||
VerificationExpiration time.Time `json:"verification_expiration"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
Reference in New Issue
Block a user