chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
//go:generate go run github.com/swaggo/swag/cmd/swag init -g ./cmd/answer/main.go -d ../../ -o ../../docs
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
answercmd "github.com/apache/answer/cmd"
|
||||
)
|
||||
|
||||
// main godoc
|
||||
// @title Apache Answer
|
||||
// @description Apache Answer API
|
||||
// @BasePath /
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
// @name Authorization
|
||||
func main() {
|
||||
answercmd.Main()
|
||||
}
|
||||
+344
@@ -0,0 +1,344 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package answercmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/apache/answer/internal/base/conf"
|
||||
"github.com/apache/answer/internal/base/path"
|
||||
"github.com/apache/answer/internal/cli"
|
||||
"github.com/apache/answer/internal/install"
|
||||
"github.com/apache/answer/internal/migrations"
|
||||
"github.com/apache/answer/plugin"
|
||||
"github.com/segmentfault/pacman/log"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
// dataDirPath save all answer application data in this directory. like config file, upload file...
|
||||
dataDirPath string
|
||||
// dumpDataPath dump data path
|
||||
dumpDataPath string
|
||||
// place to build new answer
|
||||
buildDir string
|
||||
// plugins needed to build in answer application
|
||||
buildWithPlugins []string
|
||||
// build output path
|
||||
buildOutput string
|
||||
// This config is used to upgrade the database from a specific version manually.
|
||||
// If you want to upgrade the database to version 1.1.0, you can use `answer upgrade -f v1.1.0`.
|
||||
upgradeVersion string
|
||||
// The fields that need to be set to the default value
|
||||
configFields []string
|
||||
// i18nSourcePath i18n from path
|
||||
i18nSourcePath string
|
||||
// i18nTargetPath i18n to path
|
||||
i18nTargetPath string
|
||||
// resetPasswordEmail user email for password reset
|
||||
resetPasswordEmail string
|
||||
// resetPasswordPassword new password for password reset
|
||||
resetPasswordPassword string
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.Version = fmt.Sprintf("%s\nrevision: %s\nbuild time: %s", Version, Revision, Time)
|
||||
|
||||
rootCmd.PersistentFlags().StringVarP(&dataDirPath, "data-path", "C", "/data/", "data path, eg: -C ./data/")
|
||||
|
||||
dumpCmd.Flags().StringVarP(&dumpDataPath, "path", "p", "./", "dump data path, eg: -p ./dump/data/")
|
||||
|
||||
buildCmd.Flags().StringSliceVarP(&buildWithPlugins, "with", "w", []string{}, "plugins needed to build")
|
||||
|
||||
buildCmd.Flags().StringVarP(&buildOutput, "output", "o", "", "build output path")
|
||||
|
||||
buildCmd.Flags().StringVarP(&buildDir, "build-dir", "b", "", "dir for build process")
|
||||
|
||||
upgradeCmd.Flags().StringVarP(&upgradeVersion, "from", "f", "", "upgrade from specific version, eg: -f v1.1.0")
|
||||
|
||||
configCmd.Flags().StringSliceVarP(&configFields, "with", "w", []string{}, "the fields that need to be set to the default value, eg: -w allow_password_login")
|
||||
|
||||
i18nCmd.Flags().StringVarP(&i18nSourcePath, "source", "s", "", "i18n source path, eg: -s ./i18n/source")
|
||||
|
||||
i18nCmd.Flags().StringVarP(&i18nTargetPath, "target", "t", "", "i18n target path, eg: -t ./i18n/target")
|
||||
|
||||
resetPasswordCmd.Flags().StringVarP(&resetPasswordEmail, "email", "e", "", "user email address")
|
||||
resetPasswordCmd.Flags().StringVarP(&resetPasswordPassword, "password", "p", "", "new password (not recommended, will be recorded in shell history)")
|
||||
|
||||
for _, cmd := range []*cobra.Command{initCmd, checkCmd, runCmd, dumpCmd, upgradeCmd, buildCmd, pluginCmd, configCmd, i18nCmd, resetPasswordCmd} {
|
||||
rootCmd.AddCommand(cmd)
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "answer",
|
||||
Short: "Answer is a minimalist open source Q&A community.",
|
||||
Long: `Answer is a minimalist open source Q&A community.
|
||||
To run answer, use:
|
||||
- 'answer init' to initialize the required environment.
|
||||
- 'answer run' to launch application.`,
|
||||
}
|
||||
|
||||
runCmd = &cobra.Command{
|
||||
Use: "run",
|
||||
Short: "Run Answer",
|
||||
Long: `Start running Answer`,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
path.FormatAllPath(dataDirPath)
|
||||
fmt.Println("config file path: ", path.GetConfigFilePath())
|
||||
fmt.Println("Answer is starting..........................")
|
||||
runApp()
|
||||
},
|
||||
}
|
||||
|
||||
initCmd = &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "Initialize Answer",
|
||||
Long: `Initialize Answer with specified configuration`,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
// check config file and database. if config file exists and database is already created, init done
|
||||
cli.InstallAllInitialEnvironment(dataDirPath)
|
||||
|
||||
configFileExist := cli.CheckConfigFile(path.GetConfigFilePath())
|
||||
if configFileExist {
|
||||
fmt.Println("config file exists, try to read the config...")
|
||||
c, err := conf.ReadConfig(path.GetConfigFilePath())
|
||||
if err != nil {
|
||||
fmt.Println("read config failed: ", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("config file read successfully, try to connect database...")
|
||||
if cli.CheckDBTableExist(c.Data.Database) {
|
||||
fmt.Println("connect to database successfully and table already exists, do nothing.")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// start installation server to install
|
||||
install.Run(path.GetConfigFilePath())
|
||||
},
|
||||
}
|
||||
|
||||
upgradeCmd = &cobra.Command{
|
||||
Use: "upgrade",
|
||||
Short: "Upgrade Answer",
|
||||
Long: `Upgrade Answer to the latest version`,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
log.SetLogger(log.NewStdLogger(os.Stdout))
|
||||
path.FormatAllPath(dataDirPath)
|
||||
cli.InstallI18nBundle(true)
|
||||
c, err := conf.ReadConfig(path.GetConfigFilePath())
|
||||
if err != nil {
|
||||
fmt.Println("read config failed: ", err.Error())
|
||||
return
|
||||
}
|
||||
if err = migrations.Migrate(c.Debug, c.Data.Database, c.Data.Cache, upgradeVersion); err != nil {
|
||||
fmt.Println("migrate failed: ", err.Error())
|
||||
return
|
||||
}
|
||||
fmt.Println("upgrade done")
|
||||
},
|
||||
}
|
||||
|
||||
dumpCmd = &cobra.Command{
|
||||
Use: "dump",
|
||||
Short: "Back up data",
|
||||
Long: `Back up database into an SQL file`,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
fmt.Println("Answer is backing up data")
|
||||
path.FormatAllPath(dataDirPath)
|
||||
c, err := conf.ReadConfig(path.GetConfigFilePath())
|
||||
if err != nil {
|
||||
fmt.Println("read config failed: ", err.Error())
|
||||
return
|
||||
}
|
||||
err = cli.DumpAllData(c.Data.Database, dumpDataPath)
|
||||
if err != nil {
|
||||
fmt.Println("dump failed: ", err.Error())
|
||||
return
|
||||
}
|
||||
fmt.Println("Answer backed up the data successfully.")
|
||||
},
|
||||
}
|
||||
|
||||
checkCmd = &cobra.Command{
|
||||
Use: "check",
|
||||
Short: "Check the required environment",
|
||||
Long: `Check if the current environment meets the startup requirements`,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
path.FormatAllPath(dataDirPath)
|
||||
fmt.Println("Start checking the required environment...")
|
||||
if cli.CheckConfigFile(path.GetConfigFilePath()) {
|
||||
fmt.Println("config file exists [✔]")
|
||||
} else {
|
||||
fmt.Println("config file not exists [x]")
|
||||
}
|
||||
|
||||
if cli.CheckUploadDir() {
|
||||
fmt.Println("upload directory exists [✔]")
|
||||
} else {
|
||||
fmt.Println("upload directory not exists [x]")
|
||||
}
|
||||
|
||||
c, err := conf.ReadConfig(path.GetConfigFilePath())
|
||||
if err != nil {
|
||||
fmt.Println("read config failed: ", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if cli.CheckDBConnection(c.Data.Database) {
|
||||
fmt.Println("db connection successfully [✔]")
|
||||
} else {
|
||||
fmt.Println("db connection failed [x]")
|
||||
}
|
||||
fmt.Println("check environment all done")
|
||||
},
|
||||
}
|
||||
|
||||
buildCmd = &cobra.Command{
|
||||
Use: "build",
|
||||
Short: "Build Answer with plugins",
|
||||
Long: `Build a new Answer with plugins that you need`,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
fmt.Printf("try to build a new answer with plugins:\n%s\n", strings.Join(buildWithPlugins, "\n"))
|
||||
err := cli.BuildNewAnswer(buildDir, buildOutput, buildWithPlugins, cli.OriginalAnswerInfo{
|
||||
Version: Version,
|
||||
Revision: Revision,
|
||||
Time: Time,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Printf("build failed %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("build new answer successfully %s\n", buildOutput)
|
||||
},
|
||||
}
|
||||
|
||||
pluginCmd = &cobra.Command{
|
||||
Use: "plugin",
|
||||
Short: "Print all plugins packed in the binary",
|
||||
Long: `Print all plugins packed in the binary`,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
_ = plugin.CallBase(func(base plugin.Base) error {
|
||||
info := base.Info()
|
||||
fmt.Printf("%s[%s] made by %s\n", info.SlugName, info.Version, info.Author)
|
||||
return nil
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
configCmd = &cobra.Command{
|
||||
Use: "config",
|
||||
Short: "Set some config to default value",
|
||||
Long: `Set some config to default value`,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
path.FormatAllPath(dataDirPath)
|
||||
|
||||
c, err := conf.ReadConfig(path.GetConfigFilePath())
|
||||
if err != nil {
|
||||
fmt.Println("read config failed: ", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
field := &cli.ConfigField{}
|
||||
fmt.Println(configFields)
|
||||
if len(configFields) > 0 {
|
||||
switch configFields[0] {
|
||||
case "allow_password_login":
|
||||
field.AllowPasswordLogin = true
|
||||
case "deactivate_plugin":
|
||||
if len(configFields) > 1 {
|
||||
field.DeactivatePluginSlugName = configFields[1]
|
||||
}
|
||||
default:
|
||||
fmt.Printf("field %s not support\n", configFields[0])
|
||||
}
|
||||
}
|
||||
err = cli.SetDefaultConfig(c.Data.Database, c.Data.Cache, field)
|
||||
if err != nil {
|
||||
fmt.Println("set default config failed: ", err.Error())
|
||||
} else {
|
||||
fmt.Println("set default config successfully")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
i18nCmd = &cobra.Command{
|
||||
Use: "i18n",
|
||||
Short: "Overwrite i18n files",
|
||||
Long: `Merge i18n files from plugins to original i18n files. It will overwrite the original i18n files`,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
if err := cli.ReplaceI18nFilesLocal(i18nTargetPath); err != nil {
|
||||
fmt.Printf("replace i18n files failed %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("replace i18n files successfully\n")
|
||||
}
|
||||
|
||||
fmt.Printf("try to merge i18n files from %q to %q\n", i18nSourcePath, i18nTargetPath)
|
||||
|
||||
if err := cli.MergeI18nFilesLocal(i18nTargetPath, i18nSourcePath); err != nil {
|
||||
fmt.Printf("merge i18n files failed %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("merge i18n files successfully\n")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
resetPasswordCmd = &cobra.Command{
|
||||
Use: "passwd",
|
||||
Aliases: []string{"password", "reset-password"},
|
||||
Short: "Reset user password",
|
||||
Long: "Reset user password by email address.",
|
||||
Example: ` # Interactive mode (recommended, safest)
|
||||
answer passwd -C ./answer-data
|
||||
|
||||
# Specify email only (will prompt for password securely)
|
||||
answer passwd -C ./answer-data --email user@example.com
|
||||
answer passwd -C ./answer-data -e user@example.com
|
||||
|
||||
# Specify email and password (NOT recommended, will be recorded in shell history)
|
||||
answer passwd -C ./answer-data -e user@example.com -p newpassword123`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
opts := &cli.ResetPasswordOptions{
|
||||
Email: resetPasswordEmail,
|
||||
Password: resetPasswordPassword,
|
||||
}
|
||||
if err := cli.ResetPassword(context.Background(), dataDirPath, opts); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
// This is called by main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
err := rootCmd.Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package answercmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/apache/answer/internal/base/conf"
|
||||
"github.com/apache/answer/internal/base/constant"
|
||||
"github.com/apache/answer/internal/base/cron"
|
||||
"github.com/apache/answer/internal/base/path"
|
||||
"github.com/apache/answer/internal/schema"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/segmentfault/pacman"
|
||||
"github.com/segmentfault/pacman/contrib/log/zap"
|
||||
"github.com/segmentfault/pacman/contrib/server/http"
|
||||
"github.com/segmentfault/pacman/log"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Load .env if present, ignore error to keep backward compatibility
|
||||
_ = godotenv.Load()
|
||||
}
|
||||
|
||||
// go build -ldflags "-X github.com/apache/answer/cmd.Version=x.y.z"
|
||||
var (
|
||||
// Name is the name of the project
|
||||
Name = "answer"
|
||||
// Version is the version of the project
|
||||
Version = "0.0.0"
|
||||
// Revision is the git short commit revision number
|
||||
// If built without a Git repository, this field will be empty.
|
||||
Revision = ""
|
||||
// Time is the build time of the project
|
||||
Time = ""
|
||||
// GoVersion is the go version of the project
|
||||
GoVersion = "1.23"
|
||||
// log level
|
||||
logLevel = os.Getenv("LOG_LEVEL")
|
||||
// log path
|
||||
logPath = os.Getenv("LOG_PATH")
|
||||
)
|
||||
|
||||
// Main
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
// @name Authorization
|
||||
func Main() {
|
||||
log.SetLogger(zap.NewLogger(
|
||||
log.ParseLevel(logLevel), zap.WithName("answer"), zap.WithPath(logPath)))
|
||||
Execute()
|
||||
}
|
||||
|
||||
func runApp() {
|
||||
c, err := conf.ReadConfig(path.GetConfigFilePath())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
app, cleanup, err := initApplication(
|
||||
c.Debug, c.Server, c.Data.Database, c.Data.Cache, c.I18n, c.Swaggerui, c.ServiceConfig, c.UI, log.GetLogger())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
constant.Version = Version
|
||||
constant.Revision = Revision
|
||||
constant.GoVersion = GoVersion
|
||||
schema.AppStartTime = time.Now()
|
||||
fmt.Println("answer Version:", constant.Version, " Revision:", constant.Revision)
|
||||
|
||||
defer cleanup()
|
||||
if err := app.Run(context.Background()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func newApplication(serverConf *conf.Server, server *gin.Engine, manager *cron.ScheduledTaskManager) *pacman.Application {
|
||||
manager.Run()
|
||||
return pacman.NewApp(
|
||||
pacman.WithName(Name),
|
||||
pacman.WithVersion(Version),
|
||||
pacman.WithServer(http.NewServer(server, serverConf.HTTP.Addr)),
|
||||
)
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
//go:build wireinject
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// The build tag makes sure the stub is not built in the final build.
|
||||
|
||||
package answercmd
|
||||
|
||||
import (
|
||||
"github.com/apache/answer/internal/base/conf"
|
||||
"github.com/apache/answer/internal/base/cron"
|
||||
"github.com/apache/answer/internal/base/data"
|
||||
"github.com/apache/answer/internal/base/middleware"
|
||||
"github.com/apache/answer/internal/base/server"
|
||||
"github.com/apache/answer/internal/base/translator"
|
||||
"github.com/apache/answer/internal/controller"
|
||||
templaterender "github.com/apache/answer/internal/controller/template_render"
|
||||
"github.com/apache/answer/internal/controller_admin"
|
||||
"github.com/apache/answer/internal/repo"
|
||||
"github.com/apache/answer/internal/router"
|
||||
"github.com/apache/answer/internal/service"
|
||||
"github.com/apache/answer/internal/service/service_config"
|
||||
"github.com/google/wire"
|
||||
"github.com/segmentfault/pacman"
|
||||
"github.com/segmentfault/pacman/log"
|
||||
)
|
||||
|
||||
// initApplication init application.
|
||||
func initApplication(
|
||||
debug bool,
|
||||
serverConf *conf.Server,
|
||||
dbConf *data.Database,
|
||||
cacheConf *data.CacheConf,
|
||||
i18nConf *translator.I18n,
|
||||
swaggerConf *router.SwaggerConfig,
|
||||
serviceConf *service_config.ServiceConfig,
|
||||
uiConf *server.UI,
|
||||
logConf log.Logger) (*pacman.Application, func(), error) {
|
||||
panic(wire.Build(
|
||||
server.ProviderSetServer,
|
||||
router.ProviderSetRouter,
|
||||
controller.ProviderSetController,
|
||||
controller_admin.ProviderSetController,
|
||||
templaterender.ProviderSetTemplateRenderController,
|
||||
service.ProviderSetService,
|
||||
cron.ProviderSetService,
|
||||
repo.ProviderSetRepo,
|
||||
translator.ProviderSet,
|
||||
middleware.ProviderSetMiddleware,
|
||||
newApplication,
|
||||
))
|
||||
}
|
||||
+320
@@ -0,0 +1,320 @@
|
||||
//go:build !wireinject
|
||||
// +build !wireinject
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Code generated by Wire. DO NOT EDIT.
|
||||
|
||||
//go:generate go run github.com/google/wire/cmd/wire
|
||||
|
||||
package answercmd
|
||||
|
||||
import (
|
||||
"github.com/apache/answer/internal/base/conf"
|
||||
"github.com/apache/answer/internal/base/cron"
|
||||
"github.com/apache/answer/internal/base/data"
|
||||
"github.com/apache/answer/internal/base/middleware"
|
||||
"github.com/apache/answer/internal/base/server"
|
||||
"github.com/apache/answer/internal/base/translator"
|
||||
"github.com/apache/answer/internal/controller"
|
||||
"github.com/apache/answer/internal/controller/template_render"
|
||||
"github.com/apache/answer/internal/controller_admin"
|
||||
"github.com/apache/answer/internal/repo/activity"
|
||||
"github.com/apache/answer/internal/repo/activity_common"
|
||||
"github.com/apache/answer/internal/repo/ai_conversation"
|
||||
"github.com/apache/answer/internal/repo/answer"
|
||||
"github.com/apache/answer/internal/repo/api_key"
|
||||
"github.com/apache/answer/internal/repo/auth"
|
||||
"github.com/apache/answer/internal/repo/badge"
|
||||
"github.com/apache/answer/internal/repo/badge_award"
|
||||
"github.com/apache/answer/internal/repo/badge_group"
|
||||
"github.com/apache/answer/internal/repo/captcha"
|
||||
"github.com/apache/answer/internal/repo/collection"
|
||||
"github.com/apache/answer/internal/repo/comment"
|
||||
"github.com/apache/answer/internal/repo/config"
|
||||
"github.com/apache/answer/internal/repo/export"
|
||||
"github.com/apache/answer/internal/repo/file_record"
|
||||
"github.com/apache/answer/internal/repo/limit"
|
||||
"github.com/apache/answer/internal/repo/meta"
|
||||
notification2 "github.com/apache/answer/internal/repo/notification"
|
||||
"github.com/apache/answer/internal/repo/plugin_config"
|
||||
"github.com/apache/answer/internal/repo/question"
|
||||
"github.com/apache/answer/internal/repo/rank"
|
||||
"github.com/apache/answer/internal/repo/reason"
|
||||
"github.com/apache/answer/internal/repo/report"
|
||||
"github.com/apache/answer/internal/repo/review"
|
||||
"github.com/apache/answer/internal/repo/revision"
|
||||
"github.com/apache/answer/internal/repo/role"
|
||||
"github.com/apache/answer/internal/repo/search_common"
|
||||
"github.com/apache/answer/internal/repo/site_info"
|
||||
"github.com/apache/answer/internal/repo/tag"
|
||||
"github.com/apache/answer/internal/repo/tag_common"
|
||||
"github.com/apache/answer/internal/repo/unique"
|
||||
"github.com/apache/answer/internal/repo/user"
|
||||
"github.com/apache/answer/internal/repo/user_external_login"
|
||||
"github.com/apache/answer/internal/repo/user_notification_config"
|
||||
"github.com/apache/answer/internal/router"
|
||||
"github.com/apache/answer/internal/service/action"
|
||||
activity2 "github.com/apache/answer/internal/service/activity"
|
||||
activity_common2 "github.com/apache/answer/internal/service/activity_common"
|
||||
"github.com/apache/answer/internal/service/activityqueue"
|
||||
ai_conversation2 "github.com/apache/answer/internal/service/ai_conversation"
|
||||
"github.com/apache/answer/internal/service/answer_common"
|
||||
"github.com/apache/answer/internal/service/apikey"
|
||||
auth2 "github.com/apache/answer/internal/service/auth"
|
||||
badge2 "github.com/apache/answer/internal/service/badge"
|
||||
collection2 "github.com/apache/answer/internal/service/collection"
|
||||
"github.com/apache/answer/internal/service/collection_common"
|
||||
comment2 "github.com/apache/answer/internal/service/comment"
|
||||
"github.com/apache/answer/internal/service/comment_common"
|
||||
config2 "github.com/apache/answer/internal/service/config"
|
||||
"github.com/apache/answer/internal/service/content"
|
||||
"github.com/apache/answer/internal/service/dashboard"
|
||||
"github.com/apache/answer/internal/service/embedding"
|
||||
"github.com/apache/answer/internal/service/eventqueue"
|
||||
export2 "github.com/apache/answer/internal/service/export"
|
||||
"github.com/apache/answer/internal/service/feature_toggle"
|
||||
file_record2 "github.com/apache/answer/internal/service/file_record"
|
||||
"github.com/apache/answer/internal/service/follow"
|
||||
"github.com/apache/answer/internal/service/importer"
|
||||
meta2 "github.com/apache/answer/internal/service/meta"
|
||||
"github.com/apache/answer/internal/service/meta_common"
|
||||
"github.com/apache/answer/internal/service/noticequeue"
|
||||
"github.com/apache/answer/internal/service/notification"
|
||||
"github.com/apache/answer/internal/service/notification_common"
|
||||
"github.com/apache/answer/internal/service/object_info"
|
||||
"github.com/apache/answer/internal/service/plugin_common"
|
||||
"github.com/apache/answer/internal/service/question_common"
|
||||
rank2 "github.com/apache/answer/internal/service/rank"
|
||||
reason2 "github.com/apache/answer/internal/service/reason"
|
||||
report2 "github.com/apache/answer/internal/service/report"
|
||||
"github.com/apache/answer/internal/service/report_handle"
|
||||
review2 "github.com/apache/answer/internal/service/review"
|
||||
"github.com/apache/answer/internal/service/revision_common"
|
||||
role2 "github.com/apache/answer/internal/service/role"
|
||||
"github.com/apache/answer/internal/service/search_parser"
|
||||
"github.com/apache/answer/internal/service/service_config"
|
||||
"github.com/apache/answer/internal/service/siteinfo"
|
||||
"github.com/apache/answer/internal/service/siteinfo_common"
|
||||
tag2 "github.com/apache/answer/internal/service/tag"
|
||||
tag_common2 "github.com/apache/answer/internal/service/tag_common"
|
||||
"github.com/apache/answer/internal/service/uploader"
|
||||
"github.com/apache/answer/internal/service/user_admin"
|
||||
"github.com/apache/answer/internal/service/user_common"
|
||||
user_external_login2 "github.com/apache/answer/internal/service/user_external_login"
|
||||
user_notification_config2 "github.com/apache/answer/internal/service/user_notification_config"
|
||||
"github.com/apache/answer/internal/service/vector_sync"
|
||||
"github.com/segmentfault/pacman"
|
||||
"github.com/segmentfault/pacman/log"
|
||||
)
|
||||
|
||||
// Injectors from wire.go:
|
||||
|
||||
// initApplication init application.
|
||||
func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database, cacheConf *data.CacheConf, i18nConf *translator.I18n, swaggerConf *router.SwaggerConfig, serviceConf *service_config.ServiceConfig, uiConf *server.UI, logConf log.Logger) (*pacman.Application, func(), error) {
|
||||
staticRouter := router.NewStaticRouter(serviceConf)
|
||||
i18nTranslator, err := translator.NewTranslator(i18nConf)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
engine, err := data.NewDB(debug, dbConf)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
cache, cleanup, err := data.NewCache(cacheConf)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
dataData, cleanup2, err := data.NewData(engine, cache)
|
||||
if err != nil {
|
||||
cleanup()
|
||||
return nil, nil, err
|
||||
}
|
||||
siteInfoRepo := site_info.NewSiteInfo(dataData)
|
||||
siteInfoCommonService := siteinfo_common.NewSiteInfoCommonService(siteInfoRepo)
|
||||
langController := controller.NewLangController(i18nTranslator, siteInfoCommonService)
|
||||
authRepo := auth.NewAuthRepo(dataData)
|
||||
apiKeyRepo := api_key.NewAPIKeyRepo(dataData)
|
||||
authService := auth2.NewAuthService(authRepo, apiKeyRepo)
|
||||
userRepo := user.NewUserRepo(dataData)
|
||||
uniqueIDRepo := unique.NewUniqueIDRepo(dataData)
|
||||
configRepo := config.NewConfigRepo(dataData)
|
||||
configService := config2.NewConfigService(configRepo)
|
||||
activityRepo := activity_common.NewActivityRepo(dataData, uniqueIDRepo, configService)
|
||||
userRankRepo := rank.NewUserRankRepo(dataData, configService)
|
||||
userActiveActivityRepo := activity.NewUserActiveActivityRepo(dataData, activityRepo, userRankRepo, configService)
|
||||
emailRepo := export.NewEmailRepo(dataData)
|
||||
emailService := export2.NewEmailService(configService, emailRepo, siteInfoCommonService)
|
||||
userRoleRelRepo := role.NewUserRoleRelRepo(dataData)
|
||||
roleRepo := role.NewRoleRepo(dataData)
|
||||
roleService := role2.NewRoleService(roleRepo)
|
||||
userRoleRelService := role2.NewUserRoleRelService(userRoleRelRepo, roleService)
|
||||
userCommon := usercommon.NewUserCommon(userRepo, userRoleRelService, authService, siteInfoCommonService)
|
||||
userExternalLoginRepo := user_external_login.NewUserExternalLoginRepo(dataData)
|
||||
userNotificationConfigRepo := user_notification_config.NewUserNotificationConfigRepo(dataData)
|
||||
userNotificationConfigService := user_notification_config2.NewUserNotificationConfigService(userRepo, userNotificationConfigRepo)
|
||||
userExternalLoginService := user_external_login2.NewUserExternalLoginService(userRepo, userCommon, userExternalLoginRepo, emailService, siteInfoCommonService, userActiveActivityRepo, userNotificationConfigService)
|
||||
questionRepo := question.NewQuestionRepo(dataData, uniqueIDRepo)
|
||||
answerRepo := answer.NewAnswerRepo(dataData, uniqueIDRepo, userRankRepo, activityRepo)
|
||||
voteRepo := activity_common.NewVoteRepo(dataData, activityRepo)
|
||||
followRepo := activity_common.NewFollowRepo(dataData, uniqueIDRepo, activityRepo)
|
||||
tagCommonRepo := tag_common.NewTagCommonRepo(dataData, uniqueIDRepo)
|
||||
tagRelRepo := tag.NewTagRelRepo(dataData, uniqueIDRepo)
|
||||
tagRepo := tag.NewTagRepo(dataData, uniqueIDRepo)
|
||||
revisionRepo := revision.NewRevisionRepo(dataData, uniqueIDRepo)
|
||||
revisionService := revision_common.NewRevisionService(revisionRepo, userRepo)
|
||||
service := activityqueue.NewService()
|
||||
tagCommonService := tag_common2.NewTagCommonService(tagCommonRepo, tagRelRepo, tagRepo, revisionService, siteInfoCommonService, service)
|
||||
collectionRepo := collection.NewCollectionRepo(dataData, uniqueIDRepo)
|
||||
collectionCommon := collectioncommon.NewCollectionCommon(collectionRepo)
|
||||
answerCommon := answercommon.NewAnswerCommon(answerRepo)
|
||||
metaRepo := meta.NewMetaRepo(dataData)
|
||||
metaCommonService := metacommon.NewMetaCommonService(metaRepo)
|
||||
questionCommon := questioncommon.NewQuestionCommon(questionRepo, answerRepo, voteRepo, followRepo, tagCommonService, userCommon, collectionCommon, answerCommon, metaCommonService, configService, service, revisionRepo, siteInfoCommonService, dataData)
|
||||
eventqueueService := eventqueue.NewService()
|
||||
fileRecordRepo := file_record.NewFileRecordRepo(dataData)
|
||||
fileRecordService := file_record2.NewFileRecordService(fileRecordRepo, revisionRepo, serviceConf, siteInfoCommonService, userCommon)
|
||||
userService := content.NewUserService(userRepo, userActiveActivityRepo, activityRepo, emailService, authService, siteInfoCommonService, userRoleRelService, userCommon, userExternalLoginService, userNotificationConfigRepo, userNotificationConfigService, questionCommon, eventqueueService, fileRecordService)
|
||||
captchaRepo := captcha.NewCaptchaRepo(dataData)
|
||||
captchaService := action.NewCaptchaService(captchaRepo)
|
||||
userController := controller.NewUserController(authService, userService, captchaService, emailService, siteInfoCommonService, userNotificationConfigService)
|
||||
commentRepo := comment.NewCommentRepo(dataData, uniqueIDRepo)
|
||||
commentCommonRepo := comment.NewCommentCommonRepo(dataData, uniqueIDRepo)
|
||||
objService := object_info.NewObjService(answerRepo, questionRepo, commentCommonRepo, tagCommonRepo, tagCommonService)
|
||||
noticequeueService := noticequeue.NewService()
|
||||
externalService := noticequeue.NewExternalService()
|
||||
reviewRepo := review.NewReviewRepo(dataData)
|
||||
vector_syncService := vector_sync.NewService(dataData)
|
||||
reviewService := review2.NewReviewService(reviewRepo, objService, userCommon, userRepo, questionRepo, answerRepo, userRoleRelService, externalService, tagCommonService, questionCommon, noticequeueService, siteInfoCommonService, commentCommonRepo, vector_syncService)
|
||||
commentService := comment2.NewCommentService(commentRepo, commentCommonRepo, userCommon, objService, voteRepo, emailService, userRepo, noticequeueService, externalService, service, eventqueueService, reviewService, vector_syncService)
|
||||
rolePowerRelRepo := role.NewRolePowerRelRepo(dataData)
|
||||
rolePowerRelService := role2.NewRolePowerRelService(rolePowerRelRepo, userRoleRelService)
|
||||
rankService := rank2.NewRankService(userCommon, userRankRepo, objService, userRoleRelService, rolePowerRelService, configService)
|
||||
limitRepo := limit.NewRateLimitRepo(dataData)
|
||||
rateLimitMiddleware := middleware.NewRateLimitMiddleware(limitRepo)
|
||||
commentController := controller.NewCommentController(commentService, rankService, captchaService, rateLimitMiddleware)
|
||||
reportRepo := report.NewReportRepo(dataData, uniqueIDRepo)
|
||||
tagService := tag2.NewTagService(tagRepo, tagCommonService, revisionService, followRepo, siteInfoCommonService, service)
|
||||
answerActivityRepo := activity.NewAnswerActivityRepo(dataData, activityRepo, userRankRepo, noticequeueService)
|
||||
answerActivityService := activity2.NewAnswerActivityService(answerActivityRepo, configService)
|
||||
externalNotificationService := notification.NewExternalNotificationService(dataData, userNotificationConfigRepo, followRepo, emailService, userRepo, externalService, userExternalLoginRepo, siteInfoCommonService)
|
||||
questionService := content.NewQuestionService(activityRepo, questionRepo, answerRepo, tagCommonService, tagService, questionCommon, userCommon, userRepo, userRoleRelService, revisionService, metaCommonService, collectionCommon, answerActivityService, emailService, noticequeueService, externalService, service, siteInfoCommonService, externalNotificationService, reviewService, configService, eventqueueService, reviewRepo, vector_syncService)
|
||||
answerService := content.NewAnswerService(answerRepo, questionRepo, questionCommon, userCommon, collectionCommon, userRepo, revisionService, answerActivityService, answerCommon, voteRepo, emailService, userRoleRelService, noticequeueService, externalService, service, reviewService, eventqueueService, vector_syncService)
|
||||
reportHandle := report_handle.NewReportHandle(questionService, answerService, commentService)
|
||||
reportService := report2.NewReportService(reportRepo, objService, userCommon, answerRepo, questionRepo, commentCommonRepo, reportHandle, configService, eventqueueService)
|
||||
reportController := controller.NewReportController(reportService, rankService, captchaService)
|
||||
contentVoteRepo := activity.NewVoteRepo(dataData, activityRepo, userRankRepo, noticequeueService)
|
||||
voteService := content.NewVoteService(contentVoteRepo, configService, questionRepo, answerRepo, commentCommonRepo, objService, eventqueueService)
|
||||
voteController := controller.NewVoteController(voteService, rankService, captchaService)
|
||||
tagController := controller.NewTagController(tagService, tagCommonService, rankService)
|
||||
followFollowRepo := activity.NewFollowRepo(dataData, uniqueIDRepo, activityRepo)
|
||||
followService := follow.NewFollowService(followFollowRepo, followRepo, tagCommonRepo)
|
||||
followController := controller.NewFollowController(followService)
|
||||
collectionGroupRepo := collection.NewCollectionGroupRepo(dataData)
|
||||
collectionService := collection2.NewCollectionService(collectionRepo, collectionGroupRepo, questionCommon)
|
||||
collectionController := controller.NewCollectionController(collectionService)
|
||||
questionController := controller.NewQuestionController(questionService, answerService, rankService, siteInfoCommonService, captchaService, rateLimitMiddleware)
|
||||
answerController := controller.NewAnswerController(answerService, rankService, captchaService, siteInfoCommonService, rateLimitMiddleware)
|
||||
searchParser := search_parser.NewSearchParser(tagCommonService, userCommon)
|
||||
searchRepo := search_common.NewSearchRepo(dataData, uniqueIDRepo, userCommon, tagCommonService)
|
||||
searchService := content.NewSearchService(searchParser, searchRepo)
|
||||
searchController := controller.NewSearchController(searchService, captchaService)
|
||||
reviewActivityRepo := activity.NewReviewActivityRepo(dataData, activityRepo, userRankRepo, configService)
|
||||
contentRevisionService := content.NewRevisionService(revisionRepo, userCommon, questionCommon, answerService, objService, questionRepo, answerRepo, tagRepo, tagCommonService, noticequeueService, service, reportRepo, reviewService, reviewActivityRepo)
|
||||
revisionController := controller.NewRevisionController(contentRevisionService, rankService)
|
||||
rankController := controller.NewRankController(rankService)
|
||||
userAdminRepo := user.NewUserAdminRepo(dataData, authRepo)
|
||||
notificationRepo := notification2.NewNotificationRepo(dataData)
|
||||
pluginUserConfigRepo := plugin_config.NewPluginUserConfigRepo(dataData)
|
||||
badgeAwardRepo := badge_award.NewBadgeAwardRepo(dataData, uniqueIDRepo)
|
||||
userAdminService := user_admin.NewUserAdminService(userAdminRepo, userRoleRelService, authService, userCommon, userActiveActivityRepo, siteInfoCommonService, emailService, questionRepo, answerRepo, commentCommonRepo, userExternalLoginRepo, notificationRepo, pluginUserConfigRepo, badgeAwardRepo, apiKeyRepo)
|
||||
userAdminController := controller_admin.NewUserAdminController(userAdminService)
|
||||
reasonRepo := reason.NewReasonRepo(configService)
|
||||
reasonService := reason2.NewReasonService(reasonRepo)
|
||||
reasonController := controller.NewReasonController(reasonService)
|
||||
themeController := controller_admin.NewThemeController()
|
||||
siteInfoService := siteinfo.NewSiteInfoService(siteInfoRepo, siteInfoCommonService, emailService, tagCommonService, configService, questionCommon, fileRecordService)
|
||||
siteInfoController := controller_admin.NewSiteInfoController(siteInfoService)
|
||||
controllerSiteInfoController := controller.NewSiteInfoController(siteInfoCommonService)
|
||||
notificationCommon := notificationcommon.NewNotificationCommon(dataData, notificationRepo, userCommon, activityRepo, followRepo, objService, noticequeueService, userExternalLoginRepo, siteInfoCommonService)
|
||||
badgeRepo := badge.NewBadgeRepo(dataData, uniqueIDRepo)
|
||||
notificationService := notification.NewNotificationService(dataData, notificationRepo, notificationCommon, revisionService, userRepo, reportRepo, reviewService, badgeRepo)
|
||||
notificationController := controller.NewNotificationController(notificationService, rankService)
|
||||
dashboardService := dashboard.NewDashboardService(questionRepo, answerRepo, commentCommonRepo, voteRepo, userRepo, reportRepo, configService, siteInfoCommonService, serviceConf, reviewService, revisionRepo, dataData)
|
||||
dashboardController := controller.NewDashboardController(dashboardService)
|
||||
uploaderService := uploader.NewUploaderService(serviceConf, siteInfoCommonService, fileRecordService)
|
||||
uploadController := controller.NewUploadController(uploaderService)
|
||||
activityActivityRepo := activity.NewActivityRepo(dataData, configService)
|
||||
activityCommon := activity_common2.NewActivityCommon(activityRepo, service)
|
||||
commentCommonService := comment_common.NewCommentCommonService(commentCommonRepo)
|
||||
activityService := activity2.NewActivityService(activityActivityRepo, userCommon, activityCommon, tagCommonService, objService, commentCommonService, revisionService, metaCommonService, configService)
|
||||
activityController := controller.NewActivityController(activityService)
|
||||
roleController := controller_admin.NewRoleController(roleService)
|
||||
pluginConfigRepo := plugin_config.NewPluginConfigRepo(dataData)
|
||||
importerService := importer.NewImporterService(questionService, rankService, userCommon)
|
||||
pluginCommonService := plugin_common.NewPluginCommonService(pluginConfigRepo, pluginUserConfigRepo, configService, dataData, importerService)
|
||||
pluginController := controller_admin.NewPluginController(pluginCommonService)
|
||||
permissionController := controller.NewPermissionController(rankService)
|
||||
userPluginController := controller.NewUserPluginController(pluginCommonService)
|
||||
reviewController := controller.NewReviewController(reviewService, rankService, captchaService)
|
||||
metaService := meta2.NewMetaService(metaCommonService, userCommon, answerRepo, questionRepo, eventqueueService)
|
||||
metaController := controller.NewMetaController(metaService)
|
||||
badgeGroupRepo := badge_group.NewBadgeGroupRepo(dataData, uniqueIDRepo)
|
||||
eventRuleRepo := badge.NewEventRuleRepo(dataData)
|
||||
badgeAwardService := badge2.NewBadgeAwardService(badgeAwardRepo, badgeRepo, userCommon, objService, noticequeueService)
|
||||
badgeEventService := badge2.NewBadgeEventService(dataData, eventqueueService, badgeRepo, eventRuleRepo, badgeAwardService)
|
||||
badgeService := badge2.NewBadgeService(badgeRepo, badgeGroupRepo, badgeAwardRepo, badgeEventService, siteInfoCommonService)
|
||||
badgeController := controller.NewBadgeController(badgeService, badgeAwardService)
|
||||
controller_adminBadgeController := controller_admin.NewBadgeController(badgeService)
|
||||
apiKeyService := apikey.NewAPIKeyService(apiKeyRepo)
|
||||
adminAPIKeyController := controller_admin.NewAdminAPIKeyController(apiKeyService)
|
||||
featureToggleService := feature_toggle.NewFeatureToggleService(siteInfoRepo)
|
||||
embeddingService := embedding.NewEmbeddingService()
|
||||
mcpController := controller.NewMCPController(searchService, siteInfoCommonService, tagCommonService, questionCommon, commentRepo, userCommon, answerRepo, featureToggleService, embeddingService)
|
||||
aiConversationRepo := ai_conversation.NewAIConversationRepo(dataData)
|
||||
aiConversationService := ai_conversation2.NewAIConversationService(aiConversationRepo, userCommon)
|
||||
aiController := controller.NewAIController(searchService, siteInfoCommonService, tagCommonService, questionCommon, commentRepo, userCommon, answerRepo, mcpController, aiConversationService, featureToggleService)
|
||||
aiConversationController := controller.NewAIConversationController(aiConversationService, featureToggleService)
|
||||
aiConversationAdminController := controller_admin.NewAIConversationAdminController(aiConversationService, featureToggleService)
|
||||
answerAPIRouter := router.NewAnswerAPIRouter(langController, userController, commentController, reportController, voteController, tagController, followController, collectionController, questionController, answerController, searchController, revisionController, rankController, userAdminController, reasonController, themeController, siteInfoController, controllerSiteInfoController, notificationController, dashboardController, uploadController, activityController, roleController, pluginController, permissionController, userPluginController, reviewController, metaController, badgeController, controller_adminBadgeController, adminAPIKeyController, aiController, aiConversationController, aiConversationAdminController, mcpController)
|
||||
swaggerRouter := router.NewSwaggerRouter(swaggerConf)
|
||||
uiRouter := router.NewUIRouter(controllerSiteInfoController, siteInfoCommonService)
|
||||
authUserMiddleware := middleware.NewAuthUserMiddleware(authService, siteInfoCommonService)
|
||||
avatarMiddleware := middleware.NewAvatarMiddleware(serviceConf, uploaderService)
|
||||
shortIDMiddleware := middleware.NewShortIDMiddleware(siteInfoCommonService)
|
||||
templateRenderController := templaterender.NewTemplateRenderController(questionService, userService, tagService, answerService, commentService, siteInfoCommonService, questionRepo)
|
||||
templateController := controller.NewTemplateController(templateRenderController, siteInfoCommonService, eventqueueService, userService, questionService)
|
||||
templateRouter := router.NewTemplateRouter(templateController, templateRenderController, siteInfoController, authUserMiddleware)
|
||||
connectorController := controller.NewConnectorController(siteInfoCommonService, emailService, userExternalLoginService)
|
||||
userCenterLoginService := user_external_login2.NewUserCenterLoginService(userRepo, userCommon, userExternalLoginRepo, userActiveActivityRepo, siteInfoCommonService)
|
||||
userCenterController := controller.NewUserCenterController(userCenterLoginService, siteInfoCommonService)
|
||||
captchaController := controller.NewCaptchaController()
|
||||
embedController := controller.NewEmbedController()
|
||||
renderController := controller.NewRenderController()
|
||||
sidebarController := controller.NewSidebarController()
|
||||
pluginAPIRouter := router.NewPluginAPIRouter(connectorController, userCenterController, captchaController, embedController, renderController, sidebarController)
|
||||
ginEngine := server.NewHTTPServer(debug, staticRouter, answerAPIRouter, swaggerRouter, uiRouter, authUserMiddleware, avatarMiddleware, shortIDMiddleware, templateRouter, pluginAPIRouter, uiConf)
|
||||
scheduledTaskManager := cron.NewScheduledTaskManager(siteInfoCommonService, questionService, fileRecordService, userAdminService, serviceConf)
|
||||
application := newApplication(serverConf, ginEngine, scheduledTaskManager)
|
||||
return application, func() {
|
||||
cleanup2()
|
||||
cleanup()
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user