package router

import (
	"fonchain-fiee/pkg/middleware"
	"fonchain-fiee/pkg/service"
	serviceAI "fonchain-fiee/pkg/service/ai"
	serviceCast "fonchain-fiee/pkg/service/cast"

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

func MediaRouter(r *gin.RouterGroup) {
	noAuth := r.Group("")
	auth := r.Group("")
	auth.Use(middleware.CheckWebLogin(service.AccountProvider))
	media := auth.Group("media")
	{
		media.POST("user-list", serviceCast.MediaUserList)
		media.POST("unbind-manager", serviceCast.UnbindManager)
		media.POST("bind-manager", serviceCast.BindManager)
		media.POST("update-account", serviceCast.UpdateMediaAccount)
		media.POST("oauth-account", serviceCast.OAuthAccount)
		media.POST("refresh-token", serviceCast.RefreshToken)
		media.POST("artist-info", serviceCast.ArtistInfo)
		media.POST("sync-as-profile", serviceCast.SyncAsProfile)
		media.POST("import-media-account", serviceCast.ImportMediaAccount)
		media.POST("unbind-auth", serviceCast.UnbindAuth)
	}
	mediaNoLogin := r.Group("media")
	{
		mediaNoLogin.GET("oauth2callback", serviceCast.OAuth2Callback)
		mediaNoLogin.GET("as-oauth2callback", serviceCast.AsOAuth2Callback)
		mediaNoLogin.Any("test", serviceCast.Test)
		//mediaNoLogin.GET("dmoauth2callback", serviceCast.DMOAuth2Callback)
	}

	work := auth.Group("work")
	{
		work.POST("update-work-image", serviceCast.UpdateWorkImage)
		work.POST("update-work-video", serviceCast.UpdateWorkVideo)
		work.POST("update-approval", serviceCast.UpdateApproval)
		work.POST("list", serviceCast.WorkList)
		work.Any("list-export", serviceCast.WorkListExport)
		work.POST("detail", serviceCast.WorkDetail)
		work.POST("republish", serviceCast.RePublish)
		work.POST("publish", serviceCast.Publish)
		work.POST("delete", serviceCast.DelWork)
		work.POST("remind", serviceCast.Remind)
		work.POST("publish-info", serviceCast.PublishInfo)
		work.POST("import-batch", serviceCast.ImportWorkBatch)
		work.POST("list-published", serviceCast.WorkListPublished)
		work.POST("update-work-script", serviceCast.UpdateWorkScript)
		work.POST("publish-log-list", serviceCast.PublishLogList)
		work.Any("publish-log-list-export", serviceCast.PublishLogListExport)
	}

	workNoAuth := noAuth.Group("work")
	{
		workNoAuth.POST("cron-republish", serviceCast.CronRePublish)
	}

	script := auth.Group("script")
	{
		script.POST("update", serviceCast.UpdateVideoScript)
		script.POST("detail", serviceCast.VideoScriptDetail)
		script.POST("list", serviceCast.ListVideoScripts)
		script.POST("export-excel", serviceCast.VideoScripExportExcel)
		script.POST("import-batch", serviceCast.ImportBatch)
		script.POST("update-approval", serviceCast.UpdateScriptApproval)
		script.POST("delete", serviceCast.DeleteVideoScript)
	}

	task := auth.Group("task")
	{
		task.POST("list", serviceCast.TaskList)
		task.POST("delete", serviceCast.DeleteTasK)
		task.POST("download", serviceCast.DownloadTaskFile)
	}

	layout := auth.Group("layout")
	{
		layout.POST("update", serviceCast.LayoutUpdate)
		layout.POST("detail", serviceCast.LayoutDetail)
	}

	prompt := auth.Group("prompt")
	{
		prompt.POST("update", serviceCast.UpdatePrompt)
		prompt.POST("detail", serviceCast.PromptDetail)
		prompt.POST("list", serviceCast.ListPrompt)
		prompt.POST("import-batch", serviceCast.ImportPromptBatch)
		prompt.POST("delete", serviceCast.DeletePrompt)
	}

	tag := auth.Group("tag")
	{
		tag.POST("update", serviceCast.UpdateCastTag)
		tag.POST("list", serviceCast.ListCastTags)
		tag.POST("import-batch", serviceCast.ImportTagBatch)
		tag.POST("recalculate-quote-count", serviceCast.RecalculateCastTagQuoteCount)
		// tag.POST("auto-hashtags", serviceCast.AutoHashtags)
		// 这两个接口需要关闭ins，通过facebook授权
		// tag.POST("recommend-hashtags", serviceCast.RecommendHashtags)
		// tag.POST("search-hashtags", serviceCast.SearchHashtags)
	}

	//AI 生图
	aiNoAuth := noAuth.Group("ai")
	{
		aiNoAuth.POST("image-generate", serviceAI.AIImageGenerate)
		aiNoAuth.POST("text-generate", serviceAI.AIChat)
		aiNoAuth.POST("video-vl", serviceAI.AIVideoVL)
	}
	aiAuth := auth.Group("ai")
	{
		aiAuth.POST("one-text", serviceAI.OneText)
		aiAuth.POST("more-text", serviceAI.MoreText)
		aiAuth.POST("generate-report", serviceAI.AICompetitorReport)
	}

	social := noAuth.Group("social")
	{
		social.GET("tiktok-redirect", serviceCast.TikTokRedirect)
	}
	interact := auth.Group("interact")
	{
		interact.POST("send-message", serviceCast.SendMessage)
		interact.POST("get-message", serviceCast.GetMessage)
		interact.POST("post-comment", serviceCast.PostComment)
		interact.POST("get-comment", serviceCast.GetComment)
		interact.POST("delete-comment", serviceCast.DeleteComment)
		interact.POST("replay-comment", serviceCast.ReplyComment)
	}
}
