fix: update user plan and rearrange structur project
This commit is contained in:
@@ -1,28 +1,18 @@
|
||||
package subscribedomain
|
||||
|
||||
import (
|
||||
subscribeplandm "legalgo-BE-go/internal/domain/subscribe_plan_model"
|
||||
subscribeplan "legalgo-BE-go/internal/domain/subscribe_plan"
|
||||
"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"`
|
||||
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"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
SubscribePlan subscribeplandm.SubscribePlan `gorm:"foreignKey:SubscribePlanID;constraint:OnDelete:CASCADE" json:"subscribe_plan"`
|
||||
SubscribePlan subscribeplan.SubscribePlan `gorm:"foreignKey:SubscribePlanID" json:"subscribe_plan"`
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
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"`
|
||||
}
|
||||
@@ -1,12 +1,22 @@
|
||||
package subscribeplandomain
|
||||
|
||||
import "time"
|
||||
|
||||
type SubscribePlan struct {
|
||||
ID string `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type SubscribePlanUpdate struct {
|
||||
Code string `json:"code" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type SubscribePlanReq struct {
|
||||
Code string `json:"code" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
type SubscribePlan struct {
|
||||
ID string `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package subscribeplandm
|
||||
|
||||
// refactored
|
||||
type SubscribePlan struct {
|
||||
ID string `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package userdomain
|
||||
|
||||
import subscribedm "legalgo-BE-go/internal/domain/subscribe_model"
|
||||
import (
|
||||
subscribe "legalgo-BE-go/internal/domain/subscribe"
|
||||
"time"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id"`
|
||||
@@ -9,7 +12,7 @@ type User struct {
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
|
||||
Subscribe subscribedm.Subscribe `gorm:"foreignKey:SubscribeID" json:"subscribe"`
|
||||
Subscribe subscribe.Subscribe `gorm:"foreignKey:SubscribeID" json:"subscribe"`
|
||||
}
|
||||
|
||||
type UserRegister struct {
|
||||
@@ -24,7 +27,7 @@ type UserProfile struct {
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
|
||||
Subscribe subscribedm.Subscribe `gorm:"foreignKey:SubscribeID" json:"subscribe"`
|
||||
Subscribe subscribe.Subscribe `gorm:"foreignKey:SubscribeID" json:"subscribe"`
|
||||
}
|
||||
|
||||
type UserLogin struct {
|
||||
@@ -33,5 +36,10 @@ type UserLogin struct {
|
||||
}
|
||||
|
||||
type UserSubsUpdate struct {
|
||||
Status string `json:"status"`
|
||||
ID string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
SubscribePlanID string `json:"subscribe_plan_id"`
|
||||
AutoRenew bool `json:"auto_renew"`
|
||||
StartDate time.Time `json:"start_date"`
|
||||
EndDate *time.Time `json:"end_date"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user