chores: refactor struct and structure project
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
package authdomain
|
||||
|
||||
type LoginReq struct {
|
||||
Email string `json:"email" validate:"required"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
}
|
||||
|
||||
type AuthResponse struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type LoginRepoResponse struct {
|
||||
ID string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type StaffProfile struct {
|
||||
ID string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
ProfilePicture string `json:"profile_picture"`
|
||||
}
|
||||
|
||||
type UserProfile struct {
|
||||
ID string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
SubscribePlanCode string `json:"subscribe_plan_code"`
|
||||
SubscribePlanName string `json:"subscribe_plan_name"`
|
||||
SubscribeStatus string `json:"subscribe_status"`
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package authdomain
|
||||
|
||||
type RegisterUserReq struct {
|
||||
Email string `json:"email" validate:"required"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
Phone string `json:"phone" validate:"required"`
|
||||
SubscribePlanID string `json:"subscribe_plan_id"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Phone string `json:"phone"`
|
||||
SubscribeID string `json:"subscribe_id"`
|
||||
}
|
||||
|
||||
type RegisterStaffReq struct {
|
||||
Email string `json:"email" validate:"required"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
ProfilePicture string `json:"profile_picture"`
|
||||
}
|
||||
|
||||
type UpdateStaffReq struct {
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Staff struct {
|
||||
ID string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Name string `json:"name"`
|
||||
ProfilePicture string `json:"profile_picture"`
|
||||
}
|
||||
@@ -3,4 +3,5 @@ package authdomain
|
||||
type AuthToken struct {
|
||||
Email string
|
||||
SessionID string
|
||||
Role string
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package categorydomain
|
||||
|
||||
import "time"
|
||||
|
||||
type Category struct {
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CategoryReq struct {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package newsdomain
|
||||
|
||||
import (
|
||||
categorydomain "legalgo-BE-go/internal/domain/category"
|
||||
"legalgo-BE-go/database"
|
||||
tagdomain "legalgo-BE-go/internal/domain/tag"
|
||||
"time"
|
||||
)
|
||||
@@ -17,16 +17,16 @@ type NewsReq struct {
|
||||
}
|
||||
|
||||
type News struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
FeaturedImage string `json:"featured_image"`
|
||||
Tags []tagdomain.Tag `json:"tags"`
|
||||
Categories []categorydomain.Category `json:"categories"`
|
||||
IsPremium bool `json:"is_premium"`
|
||||
Slug string `json:"slug"`
|
||||
AuthorID string `json:"author_id"`
|
||||
LiveAt time.Time `json:"live_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
FeaturedImage string `json:"featured_image"`
|
||||
Tags []tagdomain.Tag `json:"tags"`
|
||||
Categories []database.Category `json:"categories"`
|
||||
IsPremium bool `json:"is_premium"`
|
||||
Slug string `json:"slug"`
|
||||
AuthorID string `json:"author_id"`
|
||||
LiveAt time.Time `json:"live_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package responsedomain
|
||||
|
||||
type Auth struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package staffdomain
|
||||
|
||||
type Staff struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ProfilePicture string `json:"profile_picture"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type StaffRegister struct {
|
||||
Email string `json:"email" validate:"required"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
ProfilePicture string `json:"profile_picture"`
|
||||
}
|
||||
|
||||
type StaffProfile struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ProfilePicture string `json:"profile_picture"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
type StaffLogin struct {
|
||||
Email string `json:"email" validate:"required"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
}
|
||||
@@ -1,6 +1,28 @@
|
||||
package subscribedomain
|
||||
|
||||
type Subscribe struct {
|
||||
import (
|
||||
subscribeplandm "legalgo-BE-go/internal/domain/subscribe_plan_model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SubscribeDepecrate struct {
|
||||
ID string `json:"id"`
|
||||
SubscribePlanID string `json:"subscribe_plan_id"`
|
||||
}
|
||||
|
||||
type SubscribeUpdateReqDepecrate struct {
|
||||
ID string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// refactored
|
||||
type Subscribe struct {
|
||||
ID string `gorm:"primaryKey" json:"id"`
|
||||
SubscribePlanID string `gorm:"not null" json:"subscribe_plan_id"`
|
||||
StartDate time.Time `gorm:"default:CURRENT_TIMESTAMP"`
|
||||
EndDate time.Time `gorm:"default:null"`
|
||||
Status string `gorm:"default:'inactive'"`
|
||||
AutoRenew bool `gorm:"default:true"`
|
||||
|
||||
SubscribePlan subscribeplandm.SubscribePlan `gorm:"foreignKey:SubscribePlanID;constraint:OnDelete:CASCADE" json:"subscribe_plan"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package subscribedm
|
||||
|
||||
import (
|
||||
subscribeplandm "legalgo-BE-go/internal/domain/subscribe_plan_model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Subscribe struct {
|
||||
ID string `json:"id"`
|
||||
SubscribePlanID string `json:"subscribe_plan_id"`
|
||||
StartDate time.Time `json:"start_date"`
|
||||
EndDate *time.Time `json:"end_date"`
|
||||
Status string `json:"status"`
|
||||
AutoRenew bool `json:"auto_renew"`
|
||||
|
||||
SubscribePlan subscribeplandm.SubscribePlan `gorm:"foreignKey:SubscribePlanID" json:"subscribe_plan"`
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package subscribeplandm
|
||||
|
||||
// refactored
|
||||
type SubscribePlan struct {
|
||||
ID string `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package userdomain
|
||||
|
||||
import subscribedm "legalgo-BE-go/internal/domain/subscribe_model"
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id"`
|
||||
SubscribeID string `json:"subscribe_id"`
|
||||
Password string `json:"password"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
|
||||
Subscribe subscribedm.Subscribe `gorm:"foreignKey:SubscribeID" json:"subscribe"`
|
||||
}
|
||||
|
||||
type UserRegister struct {
|
||||
Email string `json:"email" validate:"required"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
Phone string `json:"phone" validate:"required"`
|
||||
SubscribePlanID string `json:"subscribe_plan_id"`
|
||||
}
|
||||
|
||||
type UserProfile struct {
|
||||
ID string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
|
||||
Subscribe subscribedm.Subscribe `gorm:"foreignKey:SubscribeID" json:"subscribe"`
|
||||
}
|
||||
|
||||
type UserLogin struct {
|
||||
Email string `json:"email" validate:"required"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
}
|
||||
|
||||
type UserSubsUpdate struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
Reference in New Issue
Block a user