package route

import (
	"kpt-tmr-group/http/handler/dashboard"
	"kpt-tmr-group/http/handler/feed"
	"kpt-tmr-group/http/handler/pasture"
	"kpt-tmr-group/http/handler/statistic"

	"github.com/gin-gonic/gin"
)

func OpsAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
	return func(s *gin.Engine) {
		for _, opt := range opts {
			opt(s)
		}

		// 牧场管理
		opsRoute := authRouteGroup(s, "/api/v1/ops/")
		opsRoute.POST("/pasture/add", pasture.AddGroupPasture)
		opsRoute.POST("/pasture/edit", pasture.EditGroupPasture)
		opsRoute.POST("/pasture/list", pasture.SearchGroupPastureList)
		opsRoute.DELETE("/pasture/:pasture_id", pasture.DeleteGroupPasture)
		opsRoute.POST("/pasture/rest_password/:pasture_id", pasture.ResetPasswordGroupPasture)
		opsRoute.POST("/pasture/is_show", pasture.IsShowGroupPasture)

		// 牲牧类型
		opsRoute.POST("/cattle/category/add", pasture.AddCattleCategory)
		opsRoute.POST("/cattle/category/edit", pasture.EditCattleCategory)
		opsRoute.POST("/cattle/category/is_show", pasture.IsShowCattleCategory)
		opsRoute.DELETE("/cattle/category/:cattle_category_id", pasture.DeleteCattleCategory)
		opsRoute.POST("/cattle/category/list", pasture.SearchCattleCategory)

		// 饲料类别
		opsRoute.POST("/forage/category/add", pasture.AddForageCategory)
		opsRoute.POST("/forage/category/edit", pasture.EditForageCategory)
		opsRoute.POST("/forage/category/is_show", pasture.IsShowForageCategory)
		opsRoute.DELETE("/forage/category/:forage_category_id", pasture.DeleteForageCategory)
		opsRoute.POST("/forage/category/list", pasture.SearchForageCategory)

		// 饲料列表
		opsRoute.POST("/forage/add", pasture.AddForage)
		opsRoute.POST("/forage/edit", pasture.EditForage)
		opsRoute.POST("/forage/list", pasture.SearchForageList)
		opsRoute.POST("forage/delete", pasture.DeleteForageList)
		opsRoute.POST("forage/is_show", pasture.IsShowForage)
		opsRoute.POST("forage/excel_import", pasture.ExcelImportForage)
		opsRoute.POST("forage/excel_export", pasture.ExcelExportForage)
		opsRoute.POST("forage/excel_template", pasture.ExcelTemplateForage)
		opsRoute.POST("/forage/small_material", pasture.SmallMaterial)
		opsRoute.POST("/forage/sort", pasture.ForageListSort)
		opsRoute.GET("/forage/enum/list", pasture.SearchForageEnumList)

		// 饲料配方
		opsRoute.POST("/feed_formula/add", feed.AddFeedFormula)
		opsRoute.POST("/feed_formula/edit", feed.EditFeedFormula)
		opsRoute.POST("/feed_formula/feed/add", feed.AddFeedByFeedFormula)
		opsRoute.POST("/feed_formula/feed/edit", feed.EditFeedByFeedFormula)
		opsRoute.POST("/feed_formula/feed/sort", feed.DetailBySort)
		opsRoute.POST("/feed_formula/feed/is_modify", feed.IsModifyFeedDetail)
		opsRoute.POST("/feed_formula/feed/delete", feed.DeleteFeedDetail)
		opsRoute.POST("/feed_formula/feed/search", feed.SearchFeedDetail)
		opsRoute.POST("/feed_formula/feed/mixed", feed.MixedFeedFormula)
		opsRoute.POST("/feed_formula/list", feed.SearchFeedFormulaList)
		opsRoute.POST("/feed_formula/forage_list", feed.SearchFeedFormulaByForageList)
		opsRoute.DELETE("/feed_formula/delete/:feed_formula_id", feed.DeleteFeedFormula)
		opsRoute.POST("/feed_formula/is_modify_show", feed.IsShowModifyFeedFormula)
		opsRoute.POST("/feed_formula/excel_export", feed.ExcelExportFeedFormula)
		opsRoute.POST("/feed_formula/excel_import", feed.ExcelImportFeedFormula)
		opsRoute.POST("/feed_formula/excel_template", feed.ExcelTemplateFeedFormula)
		opsRoute.GET("/feed_formula/encode_number", feed.EncodeNumber)
		opsRoute.POST("/feed_formula/distribute", feed.DistributeFeedFormula)
		opsRoute.POST("/feed_formula/cancel/distribute", feed.CancelDistributeFeedFormula)
		opsRoute.POST("/feed_formula/feed_detail/list", feed.ForageDetailList)
		opsRoute.POST("/feed_formula/edit_record/list", feed.EditRecordFeedFormula)
		opsRoute.POST("/feed_formula/usage", feed.Usage)
		opsRoute.GET("/feed_formula/forage_list", feed.ForageByGroup)

		//统计分析 statistic analysis
		opsRoute.POST("/feed_estimate/list", statistic.SearchFormulaEstimateList)
		opsRoute.POST("/inventory/statistics", statistic.SearchInventoryStatistics)
		opsRoute.POST("/inventory/statistics/excel_export", statistic.SearchInventoryStatisticsExcelExport)
		opsRoute.POST("/inventory/user_materials_statistics", statistic.SearchUserMaterialsStatistics)
		opsRoute.POST("/inventory/user_materials_statistics/excel_export", statistic.SearchUserMaterialsStatisticsExcelExport)
		opsRoute.POST("/inventory/price_statistics", statistic.SearchPriceStatistics)
		opsRoute.POST("/feed_efficiency/statistics", statistic.SearchFeedStatistics)
		opsRoute.POST("/feed_efficiency/chart_statistics", statistic.SearchFeedChartStatistics)
		opsRoute.POST("/feed_efficiency/cows_analysis", statistic.SearchCowsAnalysis)
		opsRoute.POST("/accuracy/agg_statistics", statistic.SearchAccuracyAggStatistics)
		opsRoute.POST("/accuracy/mixed_statistics", statistic.SearchMixFeedStatistics)
		opsRoute.POST("/accuracy/sprinkle_statistics", statistic.SearchSprinkleStatistics)

		opsRoute.POST("/process/analysis", statistic.SearchProcessAnalysis)
		opsRoute.POST("/process/analysis/mixed_sprinkle_detail", statistic.AnalysisMixedSprinkleDetail)
		opsRoute.POST("/statistics/train_number", statistic.TrainNumber)
		opsRoute.POST("/statistics/mixed_category_tmr_name", statistic.FeedMixedAndTmrName)
		opsRoute.POST("/feed_template/history", statistic.FeedTemplateHistory)
		opsRoute.POST("/barn/history", statistic.BarnHistory)
		opsRoute.POST("/spillage_all/history", statistic.SpillageAllHistory)
		opsRoute.POST("/accuracy/data_by_name", statistic.GetDataByName)

		// 首页仪表盘
		opsRoute.POST("/dashboard/accuracy", dashboard.AnalysisAccuracy)
		opsRoute.POST("/dashboard/top_pasture", dashboard.TopPasture)
		opsRoute.POST("/dashboard/exec_time", dashboard.ExecutionTime)
		opsRoute.POST("/dashboard/sprinkle_time", dashboard.SprinkleFeedTime)
	}
}