Add User Partner and Product
This commit is contained in:
@@ -26,6 +26,36 @@ type Partner struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type CreatePartnerRequest struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
Address string `json:"address"`
|
||||
Username string `json:"username" validate:"required"`
|
||||
FullName string `json:"full_name"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
NIK string `json:"nik"`
|
||||
PhoneNumber string `json:"phone_number"`
|
||||
BankName string `json:"bank_name"`
|
||||
BankAccountNumber string `json:"bank_account_number"`
|
||||
BankAccountHolderName string `json:"bank_account_holder_name"`
|
||||
}
|
||||
|
||||
func (e *CreatePartnerRequest) ToEntity() *entity.CreatePartnerRequest {
|
||||
return &entity.CreatePartnerRequest{
|
||||
Name: e.Name,
|
||||
Address: e.Address,
|
||||
Username: e.Username,
|
||||
FullName: e.FullName,
|
||||
Email: e.Email,
|
||||
Password: e.Password,
|
||||
NIK: e.NIK,
|
||||
PhoneNumber: e.PhoneNumber,
|
||||
BankName: e.BankName,
|
||||
BankAccountNumber: e.BankAccountNumber,
|
||||
BankAccountHolderName: e.BankAccountHolderName,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Partner) ToEntity() *entity.Partner {
|
||||
return &entity.Partner{
|
||||
Name: e.Name,
|
||||
|
||||
@@ -28,14 +28,15 @@ func (p *ProductParam) ToEntity() entity.ProductSearch {
|
||||
}
|
||||
|
||||
type Product struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
Type product.ProductType `json:"type" validate:"required"`
|
||||
Price float64 `json:"price" validate:"required"`
|
||||
Status product.ProductStatus `json:"status" validate:"required"`
|
||||
Description string `json:"description" `
|
||||
Image string `json:"image" `
|
||||
BranchID int64 `json:"branch_id" validate:"required"`
|
||||
StockQty int64 `json:"stock_qty" `
|
||||
ID int64 `json:"id,omitempty"`
|
||||
PartnerID int64 `json:"partner_id"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Type string `json:"type"`
|
||||
Price float64 `json:"price" validate:"required"`
|
||||
IsWeekendTicket bool `json:"is_weekend_ticket"`
|
||||
IsSeasonTicket bool `json:"is_season_ticket"`
|
||||
Status string `json:"status"`
|
||||
Description string `json:"description" validate:"required"`
|
||||
}
|
||||
|
||||
func (e *Product) ToEntity() *entity.Product {
|
||||
@@ -45,8 +46,5 @@ func (e *Product) ToEntity() *entity.Product {
|
||||
Price: e.Price,
|
||||
Status: e.Status,
|
||||
Description: e.Description,
|
||||
Image: e.Image,
|
||||
BranchID: e.BranchID,
|
||||
StockQty: e.StockQty,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"furtuna-be/internal/entity"
|
||||
)
|
||||
|
||||
type Site struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
PartnerID *int64 `json:"partner_id"`
|
||||
Image string `json:"image"`
|
||||
Address string `json:"address"`
|
||||
LocationLink string `json:"location_link"`
|
||||
Description string `json:"description"`
|
||||
Highlight string `json:"highlight"`
|
||||
ContactPerson string `json:"contact_person"`
|
||||
TnC string `json:"tnc"`
|
||||
AdditionalInfo string `json:"additional_info"`
|
||||
Status string `json:"status"`
|
||||
IsSeasonTicket bool `json:"is_season_ticket"`
|
||||
IsDiscountActive bool `json:"is_discount_active"`
|
||||
Products []Product `json:"products"`
|
||||
}
|
||||
|
||||
func (r *Site) ToEntity(createdBy int64) *entity.Site {
|
||||
var products []entity.Product
|
||||
for _, p := range r.Products {
|
||||
products = append(products, entity.Product{
|
||||
ID: p.ID,
|
||||
PartnerID: *r.PartnerID,
|
||||
Name: p.Name,
|
||||
Type: p.Type,
|
||||
Price: p.Price,
|
||||
IsWeekendTicket: p.IsWeekendTicket,
|
||||
IsSeasonTicket: p.IsSeasonTicket,
|
||||
Status: p.Status,
|
||||
Description: p.Description,
|
||||
CreatedBy: createdBy,
|
||||
})
|
||||
}
|
||||
|
||||
return &entity.Site{
|
||||
ID: r.ID,
|
||||
Name: r.Name,
|
||||
PartnerID: *r.PartnerID,
|
||||
Image: r.Image,
|
||||
Address: r.Address,
|
||||
LocationLink: r.LocationLink,
|
||||
Description: r.Description,
|
||||
Highlight: r.Highlight,
|
||||
ContactPerson: r.ContactPerson,
|
||||
TnC: r.TnC,
|
||||
AdditionalInfo: r.AdditionalInfo,
|
||||
Status: r.Status,
|
||||
IsSeasonTicket: r.IsSeasonTicket,
|
||||
IsDiscountActive: r.IsDiscountActive,
|
||||
Products: products,
|
||||
}
|
||||
}
|
||||
|
||||
type SiteParam struct {
|
||||
Search string `form:"search"`
|
||||
Name string `form:"name"`
|
||||
Limit int `form:"limit,default=10"`
|
||||
Offset int `form:"offset,default=0"`
|
||||
}
|
||||
|
||||
func (r *SiteParam) ToEntity() entity.SiteSearch {
|
||||
return entity.SiteSearch{
|
||||
Search: r.Search,
|
||||
Name: r.Name,
|
||||
Limit: r.Limit,
|
||||
Offset: r.Offset,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user