mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Feat[BE-222]: add marketing product to get all marketing for Frontend needs
This commit is contained in:
@@ -24,6 +24,7 @@ type MarketingListDTO struct {
|
||||
Customer *customerDTO.CustomerBaseDTO `json:"customer,omitempty"`
|
||||
SalesPerson *userDTO.UserBaseDTO `json:"sales_person,omitempty"`
|
||||
SoDocs string `json:"so_docs,omitempty"`
|
||||
SalesOrder []MarketingProductDTO `json:"sales_order,omitempty"`
|
||||
CreatedUser *userDTO.UserBaseDTO `json:"created_user"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
@@ -154,11 +155,20 @@ func ToMarketingListDTO(marketing *entity.Marketing, deliveryProducts []entity.M
|
||||
latestApproval = &mapped
|
||||
}
|
||||
|
||||
var salesOrderProducts []MarketingProductDTO
|
||||
if len(marketing.Products) > 0 {
|
||||
salesOrderProducts = make([]MarketingProductDTO, len(marketing.Products))
|
||||
for i, product := range marketing.Products {
|
||||
salesOrderProducts[i] = ToMarketingProductDTO(product)
|
||||
}
|
||||
}
|
||||
|
||||
return MarketingListDTO{
|
||||
MarketingBaseDTO: ToMarketingBaseDTO(marketing),
|
||||
Customer: customer,
|
||||
SalesPerson: salesPerson,
|
||||
SoDocs: marketing.SoDocs,
|
||||
SalesOrder: salesOrderProducts,
|
||||
CreatedUser: createdUser,
|
||||
CreatedAt: marketing.CreatedAt,
|
||||
UpdatedAt: marketing.UpdatedAt,
|
||||
|
||||
@@ -97,7 +97,10 @@ func (s deliveryOrdersService) GetAll(c *fiber.Ctx, params *validation.Query) ([
|
||||
Preload("CreatedUser").
|
||||
Preload("Customer").
|
||||
Preload("SalesPerson").
|
||||
Preload("Products.ProductWarehouse")
|
||||
Preload("Products.ProductWarehouse.Product").
|
||||
Preload("Products.ProductWarehouse.Warehouse").
|
||||
Preload("Products.DeliveryProduct")
|
||||
|
||||
if params.MarketingId != 0 {
|
||||
return db.Where("id = ?", params.MarketingId)
|
||||
}
|
||||
@@ -109,7 +112,9 @@ func (s deliveryOrdersService) GetAll(c *fiber.Ctx, params *validation.Query) ([
|
||||
return nil, 0, err
|
||||
}
|
||||
for i := range marketings {
|
||||
latestApproval, err := s.ApprovalSvc.LatestByTarget(c.Context(), utils.ApprovalWorkflowMarketing, marketings[i].Id, nil)
|
||||
latestApproval, err := s.ApprovalSvc.LatestByTarget(c.Context(), utils.ApprovalWorkflowMarketing, marketings[i].Id, func(db *gorm.DB) *gorm.DB {
|
||||
return db.Preload("ActionUser")
|
||||
})
|
||||
if err != nil {
|
||||
s.Log.Warnf("Failed to load approval for marketing %d: %+v", marketings[i].Id, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user