Erweiterung der Produktpflege
This commit is contained in:
@@ -16,37 +16,37 @@ func NewBomService(bomRepo *repositories.BomRepository) *BomService {
|
||||
}
|
||||
}
|
||||
|
||||
func (bs *BomService) GetBOMByProductID(productID int) ([]models.BillOfMaterial, error) {
|
||||
func (bs *BomService) GetBOMByProductID(productID int) (*models.BillOfMaterial, error) {
|
||||
bomData, err := bs.bomRepository.GetBOMByProductID(productID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve BOM data: %w", err)
|
||||
}
|
||||
return bomData, nil
|
||||
return &bomData, nil
|
||||
}
|
||||
|
||||
func (bs *BomService) CreateBillOfMaterial(bom *models.BillOfMaterial) error {
|
||||
func (bs *BomService) CreateBillOfMaterial(bom *models.BillOfMaterial) (*models.BillOfMaterial, error) {
|
||||
// Validate the BOM data
|
||||
if bom.ProductID <= 0 {
|
||||
return fmt.Errorf("invalid product ID")
|
||||
return nil, fmt.Errorf("invalid product ID")
|
||||
}
|
||||
|
||||
// Create the BOM in the repository
|
||||
err := bs.bomRepository.CreateBillOfMaterial(bom)
|
||||
createdBOM, err := bs.bomRepository.CreateBillOfMaterial(bom)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create BOM: %w", err)
|
||||
return nil, fmt.Errorf("failed to create BOM: %w", err)
|
||||
}
|
||||
return nil
|
||||
return &createdBOM, nil
|
||||
}
|
||||
|
||||
func (bs *BomService) GetBOMProductsByBOMId(bomId int64) ([]models.Product, error) {
|
||||
products, err := bs.bomRepository.GetBOMProductsByBOMId(bomId)
|
||||
func (bs *BomService) GetBOMContentByBOMId(bomId int) ([]models.BOMContent, error) {
|
||||
contents, err := bs.bomRepository.GetBOMContentByBOMId(bomId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve BOM products: %w", err)
|
||||
return nil, fmt.Errorf("failed to retrieve BOM contents: %w", err)
|
||||
}
|
||||
return products, nil
|
||||
return contents, nil
|
||||
}
|
||||
|
||||
func (bs *BomService) GetBOMVariantNodesByBOMId(bomId int64) ([]models.VariantNode, error) {
|
||||
func (bs *BomService) GetBOMVariantNodesByBOMId(bomId int) ([]models.VariantNode, error) {
|
||||
variantNodes, err := bs.bomRepository.GetBOMVariantNodesByBOMId(bomId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve BOM variant nodes: %w", err)
|
||||
@@ -57,31 +57,31 @@ func (bs *BomService) GetBOMVariantNodesByBOMId(bomId int64) ([]models.VariantNo
|
||||
func (bs *BomService) CreateVariantNode(variantNode *models.VariantNode) (*models.VariantNode, error) {
|
||||
|
||||
// Create the VariantNode in the repository
|
||||
variantNode, err := bs.bomRepository.CreateVariantNode(variantNode)
|
||||
variantNode2, err := bs.bomRepository.CreateVariantNode(variantNode)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create VariantNode: %w", err)
|
||||
}
|
||||
return variantNode, nil
|
||||
return &variantNode2, nil
|
||||
}
|
||||
|
||||
func (bs *BomService) GetVariantNodeByID(id int64) (*models.VariantNode, error) {
|
||||
func (bs *BomService) GetVariantNodeByID(id int) (*models.VariantNode, error) {
|
||||
variantNode, err := bs.bomRepository.GetVariantNodeByID(id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve VariantNode: %w", err)
|
||||
}
|
||||
return variantNode, nil
|
||||
return &variantNode, nil
|
||||
}
|
||||
|
||||
func (bs *BomService) UpdateVariantNode(variantNode *models.VariantNode) error {
|
||||
func (bs *BomService) UpdateVariantNode(variantNode *models.VariantNode) (*models.VariantNode, error) {
|
||||
// Update the VariantNode in the repository
|
||||
err := bs.bomRepository.UpdateVariantNode(variantNode)
|
||||
variantNode2, err := bs.bomRepository.UpdateVariantNode(variantNode)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update VariantNode: %w", err)
|
||||
return nil, fmt.Errorf("failed to update VariantNode: %w", err)
|
||||
}
|
||||
return nil
|
||||
return &variantNode2, nil
|
||||
}
|
||||
|
||||
func (bs *BomService) DeleteVariantNode(id int64) error {
|
||||
func (bs *BomService) DeleteVariantNode(id int) error {
|
||||
// Delete the VariantNode in the repository
|
||||
err := bs.bomRepository.DeleteVariantNode(id)
|
||||
if err != nil {
|
||||
@@ -90,32 +90,32 @@ func (bs *BomService) DeleteVariantNode(id int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bs *BomService) GetVariantNode(parentID int64) ([]models.VariantNode, error) {
|
||||
variantNodes, err := bs.bomRepository.GetVariantNode(parentID)
|
||||
func (bs *BomService) GetVariantNode(id int) (*models.VariantNode, error) {
|
||||
variantNode, err := bs.bomRepository.GetVariantNode(id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve VariantNodes: %w", err)
|
||||
return nil, fmt.Errorf("failed to retrieve VariantNode: %w", err)
|
||||
}
|
||||
return variantNodes, nil
|
||||
return &variantNode, nil
|
||||
}
|
||||
|
||||
func (bs *BomService) GetVariantNodeProductsByVariantNodeId(parentID int64) ([]models.Product, error) {
|
||||
products, err := bs.bomRepository.GetVariantNodeProductsByVariantNodeId(parentID)
|
||||
func (bs *BomService) GetVariantNodeProductsByVariantNodeId(id int) ([]models.Product, error) {
|
||||
products, err := bs.bomRepository.GetVariantNodeProductsByVariantNodeId(id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve VariantNode products: %w", err)
|
||||
}
|
||||
return products, nil
|
||||
}
|
||||
|
||||
func (bs *BomService) UpdateBillOfMaterial(bom *models.BillOfMaterial) error {
|
||||
func (bs *BomService) UpdateBillOfMaterial(bom *models.BillOfMaterial) (*models.BillOfMaterial, error) {
|
||||
// Update the BOM in the repository
|
||||
err := bs.bomRepository.UpdateBillOfMaterial(bom)
|
||||
bom2, err := bs.bomRepository.UpdateBillOfMaterial(bom)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update BOM: %w", err)
|
||||
return nil, fmt.Errorf("failed to update BOM: %w", err)
|
||||
}
|
||||
return nil
|
||||
return &bom2, nil
|
||||
}
|
||||
|
||||
func (bs *BomService) DeleteBillOfMaterial(id int64) error {
|
||||
func (bs *BomService) DeleteBillOfMaterial(id int) error {
|
||||
// Delete the BOM in the repository
|
||||
err := bs.bomRepository.DeleteBillOfMaterial(id)
|
||||
if err != nil {
|
||||
@@ -124,10 +124,10 @@ func (bs *BomService) DeleteBillOfMaterial(id int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bs *BomService) GetBillOfMaterial(id int64) (*models.BillOfMaterial, error) {
|
||||
func (bs *BomService) GetBillOfMaterial(id int) (*models.BillOfMaterial, error) {
|
||||
bom, err := bs.bomRepository.GetBillOfMaterial(id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve BOM: %w", err)
|
||||
}
|
||||
return bom, nil
|
||||
return &bom, nil
|
||||
}
|
||||
|
||||
@@ -87,6 +87,10 @@ func (vs *ValueService) CreateValueForPropertyId(propertyId int, value *models.V
|
||||
return vs.valueRepository.CreateValueForPropertyId(propertyId, value)
|
||||
}
|
||||
|
||||
func (vs *ValueService) UpdateValue(value *models.Value) error {
|
||||
return vs.valueRepository.UpdateValue(value)
|
||||
}
|
||||
|
||||
func (vs *ValueService) GetValue(id int) (*models.Value, error) {
|
||||
return vs.valueRepository.GetValue(id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user