Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-06-02 16:14:54 +03:00
parent 5f3e975b6d
commit b4e87cfd47
25 changed files with 4918 additions and 287 deletions

View File

@@ -6,6 +6,7 @@ import (
"bssapp-backend/internal/mailer"
"bssapp-backend/middlewares"
"bssapp-backend/permissions"
"bssapp-backend/queries"
"bssapp-backend/repository"
"bssapp-backend/routes"
"bssapp-backend/utils"
@@ -109,6 +110,12 @@ func autoRegisterRouteV3(
// 2) MODULE LOOKUP AUTO SEED (permission ekranları için)
moduleLabel := strings.TrimSpace(strings.ReplaceAll(module, "_", " "))
switch strings.ToLower(strings.TrimSpace(module)) {
case "pricing":
moduleLabel = "Ürün Fiyatlandırma"
case "costing":
moduleLabel = "Ürün Maliyetlendirme"
}
if moduleLabel == "" {
moduleLabel = module
}
@@ -460,6 +467,16 @@ func InitRoutes(pgDB *sql.DB, mssql *sql.DB, ml *mailer.GraphMailer) *mux.Router
"system", "update",
wrapV3(http.HandlerFunc(rdHandler.Save)),
)
bindV3(r, pgDB,
"/api/roles/{roleId}/departments/{deptCode}/members", "GET",
"system", "update",
wrapV3(http.HandlerFunc(rdHandler.Members)),
)
bindV3(r, pgDB,
"/api/roles/{roleId}/departments/{deptCode}/members", "POST",
"system", "update",
wrapV3(http.HandlerFunc(rdHandler.AddMember)),
)
// ============================================================
// USERS
@@ -770,167 +787,217 @@ func InitRoutes(pgDB *sql.DB, mssql *sql.DB, ml *mailer.GraphMailer) *mux.Router
)
bindV3(r, pgDB,
"/api/pricing/products", "GET",
"order", "view",
"pricing", "view",
wrapV3(http.HandlerFunc(routes.GetProductPricingListHandler)),
)
bindV3(r, pgDB,
"/api/pricing/products/options", "GET",
"pricing", "view",
wrapV3(http.HandlerFunc(routes.GetProductPricingFilterOptionsHandler)),
)
bindV3(r, pgDB,
"/api/pricing/brand-classification/lookups", "GET",
"pricing", "view",
wrapV3(routes.GetBrandClassificationLookupsHandler(pgDB)),
)
bindV3(r, pgDB,
"/api/pricing/brand-classification/brands", "GET",
"pricing", "view",
wrapV3(routes.ListBrandsHandler(pgDB)),
)
bindV3(r, pgDB,
"/api/pricing/brand-classification/brands/sync", "POST",
"pricing", "update",
wrapV3(routes.SyncBrandsFromMSSQLHandler(pgDB)),
)
bindV3(r, pgDB,
"/api/pricing/brand-classification/brand/{code}/group", "POST",
"pricing", "update",
wrapV3(routes.SetBrandGroupHandler(pgDB)),
)
bindV3(r, pgDB,
"/api/pricing/brand-classification/brands/group-bulk", "POST",
"pricing", "update",
wrapV3(routes.SetBrandGroupsBulkHandler(pgDB)),
)
bindV3(r, pgDB,
"/api/pricing/pricing-rules", "GET",
"pricing", "view",
wrapV3(routes.GetPricingRulesHandler(pgDB)),
)
bindV3(r, pgDB,
"/api/pricing/pricing-rules/bulk-save", "POST",
"pricing", "update",
wrapV3(routes.SavePricingRulesBulkHandler(pgDB)),
)
bindV3(r, pgDB,
"/api/pricing/pricing-rules/options", "GET",
"pricing", "view",
wrapV3(routes.GetPricingRuleOptionsHandler(pgDB)),
)
bindV3(r, pgDB,
"/api/pricing/pricing-rules/parameters", "GET",
"pricing", "view",
wrapV3(routes.GetPricingParameterRulesHandler(pgDB)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/no-cost-products", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionNoCostProductsHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/has-cost-products", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionHasCostProductsHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/has-cost-history", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionHasCostHistoryHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/has-cost-detail-groups", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionHasCostDetailGroupsHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/has-cost-detail-header", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionHasCostDetailHeaderHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/production-types", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionTypesHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/detail-editor-options", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionHasCostDetailEditorOptionsHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/has-cost-detail-exchange-rates", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionHasCostDetailExchangeRatesHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/has-cost-detail-line-history", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionHasCostDetailLineHistoryHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/has-cost-detail-similar-history", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionHasCostDetailSimilarHistoryHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/has-cost-detail-bulk-prices", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionHasCostDetailBulkPricesHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/has-cost-detail/last-detail", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingHasCostDetailLastDetailHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/options/hammadde-by-nos", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingOptionsHammaddeByNosHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/onml/save", "POST",
"order", "view",
"costing", "view",
wrapV3(routes.PostProductionProductCostingOnMLSaveHandlerWithMailer(ml)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/onml/pdf", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionProductCostingOnMLPDFHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/onml/delete", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingOnMLDeleteHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/default-quantities", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionProductCostingDefaultQuantitiesHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/default-quantities/upsert", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingDefaultQuantitiesUpsertHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/default-quantities/update-bulk", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingDefaultQuantitiesBulkUpdateHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/default-quantities/calc-avg", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingDefaultQuantitiesCalcAvgHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/default-quantities/lookup", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingDefaultQuantitiesLookupHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/default-quantities/refresh", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingDefaultQuantitiesRefreshHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/tbstok/exists-bulk", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingTbStokExistsBulkHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/last10-warnings", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionProductCostingLast10WarningsHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/options/urun-ana-grup", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionProductCostingUrunAnaGrupOptionsHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/options/urun-alt-grup", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionProductCostingUrunAltGrupOptionsHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/options/urun-ana-alt-combos", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionProductCostingUrunAnaAltCombosHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/options/mtbolum", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionProductCostingMTBolumOptionsHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/maliyet-parca-eslestirme", "GET",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.GetProductionProductCostingParcaMappingsHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/maliyet-parca-eslestirme", "DELETE",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.DeleteProductionProductCostingParcaMappingHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/maliyet-parca-eslestirme/upsert", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingParcaMappingUpsertHandler)),
)
bindV3(r, pgDB,
"/api/pricing/production-product-costing/maliyet-parca-eslestirme/set-active", "POST",
"order", "view",
"costing", "view",
wrapV3(http.HandlerFunc(routes.PostProductionProductCostingParcaMappingSetActiveHandler)),
)
@@ -1062,6 +1129,20 @@ func main() {
// -------------------------------------------------------
routes.EnsureTranslationPerfIndexes(pgDB)
// -------------------------------------------------------
// 🏷️ BRAND CLASSIFICATION BOOTSTRAP + SYNC SCHEDULER
// -------------------------------------------------------
// Ensure Postgres tables exist even before the UI hits the endpoints.
if err := queries.EnsureBrandClassificationTables(pgDB); err != nil {
log.Println("⚠️ mk_brands bootstrap failed:", err)
}
if err := queries.EnsurePricingRuleTables(pgDB); err != nil {
log.Println("pricing rule tables bootstrap failed:", err)
}
if err := queries.EnsurePricingParameterTables(pgDB); err != nil {
log.Println("mk_urunpricingprmtr bootstrap failed:", err)
}
// -------------------------------------------------------
// ✉️ MAILER INIT
// -------------------------------------------------------
@@ -1081,6 +1162,8 @@ func main() {
// -------------------------------------------------------
router := InitRoutes(pgDB, db.MssqlDB, graphMailer)
startTranslationSyncScheduler(pgDB, db.MssqlDB)
startBrandSyncScheduler(pgDB, db.MssqlDB)
startPricingParameterSyncScheduler(pgDB, db.MssqlDB)
handler := enableCORS(
middlewares.GlobalAuthMiddleware(