Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update the codes by the clean arch #184

Merged
merged 3 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ config.yml

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work*
38 changes: 7 additions & 31 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,18 @@ THE SOFTWARE.
package cmd

import (
"fmt"

"github.com/gin-gonic/gin"
"github.com/saltbo/gopkg/ginutil"
"github.com/saltbo/zpan/internal/app"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/saltbo/zpan/internal/app/api"
"github.com/saltbo/zpan/internal/app/dao"
"github.com/saltbo/zpan/web"
)

// serverCmd represents the server command
var serverCmd = &cobra.Command{
Use: "server",
Short: "A cloud disk base on the cloud service.",
Run: func(cmd *cobra.Command, args []string) {
serverRun()
RunE: func(cmd *cobra.Command, args []string) error {
s := app.NewServer()
return s.Run()
},
}

Expand All @@ -48,28 +42,10 @@ func init() {

serverCmd.Flags().Int("port", 8222, "server port")

viper.BindPFlags(serverCmd.Flags())
}

func serverRun() {
//gin.SetMode(gin.ReleaseMode)
if viper.IsSet("installed") {
dao.Init(viper.GetString("database.driver"), viper.GetString("database.dsn"))
}

//if conf.TLS.Enabled {
// //go startTls(ge, tlsAddr, conf.TLS.Auto, conf.TLS.CacheDir, conf.Server.Domain, conf.TLS.CertPath, conf.TLS.CertkeyPath)
// go startTls(ge, conf)
//}

ge := gin.Default()
api.SetupRoutes(ge)
web.SetupRoutes(ge)
addr := fmt.Sprintf(":%d", viper.GetInt("port"))
ginutil.Startup(ge, addr)
_ = viper.BindPFlags(serverCmd.Flags())
}

//func startTls(e *gin.Engine, conf *config.Config) {
// func startTls(e *gin.Engine, conf *config.Config) {
// tlsAddr := fmt.Sprintf(":%d", conf.Server.SSLPort)
// if conf.TLS.Auto {
// m := autocert.Manager{
Expand Down Expand Up @@ -110,4 +86,4 @@ func serverRun() {
// }()
// httputil.SetupGracefulStop(srv)
// }
//}
// }
78 changes: 43 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,74 +11,78 @@ require (
github.com/gin-gonic/gin v1.9.1
github.com/go-oauth2/oauth2/v4 v4.5.0
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/uuid v1.1.1
github.com/saltbo/gopkg v0.0.0-20210807060851-127038a22f0d
github.com/google/uuid v1.3.0
github.com/google/wire v0.5.0
github.com/saltbo/gopkg v0.0.0-20230725153125-0d57fc71396d
github.com/saltbo/gopkg/ginutil v0.0.0-20230725153125-0d57fc71396d
github.com/saltbo/gopkg/httputil v0.0.0-20230725152854-70fe999b57ba
github.com/saltbo/gopkg/strutil v0.0.0-20230725151952-d01c3f6b1539
github.com/samber/lo v1.38.1
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.7.1
github.com/storyicon/grbac v0.0.0-20200224041032-a0461737df7e
github.com/stretchr/testify v1.8.3
github.com/swaggo/swag v1.7.0
github.com/swaggo/swag v1.8.12
github.com/tencentyun/cos-go-sdk-v5 v0.7.18
github.com/upyun/go-sdk/v3 v3.0.2
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/mysql v1.0.3
gorm.io/driver/postgres v1.0.6
gorm.io/driver/sqlite v1.1.4
gorm.io/driver/sqlserver v1.0.5
gorm.io/gorm v1.20.11
gorm.io/driver/mysql v1.5.1
gorm.io/driver/postgres v1.5.0
gorm.io/driver/sqlite v1.5.0
gorm.io/driver/sqlserver v1.4.1
gorm.io/gen v0.3.23
gorm.io/gorm v1.25.2
gorm.io/plugin/dbresolver v1.3.0
)

require (
github.com/DATA-DOG/go-sqlmock v1.5.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-openapi/jsonpointer v0.19.3 // indirect
github.com/go-openapi/jsonreference v0.19.4 // indirect
github.com/go-openapi/spec v0.19.14 // indirect
github.com/go-openapi/swag v0.19.11 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/go-resty/resty/v2 v2.3.0 // indirect
github.com/go-sql-driver/mysql v1.5.0 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-immutable-radix v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.8.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.0.6 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.6.2 // indirect
github.com/jackc/pgx/v4 v4.10.1 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.3.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.1 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jmespath/go-jmespath v0.3.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-sqlite3 v1.14.5 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/microsoft/go-mssqldb v0.17.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -87,6 +91,8 @@ require (
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/saltbo/gopkg/sliceutil v0.0.0-20221024031008-7af9787873bd // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
Expand All @@ -105,18 +111,20 @@ require (
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/tools v0.11.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c // indirect
gorm.io/hints v1.1.0 // indirect
)

//replace github.com/saltbo/gopkg => /opt/works/gopkg
Loading