package app

import (
	datapayment "kra/internal/data/payment"
	datasystem "kra/internal/data/repository"
	"kra/pkg/module"
)

// Definition describes the built-in system contribution to the application
// catalog. Other business modules can expose the same shape independently.
func Definition() module.Definition {
	surface := datapayment.AdminSurface()
	communication := module.Surface{
		Menus: []module.Menu{{Name: "integrationConfig", Path: "integrationConfig", ParentName: "extensions", Component: "view/systemTools/integration/config.vue", Title: "通信集成", Icon: "connection", Sort: 8}},
		APIs: []module.API{
			{Path: "/integration/configs/:kind", Method: "GET", Group: "集成配置", Description: "按类型获取集成配置"},
			{Path: "/integration/configs/:kind/:provider", Method: "GET", Group: "集成配置", Description: "获取指定集成配置"},
			{Path: "/integration/configs/:kind/:provider", Method: "PUT", Group: "集成配置", Description: "保存集成配置"},
			{Path: "/integration/configs/:kind/:provider", Method: "DELETE", Group: "集成配置", Description: "删除集成配置"},
		},
	}
	surface.Menus = append(surface.Menus, communication.Menus...)
	surface.APIs = append(surface.APIs, communication.APIs...)
	return module.Definition{
		Name:       "system",
		Migrations: append(datasystem.Migrations(), datapayment.Migrations()...),
		Surface:    surface,
		TimedTasks: []module.TimedTask{
			{Name: "ClearDB", Description: "定时清理数据库过期日志(操作记录/JWT黑名单/定时任务执行日志)", Spec: "@daily", MethodName: "ClearDB", Enabled: true},
			{Name: "CleanStaleUploads", Description: "定时清理过期大文件上传会话", Spec: "@hourly", MethodName: "CleanStaleUploads", Enabled: true},
		},
	}
}
