fix(BE-273): add object nonstock and supplier in response get one and fix name base to relation in dto

This commit is contained in:
Hafizh A. Y
2025-11-20 14:59:50 +07:00
parent b4b860b9d4
commit 228aedc215
64 changed files with 964 additions and 3576 deletions
@@ -57,7 +57,7 @@ func (r *NonstockRepositoryImpl) SyncSuppliersDiff(ctx context.Context, tx *gorm
existingMap := make(map[uint]struct{}, len(existing))
for _, rel := range existing {
existingMap[rel.SupplierID] = struct{}{}
existingMap[rel.SupplierId] = struct{}{}
}
incomingMap := make(map[uint]struct{}, len(supplierIDs))
@@ -66,16 +66,16 @@ func (r *NonstockRepositoryImpl) SyncSuppliersDiff(ctx context.Context, tx *gorm
if _, exists := existingMap[id]; exists {
continue
}
record := entity.NonstockSupplier{NonstockID: nonstockID, SupplierID: id}
record := entity.NonstockSupplier{NonstockId: nonstockID, SupplierId: id}
if err := db.WithContext(ctx).Create(&record).Error; err != nil {
return err
}
}
for _, rel := range existing {
if _, keep := incomingMap[rel.SupplierID]; !keep {
if _, keep := incomingMap[rel.SupplierId]; !keep {
if err := db.WithContext(ctx).
Where("nonstock_id = ? AND supplier_id = ?", nonstockID, rel.SupplierID).
Where("nonstock_id = ? AND supplier_id = ?", nonstockID, rel.SupplierId).
Delete(&entity.NonstockSupplier{}).
Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {