diff --git a/.air.conf b/.air.conf index ba3cff6e..c29c615d 100644 --- a/.air.conf +++ b/.air.conf @@ -19,7 +19,7 @@ log = "air_errors.log" # Watch these filename extensions. include_ext = ["go", "tpl", "tmpl", "html"] # Ignore these filename extensions or directories. -exclude_dir = ["log", "tmp", "vendor", "node_modules", "template", "static", "docs", "bin", "sitemap", "data", "config", "pid"] +exclude_dir = ["log", "tmp", "vendor", "node_modules", "template", "static", "docs", "bin", "sitemap", "data", "config", "pid", "docker"] # There's no necessary to trigger build each time file changes if it's too frequency. delay = 1000 # ms diff --git a/cmd/server.go b/cmd/server.go index af65870c..36416efb 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -12,7 +12,7 @@ import ( "flag" "time" - "github.com/studygolang/studygolang/logic" + "github.com/studygolang/studygolang/internal/logic" "github.com/polaris1119/config" "github.com/polaris1119/logger" @@ -31,6 +31,7 @@ func IndexingServer() { } if *manualIndex { + logger.Infoln("manual indexing") indexing(true) } diff --git a/cmd/studygolang/background.go b/cmd/studygolang/background.go index ecdaccfa..0329b446 100644 --- a/cmd/studygolang/background.go +++ b/cmd/studygolang/background.go @@ -17,8 +17,8 @@ import ( "github.com/studygolang/studygolang/cmd" "github.com/studygolang/studygolang/db" "github.com/studygolang/studygolang/global" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" ) var ( diff --git a/cmd/studygolang/main.go b/cmd/studygolang/main.go index c0eb0b3a..86aa563e 100644 --- a/cmd/studygolang/main.go +++ b/cmd/studygolang/main.go @@ -16,11 +16,11 @@ import ( "github.com/studygolang/studygolang/cmd" "github.com/studygolang/studygolang/global" - "github.com/studygolang/studygolang/http/controller" - "github.com/studygolang/studygolang/http/controller/admin" - "github.com/studygolang/studygolang/http/controller/app" - pwm "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" + "github.com/studygolang/studygolang/internal/http/controller" + "github.com/studygolang/studygolang/internal/http/controller/admin" + "github.com/studygolang/studygolang/internal/http/controller/app" + pwm "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" thirdmw "github.com/studygolang/studygolang/middleware" "github.com/fatih/structs" diff --git a/docker-compose.yml b/docker-compose.yml index 8807d74d..c8cbb7f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,11 +24,7 @@ services: restart: always nginx: container_name: nginx - build: ./nginx - depends_on: - - play - links: - - play:play + build: ./docker/nginx volumes: - /data/www:/data/www:rw - ./nginx/conf.d:/etc/nginx/conf.d:ro @@ -69,4 +65,4 @@ services: networks: app_net: - external: true \ No newline at end of file + external: true diff --git a/global/app.go b/global/app.go index 86bdfa2c..71185d08 100644 --- a/global/app.go +++ b/global/app.go @@ -31,14 +31,14 @@ import ( "sync" "time" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/config" ) const ( - DefaultCDNHttp = "http://test.static.studygolang.com/" - DefaultCDNHttps = "https://static.studygolang.com/" + DefaultCDNHttp = "http://test.static.golangjob.cn/" + DefaultCDNHttps = "https://static.golangjob.cn/" ) var Build string diff --git a/go.mod b/go.mod index 1ca0ca5e..2d8b0c4b 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/polaris1119/goutils v0.0.0-20190815094239-73c47df9b896 github.com/polaris1119/keyword v0.0.0-20170608075927-96ae6735f2f2 github.com/polaris1119/logger v0.0.0-20170422061149-0233d014769e - github.com/polaris1119/nosql v0.0.0-20181019111233-3852ef28d084 + github.com/polaris1119/nosql v0.0.0-20230923063022-e8124f458d80 github.com/polaris1119/set v0.1.1-0.20160423093427-654439414ced github.com/polaris1119/slices v0.0.0-20160517071324-6ecacdb3cd38 github.com/polaris1119/snowflake v0.1.0 diff --git a/go.sum b/go.sum index d432ea5f..23f355a7 100644 --- a/go.sum +++ b/go.sum @@ -362,8 +362,8 @@ github.com/polaris1119/keyword v0.0.0-20170608075927-96ae6735f2f2 h1:63TyJE7nj3e github.com/polaris1119/keyword v0.0.0-20170608075927-96ae6735f2f2/go.mod h1:YYx1sYXgS43cG1iH0cXYFcibESl8azhUrA6W10gYb9E= github.com/polaris1119/logger v0.0.0-20170422061149-0233d014769e h1:HSeLmpKe7eny4fT5tdnYfQffWvx6aKCdzIcW/MZWt3I= github.com/polaris1119/logger v0.0.0-20170422061149-0233d014769e/go.mod h1:7wFzOsSeMeuwhnZItJVfX1WClNpCyXuO0kj+ifdK+LQ= -github.com/polaris1119/nosql v0.0.0-20181019111233-3852ef28d084 h1:tgfnz7bUVQ0MtsvaT3R47E083V7FVP0GIDsmXhkTdD0= -github.com/polaris1119/nosql v0.0.0-20181019111233-3852ef28d084/go.mod h1:AQkEEdvgfOXmx5L7HLvGLZPWnbNa/EIOEpMhTTOor3g= +github.com/polaris1119/nosql v0.0.0-20230923063022-e8124f458d80 h1:I03kiaehuc292z3uirGDCP57KSOOS79+R6FkFJ0ci8A= +github.com/polaris1119/nosql v0.0.0-20230923063022-e8124f458d80/go.mod h1:AQkEEdvgfOXmx5L7HLvGLZPWnbNa/EIOEpMhTTOor3g= github.com/polaris1119/set v0.1.1-0.20160423093427-654439414ced h1:5E6fZkU0PW8RIoOOOQq+NJ6ICZDtk/3mON49Ezl0raY= github.com/polaris1119/set v0.1.1-0.20160423093427-654439414ced/go.mod h1:f3pW74DeWib9bLGgMImip5zikwTB5dQ53JVrmT3CYrQ= github.com/polaris1119/slices v0.0.0-20160517071324-6ecacdb3cd38 h1:DUG5gZoTQGtKgQogadMFJ2hUCchqPBchezdHsgncEj4= diff --git a/internal/dao/cache/feed.go b/internal/dao/cache/feed.go new file mode 100644 index 00000000..30ed9c14 --- /dev/null +++ b/internal/dao/cache/feed.go @@ -0,0 +1,75 @@ +package cache + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/polaris1119/nosql" + "github.com/studygolang/studygolang/internal/model" +) + +type feedCache struct{} + +var Feed feedCache + +func (feedCache) GetTop(ctx context.Context) []*model.Feed { + redisClient := nosql.NewRedisClient() + defer redisClient.Close() + + s := redisClient.GET("feed:top") + if s == "" { + return nil + } + + if s == "notop" { + return []*model.Feed{} + } + + feeds := make([]*model.Feed, 0) + err := json.Unmarshal([]byte(s), &feeds) + if err != nil { + return nil + } + + return feeds +} + +func (feedCache) SetTop(ctx context.Context, feeds []*model.Feed) { + redisClient := nosql.NewRedisClient() + defer redisClient.Close() + + val := "notop" + if len(feeds) > 0 { + b, _ := json.Marshal(feeds) + val = string(b) + } + + redisClient.SET("feed:top", val, 300) +} + +func (feedCache) GetList(ctx context.Context, p int) []*model.Feed { + redisClient := nosql.NewRedisClient() + defer redisClient.Close() + + s := redisClient.GET("feed:list:" + strconv.Itoa(p)) + if s == "" { + return nil + } + + feeds := make([]*model.Feed, 0) + err := json.Unmarshal([]byte(s), &feeds) + if err != nil { + return nil + } + + return feeds +} + +func (feedCache) SetList(ctx context.Context, p int, feeds []*model.Feed) { + redisClient := nosql.NewRedisClient() + defer redisClient.Close() + + b, _ := json.Marshal(feeds) + redisClient.SET("feed:list:"+strconv.Itoa(p), string(b), 300) +} diff --git a/http/controller/account.go b/internal/http/controller/account.go similarity index 97% rename from http/controller/account.go rename to internal/http/controller/account.go index f914cb48..5fd1bbd2 100644 --- a/http/controller/account.go +++ b/internal/http/controller/account.go @@ -14,11 +14,11 @@ import ( "time" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - . "github.com/studygolang/studygolang/http/internal/helper" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + . "github.com/studygolang/studygolang/internal/http/internal/helper" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "github.com/dchest/captcha" diff --git a/http/controller/admin/article.go b/internal/http/controller/admin/article.go similarity index 97% rename from http/controller/admin/article.go rename to internal/http/controller/admin/article.go index 5c556d9c..ff9d5d44 100644 --- a/http/controller/admin/article.go +++ b/internal/http/controller/admin/article.go @@ -11,8 +11,8 @@ import ( "strings" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/admin/authority.go b/internal/http/controller/admin/authority.go similarity index 98% rename from http/controller/admin/authority.go rename to internal/http/controller/admin/authority.go index fb2b434c..7118fe97 100644 --- a/http/controller/admin/authority.go +++ b/internal/http/controller/admin/authority.go @@ -10,7 +10,7 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/admin/base.go b/internal/http/controller/admin/base.go similarity index 95% rename from http/controller/admin/base.go rename to internal/http/controller/admin/base.go index 848ccba1..215d8328 100644 --- a/http/controller/admin/base.go +++ b/internal/http/controller/admin/base.go @@ -11,8 +11,8 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/admin/index.go b/internal/http/controller/admin/index.go similarity index 100% rename from http/controller/admin/index.go rename to internal/http/controller/admin/index.go diff --git a/http/controller/admin/metrics.go b/internal/http/controller/admin/metrics.go similarity index 94% rename from http/controller/admin/metrics.go rename to internal/http/controller/admin/metrics.go index fb0e8ac8..5f7d83be 100644 --- a/http/controller/admin/metrics.go +++ b/internal/http/controller/admin/metrics.go @@ -14,8 +14,8 @@ import ( "time" "github.com/studygolang/studygolang/global" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/admin/node.go b/internal/http/controller/admin/node.go similarity index 95% rename from http/controller/admin/node.go rename to internal/http/controller/admin/node.go index 7a49d8cd..54883d76 100644 --- a/http/controller/admin/node.go +++ b/internal/http/controller/admin/node.go @@ -9,8 +9,8 @@ package admin import ( "github.com/studygolang/studygolang/context" "github.com/studygolang/studygolang/global" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/admin/project.go b/internal/http/controller/admin/project.go similarity index 97% rename from http/controller/admin/project.go rename to internal/http/controller/admin/project.go index 9ee0e292..56960d31 100644 --- a/http/controller/admin/project.go +++ b/internal/http/controller/admin/project.go @@ -11,8 +11,8 @@ import ( "strings" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/admin/reading.go b/internal/http/controller/admin/reading.go similarity index 95% rename from http/controller/admin/reading.go rename to internal/http/controller/admin/reading.go index 6f6f040f..c5b47fd1 100644 --- a/http/controller/admin/reading.go +++ b/internal/http/controller/admin/reading.go @@ -10,8 +10,8 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/admin/routes.go b/internal/http/controller/admin/routes.go similarity index 100% rename from http/controller/admin/routes.go rename to internal/http/controller/admin/routes.go diff --git a/http/controller/admin/rule.go b/internal/http/controller/admin/rule.go similarity index 96% rename from http/controller/admin/rule.go rename to internal/http/controller/admin/rule.go index 5502ae1e..e3adf011 100644 --- a/http/controller/admin/rule.go +++ b/internal/http/controller/admin/rule.go @@ -10,8 +10,8 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/admin/setting.go b/internal/http/controller/admin/setting.go similarity index 97% rename from http/controller/admin/setting.go rename to internal/http/controller/admin/setting.go index a8ac46e6..2d9fb89c 100644 --- a/http/controller/admin/setting.go +++ b/internal/http/controller/admin/setting.go @@ -8,7 +8,7 @@ package admin import ( "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/admin/tool.go b/internal/http/controller/admin/tool.go similarity index 91% rename from http/controller/admin/tool.go rename to internal/http/controller/admin/tool.go index 50262086..b7860740 100644 --- a/http/controller/admin/tool.go +++ b/internal/http/controller/admin/tool.go @@ -7,7 +7,7 @@ package admin import ( - "github.com/studygolang/studygolang/logic" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/admin/topic.go b/internal/http/controller/admin/topic.go similarity index 95% rename from http/controller/admin/topic.go rename to internal/http/controller/admin/topic.go index 50d8967d..82a14140 100644 --- a/http/controller/admin/topic.go +++ b/internal/http/controller/admin/topic.go @@ -10,8 +10,8 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/admin/user.go b/internal/http/controller/admin/user.go similarity index 96% rename from http/controller/admin/user.go rename to internal/http/controller/admin/user.go index 75e125eb..5901b36d 100644 --- a/http/controller/admin/user.go +++ b/internal/http/controller/admin/user.go @@ -8,8 +8,8 @@ package admin import ( "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/app/article.go b/internal/http/controller/app/article.go similarity index 93% rename from http/controller/app/article.go rename to internal/http/controller/app/article.go index 8215c6d8..1f22c385 100644 --- a/http/controller/app/article.go +++ b/internal/http/controller/app/article.go @@ -8,9 +8,9 @@ package app import ( "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/app/base.go b/internal/http/controller/app/base.go similarity index 93% rename from http/controller/app/base.go rename to internal/http/controller/app/base.go index 480ea31a..27720f3d 100644 --- a/http/controller/app/base.go +++ b/internal/http/controller/app/base.go @@ -11,8 +11,8 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" "github.com/polaris1119/logger" diff --git a/http/controller/app/comment.go b/internal/http/controller/app/comment.go similarity index 86% rename from http/controller/app/comment.go rename to internal/http/controller/app/comment.go index a73e8d53..2067d29e 100644 --- a/http/controller/app/comment.go +++ b/internal/http/controller/app/comment.go @@ -8,9 +8,9 @@ package app import ( "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/app/doc.go b/internal/http/controller/app/doc.go similarity index 100% rename from http/controller/app/doc.go rename to internal/http/controller/app/doc.go diff --git a/http/controller/app/index.go b/internal/http/controller/app/index.go similarity index 94% rename from http/controller/app/index.go rename to internal/http/controller/app/index.go index 0c2568ca..96e5f541 100644 --- a/http/controller/app/index.go +++ b/internal/http/controller/app/index.go @@ -8,8 +8,8 @@ package app import ( "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/app/project.go b/internal/http/controller/app/project.go similarity index 92% rename from http/controller/app/project.go rename to internal/http/controller/app/project.go index 812f1bbe..c3cf4849 100644 --- a/http/controller/app/project.go +++ b/internal/http/controller/app/project.go @@ -8,9 +8,9 @@ package app import ( "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/app/resource.go b/internal/http/controller/app/resource.go similarity index 90% rename from http/controller/app/resource.go rename to internal/http/controller/app/resource.go index ce4b0407..4861f7fd 100644 --- a/http/controller/app/resource.go +++ b/internal/http/controller/app/resource.go @@ -8,9 +8,9 @@ package app import ( "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/app/routes.go b/internal/http/controller/app/routes.go similarity index 100% rename from http/controller/app/routes.go rename to internal/http/controller/app/routes.go diff --git a/http/controller/app/topic.go b/internal/http/controller/app/topic.go similarity index 96% rename from http/controller/app/topic.go rename to internal/http/controller/app/topic.go index 5ca2bb5d..afef2bd6 100644 --- a/http/controller/app/topic.go +++ b/internal/http/controller/app/topic.go @@ -11,10 +11,10 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/app/user.go b/internal/http/controller/app/user.go similarity index 91% rename from http/controller/app/user.go rename to internal/http/controller/app/user.go index 9790d4aa..487c285b 100644 --- a/http/controller/app/user.go +++ b/internal/http/controller/app/user.go @@ -8,10 +8,10 @@ package app import ( "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - . "github.com/studygolang/studygolang/http/internal/helper" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + . "github.com/studygolang/studygolang/internal/http/internal/helper" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/app/wechat.go b/internal/http/controller/app/wechat.go similarity index 96% rename from http/controller/app/wechat.go rename to internal/http/controller/app/wechat.go index 4b2b74f3..cd8b5920 100644 --- a/http/controller/app/wechat.go +++ b/internal/http/controller/app/wechat.go @@ -11,8 +11,8 @@ import ( "strconv" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/article.go b/internal/http/controller/article.go similarity index 97% rename from http/controller/article.go rename to internal/http/controller/article.go index 07effc54..1558163f 100644 --- a/http/controller/article.go +++ b/internal/http/controller/article.go @@ -18,10 +18,10 @@ import ( "github.com/studygolang/studygolang/context" "github.com/studygolang/studygolang/echoutils" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" ) diff --git a/http/controller/balance.go b/internal/http/controller/balance.go similarity index 90% rename from http/controller/balance.go rename to internal/http/controller/balance.go index 5277943a..dbc8dab1 100644 --- a/http/controller/balance.go +++ b/internal/http/controller/balance.go @@ -9,9 +9,9 @@ package controller import ( "github.com/polaris1119/goutils" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/base.go b/internal/http/controller/base.go similarity index 94% rename from http/controller/base.go rename to internal/http/controller/base.go index bd89b15f..34a264c8 100644 --- a/http/controller/base.go +++ b/internal/http/controller/base.go @@ -12,8 +12,8 @@ import ( "strings" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/book.go b/internal/http/controller/book.go similarity index 93% rename from http/controller/book.go rename to internal/http/controller/book.go index 2c7bf5c5..5cfd36d8 100644 --- a/http/controller/book.go +++ b/internal/http/controller/book.go @@ -14,10 +14,10 @@ import ( "github.com/polaris1119/goutils" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" ) // 在需要评论(喜欢)且要回调的地方注册评论(喜欢)对象 diff --git a/http/controller/captcha.go b/internal/http/controller/captcha.go similarity index 92% rename from http/controller/captcha.go rename to internal/http/controller/captcha.go index c3d2fe5c..119cec78 100644 --- a/http/controller/captcha.go +++ b/internal/http/controller/captcha.go @@ -7,7 +7,7 @@ package controller import ( - . "github.com/studygolang/studygolang/http" + . "github.com/studygolang/studygolang/internal/http" "github.com/dchest/captcha" echo "github.com/labstack/echo/v4" diff --git a/http/controller/comment.go b/internal/http/controller/comment.go similarity index 96% rename from http/controller/comment.go rename to internal/http/controller/comment.go index 53bd2ebc..a0d40168 100644 --- a/http/controller/comment.go +++ b/internal/http/controller/comment.go @@ -12,10 +12,10 @@ import ( "strconv" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/download.go b/internal/http/controller/download.go similarity index 95% rename from http/controller/download.go rename to internal/http/controller/download.go index 6fd4991a..ddab8e44 100644 --- a/http/controller/download.go +++ b/internal/http/controller/download.go @@ -14,8 +14,8 @@ import ( "time" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/config" @@ -36,7 +36,7 @@ func (self DownloadController) RegisterRoute(g *echo.Group) { func (DownloadController) GoDl(ctx echo.Context) error { downloads := logic.DefaultDownload.FindAll(context.EchoContext(ctx)) - featured := make([]*model.Download, 0, 4) + featured := make([]*model.Download, 0, 5) stables := make(map[string][]*model.Download) stableVersions := make([]string, 0, 2) unstables := make(map[string][]*model.Download) @@ -52,7 +52,7 @@ func (DownloadController) GoDl(ctx echo.Context) error { } stables[version] = append(stables[version], download) - if download.IsRecommend && len(featured) < 4 { + if download.IsRecommend && len(featured) < 5 { featured = append(featured, download) } } else if download.Category == model.DLUnstable { diff --git a/http/controller/favorite.go b/internal/http/controller/favorite.go similarity index 94% rename from http/controller/favorite.go rename to internal/http/controller/favorite.go index 7cf5af4b..01cdf577 100644 --- a/http/controller/favorite.go +++ b/internal/http/controller/favorite.go @@ -11,9 +11,9 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/feed.go b/internal/http/controller/feed.go similarity index 93% rename from http/controller/feed.go rename to internal/http/controller/feed.go index af9e58da..ea2e4e22 100644 --- a/http/controller/feed.go +++ b/internal/http/controller/feed.go @@ -11,9 +11,9 @@ import ( "net/http" "time" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/gorilla/feeds" echo "github.com/labstack/echo/v4" diff --git a/http/controller/gctt.go b/internal/http/controller/gctt.go similarity index 96% rename from http/controller/gctt.go rename to internal/http/controller/gctt.go index d9cbeb18..9af685e3 100644 --- a/http/controller/gctt.go +++ b/internal/http/controller/gctt.go @@ -16,10 +16,10 @@ import ( "strconv" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/config" diff --git a/http/controller/gift.go b/internal/http/controller/gift.go similarity index 90% rename from http/controller/gift.go rename to internal/http/controller/gift.go index 73e4de39..68af83fc 100644 --- a/http/controller/gift.go +++ b/internal/http/controller/gift.go @@ -8,9 +8,9 @@ package controller import ( "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/image.go b/internal/http/controller/image.go similarity index 98% rename from http/controller/image.go rename to internal/http/controller/image.go index c10ad2dd..6c05853a 100644 --- a/http/controller/image.go +++ b/internal/http/controller/image.go @@ -16,8 +16,8 @@ import ( "github.com/studygolang/studygolang/context" "github.com/studygolang/studygolang/global" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/index.go b/internal/http/controller/index.go similarity index 96% rename from http/controller/index.go rename to internal/http/controller/index.go index fd505fc1..a37f7079 100644 --- a/http/controller/index.go +++ b/internal/http/controller/index.go @@ -14,9 +14,9 @@ import ( "strings" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/labstack/echo/v4" "github.com/polaris1119/config" diff --git a/http/controller/install.go b/internal/http/controller/install.go similarity index 98% rename from http/controller/install.go rename to internal/http/controller/install.go index 08fbc6f2..8d3da960 100644 --- a/http/controller/install.go +++ b/internal/http/controller/install.go @@ -17,8 +17,8 @@ import ( "github.com/studygolang/studygolang/context" "github.com/studygolang/studygolang/db" "github.com/studygolang/studygolang/global" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/config" diff --git a/http/controller/install_unix.go b/internal/http/controller/install_unix.go similarity index 100% rename from http/controller/install_unix.go rename to internal/http/controller/install_unix.go diff --git a/http/controller/install_windows.go b/internal/http/controller/install_windows.go similarity index 100% rename from http/controller/install_windows.go rename to internal/http/controller/install_windows.go diff --git a/http/controller/interview.go b/internal/http/controller/interview.go similarity index 94% rename from http/controller/interview.go rename to internal/http/controller/interview.go index d474fb27..904c4533 100644 --- a/http/controller/interview.go +++ b/internal/http/controller/interview.go @@ -12,10 +12,10 @@ import ( "time" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/like.go b/internal/http/controller/like.go similarity index 87% rename from http/controller/like.go rename to internal/http/controller/like.go index 8248d037..fab3daa6 100644 --- a/http/controller/like.go +++ b/internal/http/controller/like.go @@ -10,9 +10,9 @@ package controller import ( "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" echo "github.com/labstack/echo/v4" diff --git a/http/controller/link.go b/internal/http/controller/link.go similarity index 93% rename from http/controller/link.go rename to internal/http/controller/link.go index 0c5eb4a9..b92846d6 100644 --- a/http/controller/link.go +++ b/internal/http/controller/link.go @@ -8,7 +8,7 @@ package controller import ( "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/message.go b/internal/http/controller/message.go similarity index 95% rename from http/controller/message.go rename to internal/http/controller/message.go index a79a9a80..3c2588c1 100644 --- a/http/controller/message.go +++ b/internal/http/controller/message.go @@ -12,9 +12,9 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/mission.go b/internal/http/controller/mission.go similarity index 91% rename from http/controller/mission.go rename to internal/http/controller/mission.go index 9f75db97..19f30fd4 100644 --- a/http/controller/mission.go +++ b/internal/http/controller/mission.go @@ -11,9 +11,9 @@ import ( "strconv" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/times" diff --git a/http/controller/oauth.go b/internal/http/controller/oauth.go similarity index 94% rename from http/controller/oauth.go rename to internal/http/controller/oauth.go index 628352e9..7a073fe9 100644 --- a/http/controller/oauth.go +++ b/internal/http/controller/oauth.go @@ -10,9 +10,9 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/other.go b/internal/http/controller/other.go similarity index 100% rename from http/controller/other.go rename to internal/http/controller/other.go diff --git a/http/controller/project.go b/internal/http/controller/project.go similarity index 96% rename from http/controller/project.go rename to internal/http/controller/project.go index 0b46ec4a..18a90860 100644 --- a/http/controller/project.go +++ b/internal/http/controller/project.go @@ -15,10 +15,10 @@ import ( "github.com/polaris1119/goutils" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" ) diff --git a/http/controller/reading.go b/internal/http/controller/reading.go similarity index 95% rename from http/controller/reading.go rename to internal/http/controller/reading.go index 4ebf3405..754a6f6f 100644 --- a/http/controller/reading.go +++ b/internal/http/controller/reading.go @@ -10,8 +10,8 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/resource.go b/internal/http/controller/resource.go similarity index 96% rename from http/controller/resource.go rename to internal/http/controller/resource.go index d601b7c8..857e845c 100644 --- a/http/controller/resource.go +++ b/internal/http/controller/resource.go @@ -11,10 +11,10 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "github.com/dchest/captcha" diff --git a/http/controller/routes.go b/internal/http/controller/routes.go similarity index 100% rename from http/controller/routes.go rename to internal/http/controller/routes.go diff --git a/http/controller/search.go b/internal/http/controller/search.go similarity index 97% rename from http/controller/search.go rename to internal/http/controller/search.go index af2dc448..d72768dc 100644 --- a/http/controller/search.go +++ b/internal/http/controller/search.go @@ -6,7 +6,7 @@ import ( "net/url" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/sidebar.go b/internal/http/controller/sidebar.go similarity index 98% rename from http/controller/sidebar.go rename to internal/http/controller/sidebar.go index a78138d4..9e30552e 100644 --- a/http/controller/sidebar.go +++ b/internal/http/controller/sidebar.go @@ -11,8 +11,8 @@ import ( "time" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/subject.go b/internal/http/controller/subject.go similarity index 96% rename from http/controller/subject.go rename to internal/http/controller/subject.go index 04fa1a6d..60b40bc8 100644 --- a/http/controller/subject.go +++ b/internal/http/controller/subject.go @@ -12,10 +12,10 @@ import ( "github.com/studygolang/studygolang/context" "github.com/studygolang/studygolang/global" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/top.go b/internal/http/controller/top.go similarity index 95% rename from http/controller/top.go rename to internal/http/controller/top.go index 33dfdd9d..469615a0 100644 --- a/http/controller/top.go +++ b/internal/http/controller/top.go @@ -8,7 +8,7 @@ package controller import ( "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" "github.com/polaris1119/times" diff --git a/http/controller/topic.go b/internal/http/controller/topic.go similarity index 98% rename from http/controller/topic.go rename to internal/http/controller/topic.go index 3614072c..4c8897dc 100644 --- a/http/controller/topic.go +++ b/internal/http/controller/topic.go @@ -12,10 +12,10 @@ import ( "strconv" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "github.com/dchest/captcha" diff --git a/http/controller/user.go b/internal/http/controller/user.go similarity index 98% rename from http/controller/user.go rename to internal/http/controller/user.go index 8a315ac7..595bc8ce 100644 --- a/http/controller/user.go +++ b/internal/http/controller/user.go @@ -11,8 +11,8 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/websocket.go b/internal/http/controller/websocket.go similarity index 97% rename from http/controller/websocket.go rename to internal/http/controller/websocket.go index f2679a00..cd3f59d5 100644 --- a/http/controller/websocket.go +++ b/internal/http/controller/websocket.go @@ -10,7 +10,7 @@ import ( "sync/atomic" "time" - "github.com/studygolang/studygolang/logic" + "github.com/studygolang/studygolang/internal/logic" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/controller/wechat.go b/internal/http/controller/wechat.go similarity index 93% rename from http/controller/wechat.go rename to internal/http/controller/wechat.go index 5a54a887..4e80d6fa 100644 --- a/http/controller/wechat.go +++ b/internal/http/controller/wechat.go @@ -11,8 +11,8 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" ) diff --git a/http/controller/wide.go b/internal/http/controller/wide.go similarity index 100% rename from http/controller/wide.go rename to internal/http/controller/wide.go diff --git a/http/controller/wiki.go b/internal/http/controller/wiki.go similarity index 95% rename from http/controller/wiki.go rename to internal/http/controller/wiki.go index 0fca04d6..35c9d1dc 100644 --- a/http/controller/wiki.go +++ b/internal/http/controller/wiki.go @@ -10,10 +10,10 @@ import ( "net/http" "github.com/studygolang/studygolang/context" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/http/middleware" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/http/middleware" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/goutils" diff --git a/http/http.go b/internal/http/http.go similarity index 99% rename from http/http.go rename to internal/http/http.go index dde4b472..0b17c568 100644 --- a/http/http.go +++ b/internal/http/http.go @@ -19,8 +19,8 @@ import ( "github.com/studygolang/studygolang/context" "github.com/studygolang/studygolang/global" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "github.com/gorilla/sessions" diff --git a/http/internal/helper/account.go b/internal/http/internal/helper/account.go similarity index 100% rename from http/internal/helper/account.go rename to internal/http/internal/helper/account.go diff --git a/http/middleware/admin.go b/internal/http/middleware/admin.go similarity index 93% rename from http/middleware/admin.go rename to internal/http/middleware/admin.go index ca45f330..5686c1da 100644 --- a/http/middleware/admin.go +++ b/internal/http/middleware/admin.go @@ -7,9 +7,10 @@ package middleware import ( - "github.com/studygolang/studygolang/model" "net/http" + "github.com/studygolang/studygolang/internal/model" + echo "github.com/labstack/echo/v4" ) diff --git a/http/middleware/balance_check.go b/internal/http/middleware/balance_check.go similarity index 96% rename from http/middleware/balance_check.go rename to internal/http/middleware/balance_check.go index 637ca51d..0d449ff2 100644 --- a/http/middleware/balance_check.go +++ b/internal/http/middleware/balance_check.go @@ -9,7 +9,7 @@ package middleware import ( "net/http" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" echo "github.com/labstack/echo/v4" diff --git a/http/middleware/captcha.go b/internal/http/middleware/captcha.go similarity index 90% rename from http/middleware/captcha.go rename to internal/http/middleware/captcha.go index b85ef29b..a659ea89 100644 --- a/http/middleware/captcha.go +++ b/internal/http/middleware/captcha.go @@ -9,8 +9,8 @@ package middleware import ( "net/http" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "github.com/dchest/captcha" diff --git a/http/middleware/http_error.go b/internal/http/middleware/http_error.go similarity index 96% rename from http/middleware/http_error.go rename to internal/http/middleware/http_error.go index 2966d240..99dda9ab 100644 --- a/http/middleware/http_error.go +++ b/internal/http/middleware/http_error.go @@ -9,7 +9,7 @@ package middleware import ( "net/http" - . "github.com/studygolang/studygolang/http" + . "github.com/studygolang/studygolang/internal/http" "github.com/studygolang/studygolang/util" echo "github.com/labstack/echo/v4" diff --git a/http/middleware/installed.go b/internal/http/middleware/installed.go similarity index 100% rename from http/middleware/installed.go rename to internal/http/middleware/installed.go diff --git a/http/middleware/login.go b/internal/http/middleware/login.go similarity index 96% rename from http/middleware/login.go rename to internal/http/middleware/login.go index 8ae352ef..c4b043c8 100644 --- a/http/middleware/login.go +++ b/internal/http/middleware/login.go @@ -15,9 +15,9 @@ import ( mycontext "github.com/studygolang/studygolang/context" "github.com/studygolang/studygolang/db" - . "github.com/studygolang/studygolang/http" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/internal/http" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "github.com/gorilla/context" diff --git a/http/middleware/notice.go b/internal/http/middleware/notice.go similarity index 92% rename from http/middleware/notice.go rename to internal/http/middleware/notice.go index e39fa0a8..fabe6e07 100644 --- a/http/middleware/notice.go +++ b/internal/http/middleware/notice.go @@ -10,8 +10,8 @@ import ( "fmt" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" ) diff --git a/http/middleware/sensitive.go b/internal/http/middleware/sensitive.go similarity index 97% rename from http/middleware/sensitive.go rename to internal/http/middleware/sensitive.go index a97bffb7..790e46a2 100644 --- a/http/middleware/sensitive.go +++ b/internal/http/middleware/sensitive.go @@ -12,8 +12,8 @@ import ( "time" "github.com/studygolang/studygolang/context" - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" echo "github.com/labstack/echo/v4" "github.com/polaris1119/config" diff --git a/logic/ad.go b/internal/logic/ad.go similarity index 96% rename from logic/ad.go rename to internal/logic/ad.go index dc62f8ab..b70e8abe 100644 --- a/logic/ad.go +++ b/internal/logic/ad.go @@ -8,7 +8,7 @@ package logic import ( . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/set" "golang.org/x/net/context" diff --git a/logic/article.go b/internal/logic/article.go similarity index 99% rename from logic/article.go rename to internal/logic/article.go index bd8fd8f0..3e8ee836 100644 --- a/logic/article.go +++ b/internal/logic/article.go @@ -31,7 +31,7 @@ import ( . "github.com/studygolang/studygolang/db" "github.com/studygolang/studygolang/global" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" ) type ArticleLogic struct{} diff --git a/logic/authority.go b/internal/logic/authority.go similarity index 99% rename from logic/authority.go rename to internal/logic/authority.go index caf41357..c2a9b857 100644 --- a/logic/authority.go +++ b/internal/logic/authority.go @@ -12,7 +12,7 @@ import ( . "github.com/studygolang/studygolang/db" "github.com/studygolang/studygolang/global" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/logger" "golang.org/x/net/context" diff --git a/logic/auto_crawl.go b/internal/logic/auto_crawl.go similarity index 99% rename from logic/auto_crawl.go rename to internal/logic/auto_crawl.go index 032f03d9..b70ac437 100644 --- a/logic/auto_crawl.go +++ b/internal/logic/auto_crawl.go @@ -18,7 +18,7 @@ import ( "time" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/PuerkitoBio/goquery" "github.com/polaris1119/config" diff --git a/logic/book.go b/internal/logic/book.go similarity index 100% rename from logic/book.go rename to internal/logic/book.go diff --git a/logic/comment.go b/internal/logic/comment.go similarity index 99% rename from logic/comment.go rename to internal/logic/comment.go index 41b37dff..e1628315 100644 --- a/logic/comment.go +++ b/internal/logic/comment.go @@ -16,7 +16,7 @@ import ( "time" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/fatih/structs" "github.com/polaris1119/goutils" diff --git a/logic/commenter.go b/internal/logic/commenter.go similarity index 100% rename from logic/commenter.go rename to internal/logic/commenter.go diff --git a/logic/common.go b/internal/logic/common.go similarity index 98% rename from logic/common.go rename to internal/logic/common.go index fa7ae93d..2f3ea470 100644 --- a/logic/common.go +++ b/internal/logic/common.go @@ -14,7 +14,7 @@ import ( "strconv" "time" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "xorm.io/xorm" @@ -230,8 +230,8 @@ func CanPublish(dauAuth, objtype int) bool { } // NeedCaptcha 是否需要验证码: -// - 新客注册后一段时间内需要 -// - 发布内容太频繁(一天次数太多、间隔太快) +// - 新客注册后一段时间内需要 +// - 发布内容太频繁(一天次数太多、间隔太快) func NeedCaptcha(user *model.Me) bool { // 注册后 30 分钟内发布需要验证码 if user.CreatedAt.Add(30 * time.Minute).After(time.Now()) { diff --git a/logic/data.go b/internal/logic/data.go similarity index 99% rename from logic/data.go rename to internal/logic/data.go index 569baef1..3ab6c8b0 100644 --- a/logic/data.go +++ b/internal/logic/data.go @@ -13,7 +13,7 @@ import ( "github.com/polaris1119/logger" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" ) // 常驻内存数据(多实例部署时,数据同步会有问题) diff --git a/logic/data_test.go b/internal/logic/data_test.go similarity index 100% rename from logic/data_test.go rename to internal/logic/data_test.go diff --git a/logic/download.go b/internal/logic/download.go similarity index 90% rename from logic/download.go rename to internal/logic/download.go index bf044190..21bcc6f3 100644 --- a/logic/download.go +++ b/internal/logic/download.go @@ -11,7 +11,7 @@ import ( "strings" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/PuerkitoBio/goquery" "github.com/polaris1119/goutils" @@ -56,10 +56,12 @@ func (DownloadLogic) AddNewDownload(ctx context.Context, version, selector strin doc.Find(selector).Each(func(i int, versionSel *goquery.Selection) { idVal, exists := versionSel.Attr("id") if !exists { + objLog.Errorln("add new download version not exist:", version) return } if idVal != version { + objLog.Errorln("add new download version not match, expected:", version, "real:", idVal) return } @@ -93,6 +95,7 @@ func (DownloadLogic) AddNewDownload(ctx context.Context, version, selector strin }) if download.Kind == "" { + objLog.Errorln("add new download Kind is empty:", version) return } diff --git a/logic/dynamic.go b/internal/logic/dynamic.go similarity index 93% rename from logic/dynamic.go rename to internal/logic/dynamic.go index 9b8eba30..fb5fc2a7 100644 --- a/logic/dynamic.go +++ b/internal/logic/dynamic.go @@ -7,7 +7,7 @@ package logic import ( - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "golang.org/x/net/context" diff --git a/logic/email.go b/internal/logic/email.go similarity index 99% rename from logic/email.go rename to internal/logic/email.go index 5d976ab6..50829d7e 100644 --- a/logic/email.go +++ b/internal/logic/email.go @@ -17,7 +17,7 @@ import ( . "github.com/studygolang/studygolang/db" "github.com/studygolang/studygolang/global" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "github.com/polaris1119/config" diff --git a/logic/email_test.go b/internal/logic/email_test.go similarity index 88% rename from logic/email_test.go rename to internal/logic/email_test.go index 08747224..ee71ef5d 100644 --- a/logic/email_test.go +++ b/internal/logic/email_test.go @@ -4,8 +4,9 @@ import ( . "github.com/polaris1119/config" "github.com/polaris1119/logger" - "github.com/studygolang/studygolang/logic" "testing" + + "github.com/studygolang/studygolang/internal/logic" ) func TestSendAuthMail(t *testing.T) { diff --git a/logic/favorite.go b/internal/logic/favorite.go similarity index 97% rename from logic/favorite.go rename to internal/logic/favorite.go index 11bf0ed6..263ca00b 100644 --- a/logic/favorite.go +++ b/internal/logic/favorite.go @@ -11,7 +11,7 @@ import ( . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "golang.org/x/net/context" ) diff --git a/logic/feed.go b/internal/logic/feed.go similarity index 93% rename from logic/feed.go rename to internal/logic/feed.go index 1d959706..9d39f86d 100644 --- a/logic/feed.go +++ b/internal/logic/feed.go @@ -15,7 +15,8 @@ import ( "github.com/polaris1119/logger" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/dao/cache" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "github.com/polaris1119/set" @@ -39,7 +40,12 @@ func (self FeedLogic) GetTotalCount(ctx context.Context) int64 { func (self FeedLogic) FindRecentWithPaginator(ctx context.Context, paginator *Paginator, tab string) []*model.Feed { objLog := GetLogger(ctx) - feeds := make([]*model.Feed, 0) + feeds := cache.Feed.GetList(ctx, paginator.curPage) + if len(feeds) > 0 { + return feeds + } + + feeds = make([]*model.Feed, 0) session := MasterDB.Limit(paginator.PerPage(), paginator.Offset()) if tab == model.TabRecommend { session.Desc("seq") @@ -50,7 +56,11 @@ func (self FeedLogic) FindRecentWithPaginator(ctx context.Context, paginator *Pa return nil } - return self.fillOtherInfo(ctx, feeds, true) + feeds = self.fillOtherInfo(ctx, feeds, true) + if len(feeds) > 0 { + cache.Feed.SetList(ctx, paginator.curPage, feeds) + } + return feeds } func (self FeedLogic) FindRecent(ctx context.Context, num int) []*model.Feed { @@ -69,14 +79,21 @@ func (self FeedLogic) FindRecent(ctx context.Context, num int) []*model.Feed { func (self FeedLogic) FindTop(ctx context.Context) []*model.Feed { objLog := GetLogger(ctx) - feeds := make([]*model.Feed, 0) + feeds := cache.Feed.GetTop(ctx) + if feeds != nil { + return feeds + } + + feeds = make([]*model.Feed, 0) err := MasterDB.Where("top=1").Desc("updated_at").Find(&feeds) if err != nil { objLog.Errorln("FeedLogic FindRecent error:", err) return nil } - return self.fillOtherInfo(ctx, feeds, false) + feeds = self.fillOtherInfo(ctx, feeds, false) + cache.Feed.SetTop(ctx, feeds) + return feeds } // AutoUpdateSeq 自动更新动态的排序(校准) diff --git a/logic/friend_link.go b/internal/logic/friend_link.go similarity index 93% rename from logic/friend_link.go rename to internal/logic/friend_link.go index a6f4d3d1..51d8bd2e 100644 --- a/logic/friend_link.go +++ b/internal/logic/friend_link.go @@ -9,7 +9,7 @@ package logic import ( . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "golang.org/x/net/context" ) diff --git a/logic/gctt.go b/internal/logic/gctt.go similarity index 98% rename from logic/gctt.go rename to internal/logic/gctt.go index f95eaae6..ee9f4881 100644 --- a/logic/gctt.go +++ b/internal/logic/gctt.go @@ -10,7 +10,7 @@ import ( "context" "time" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" . "github.com/studygolang/studygolang/db" ) diff --git a/logic/gift.go b/internal/logic/gift.go similarity index 98% rename from logic/gift.go rename to internal/logic/gift.go index e577e1db..0cff2d07 100644 --- a/logic/gift.go +++ b/internal/logic/gift.go @@ -13,7 +13,7 @@ import ( "time" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "xorm.io/xorm" ) diff --git a/logic/github.go b/internal/logic/github.go similarity index 99% rename from logic/github.go rename to internal/logic/github.go index 1d6b13a1..c6842c43 100644 --- a/logic/github.go +++ b/internal/logic/github.go @@ -17,7 +17,7 @@ import ( "unicode/utf8" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/goutils" "github.com/polaris1119/logger" diff --git a/logic/github_test.go b/internal/logic/github_test.go similarity index 99% rename from logic/github_test.go rename to internal/logic/github_test.go index b0375a71..d0c34a0e 100644 --- a/logic/github_test.go +++ b/internal/logic/github_test.go @@ -7,9 +7,10 @@ package logic_test import ( - "github.com/studygolang/studygolang/logic" "testing" + "github.com/studygolang/studygolang/internal/logic" + "github.com/polaris1119/config" "github.com/polaris1119/logger" ) diff --git a/logic/gobook.go b/internal/logic/gobook.go similarity index 99% rename from logic/gobook.go rename to internal/logic/gobook.go index c0c87242..c2e3d27e 100644 --- a/logic/gobook.go +++ b/internal/logic/gobook.go @@ -11,7 +11,7 @@ import ( "time" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/logger" "golang.org/x/net/context" diff --git a/logic/html2article.go b/internal/logic/html2article.go similarity index 97% rename from logic/html2article.go rename to internal/logic/html2article.go index 9b7b2514..e5e148b0 100644 --- a/logic/html2article.go +++ b/internal/logic/html2article.go @@ -12,7 +12,7 @@ import ( "time" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/logger" "github.com/sundy-li/html2article" diff --git a/logic/index.go b/internal/logic/index.go similarity index 98% rename from logic/index.go rename to internal/logic/index.go index e8e6cd88..58e2cb3b 100644 --- a/logic/index.go +++ b/internal/logic/index.go @@ -7,10 +7,11 @@ package logic import ( - "github.com/studygolang/studygolang/model" "strconv" "strings" + "github.com/studygolang/studygolang/internal/model" + "github.com/polaris1119/times" "golang.org/x/net/context" ) diff --git a/logic/install.go b/internal/logic/install.go similarity index 97% rename from logic/install.go rename to internal/logic/install.go index 58dd2135..bcbd6c9a 100644 --- a/logic/install.go +++ b/internal/logic/install.go @@ -2,9 +2,10 @@ package logic import ( "bytes" - "github.com/studygolang/studygolang/model" "io/ioutil" + "github.com/studygolang/studygolang/internal/model" + "github.com/polaris1119/config" "golang.org/x/net/context" diff --git a/logic/interview_question.go b/internal/logic/interview_question.go similarity index 99% rename from logic/interview_question.go rename to internal/logic/interview_question.go index 38f8b74e..3d9f8f32 100644 --- a/logic/interview_question.go +++ b/internal/logic/interview_question.go @@ -17,7 +17,7 @@ import ( "github.com/polaris1119/logger" "github.com/polaris1119/nosql" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/yuin/goldmark" "github.com/yuin/goldmark/extension" "github.com/yuin/goldmark/parser" diff --git a/logic/learning_material.go b/internal/logic/learning_material.go similarity index 93% rename from logic/learning_material.go rename to internal/logic/learning_material.go index ea34fd3d..f33e66fe 100644 --- a/logic/learning_material.go +++ b/internal/logic/learning_material.go @@ -9,7 +9,7 @@ package logic import ( . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "golang.org/x/net/context" ) diff --git a/logic/like.go b/internal/logic/like.go similarity index 98% rename from logic/like.go rename to internal/logic/like.go index 6d192114..0ad3815d 100644 --- a/logic/like.go +++ b/internal/logic/like.go @@ -15,7 +15,7 @@ import ( "golang.org/x/net/context" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" ) type LikeLogic struct{} diff --git a/logic/message.go b/internal/logic/message.go similarity index 98% rename from logic/message.go rename to internal/logic/message.go index 67699d8a..2eee3fc9 100644 --- a/logic/message.go +++ b/internal/logic/message.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" . "github.com/studygolang/studygolang/db" @@ -173,10 +173,11 @@ func (MessageLogic) SendSysMsgAtUsernames(ctx context.Context, usernames string, // FindSysMsgsByUid 获得某人的系统消息 // 系统消息类型不同,在ext中存放的字段也不一样,如下: -// model.MsgtypeTopicReply/MsgtypeResourceComment/MsgtypeWikiComment存放都为: -// {"uid":xxx,"objid":xxx} -// model.MsgtypeAtMe 为:{"uid":xxx,"cid":xxx,"objid":xxx,"objtype":xxx} -// model.MsgtypePulishAtMe 为:{"uid":xxx,"objid":xxx,"objtype":xxx} +// +// model.MsgtypeTopicReply/MsgtypeResourceComment/MsgtypeWikiComment存放都为: +// {"uid":xxx,"objid":xxx} +// model.MsgtypeAtMe 为:{"uid":xxx,"cid":xxx,"objid":xxx,"objtype":xxx} +// model.MsgtypePulishAtMe 为:{"uid":xxx,"objid":xxx,"objtype":xxx} func (self MessageLogic) FindSysMsgsByUid(ctx context.Context, uid int, paginator *Paginator) []map[string]interface{} { objLog := GetLogger(ctx) diff --git a/logic/mission.go b/internal/logic/mission.go similarity index 99% rename from logic/mission.go rename to internal/logic/mission.go index 618f8167..43b73773 100644 --- a/logic/mission.go +++ b/internal/logic/mission.go @@ -15,7 +15,7 @@ import ( "time" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/goutils" "github.com/polaris1119/times" diff --git a/logic/observer.go b/internal/logic/observer.go similarity index 99% rename from logic/observer.go rename to internal/logic/observer.go index c37fd0ff..3e425846 100644 --- a/logic/observer.go +++ b/internal/logic/observer.go @@ -10,7 +10,7 @@ import ( "fmt" "unicode/utf8" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" ) var ( diff --git a/logic/observer_test.go b/internal/logic/observer_test.go similarity index 100% rename from logic/observer_test.go rename to internal/logic/observer_test.go diff --git a/logic/page.go b/internal/logic/page.go similarity index 100% rename from logic/page.go rename to internal/logic/page.go diff --git a/logic/project.go b/internal/logic/project.go similarity index 99% rename from logic/project.go rename to internal/logic/project.go index 539273da..47fe0946 100644 --- a/logic/project.go +++ b/internal/logic/project.go @@ -15,7 +15,7 @@ import ( "time" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/PuerkitoBio/goquery" "github.com/lunny/html2md" diff --git a/logic/rank.go b/internal/logic/rank.go similarity index 99% rename from logic/rank.go rename to internal/logic/rank.go index a0fbd9ef..c7ce0ed0 100644 --- a/logic/rank.go +++ b/internal/logic/rank.go @@ -12,7 +12,7 @@ import ( "time" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/garyburd/redigo/redis" "github.com/polaris1119/logger" diff --git a/logic/rank_test.go b/internal/logic/rank_test.go similarity index 84% rename from logic/rank_test.go rename to internal/logic/rank_test.go index c06ddcb6..384e7aea 100644 --- a/logic/rank_test.go +++ b/internal/logic/rank_test.go @@ -7,9 +7,10 @@ package logic_test import ( - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" "testing" + + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" ) func TestGenRank(t *testing.T) { diff --git a/logic/reading.go b/internal/logic/reading.go similarity index 98% rename from logic/reading.go rename to internal/logic/reading.go index d204aa8c..a66a86d6 100644 --- a/logic/reading.go +++ b/internal/logic/reading.go @@ -13,7 +13,7 @@ import ( "strings" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/logger" "golang.org/x/net/context" diff --git a/logic/reddit.go b/internal/logic/reddit.go similarity index 99% rename from logic/reddit.go rename to internal/logic/reddit.go index 7ceafe5d..1c6ea9fa 100644 --- a/logic/reddit.go +++ b/internal/logic/reddit.go @@ -17,7 +17,7 @@ import ( "time" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/PuerkitoBio/goquery" "github.com/polaris1119/config" diff --git a/logic/resource.go b/internal/logic/resource.go similarity index 99% rename from logic/resource.go rename to internal/logic/resource.go index c3d2913c..2100b8b7 100644 --- a/logic/resource.go +++ b/internal/logic/resource.go @@ -12,7 +12,7 @@ import ( "time" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/fatih/structs" "github.com/polaris1119/logger" diff --git a/logic/risk.go b/internal/logic/risk.go similarity index 95% rename from logic/risk.go rename to internal/logic/risk.go index bd6cd29b..662492c5 100644 --- a/logic/risk.go +++ b/internal/logic/risk.go @@ -8,7 +8,7 @@ package logic import ( . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/nosql" ) diff --git a/logic/rule.go b/internal/logic/rule.go similarity index 97% rename from logic/rule.go rename to internal/logic/rule.go index 7734656a..77e48b12 100644 --- a/logic/rule.go +++ b/internal/logic/rule.go @@ -10,7 +10,7 @@ import ( "net/url" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "golang.org/x/net/context" ) diff --git a/logic/searcher.go b/internal/logic/searcher.go similarity index 99% rename from logic/searcher.go rename to internal/logic/searcher.go index be5d1bcd..e53ee50b 100644 --- a/logic/searcher.go +++ b/internal/logic/searcher.go @@ -23,7 +23,7 @@ import ( "github.com/polaris1119/logger" "github.com/polaris1119/set" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" ) type SearcherLogic struct { diff --git a/logic/setting.go b/internal/logic/setting.go similarity index 98% rename from logic/setting.go rename to internal/logic/setting.go index 3ed51f98..38f49922 100644 --- a/logic/setting.go +++ b/internal/logic/setting.go @@ -9,11 +9,12 @@ package logic import ( "encoding/json" "errors" - . "github.com/studygolang/studygolang/db" "net/url" "strings" - "github.com/studygolang/studygolang/model" + . "github.com/studygolang/studygolang/db" + + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/goutils" "golang.org/x/net/context" diff --git a/logic/sitemap.go b/internal/logic/sitemap.go similarity index 99% rename from logic/sitemap.go rename to internal/logic/sitemap.go index 75d50c36..773daabf 100644 --- a/logic/sitemap.go +++ b/internal/logic/sitemap.go @@ -7,17 +7,18 @@ package logic import ( - "github.com/studygolang/studygolang/util" "os" "strconv" "text/template" "time" + "github.com/studygolang/studygolang/util" + "github.com/polaris1119/config" "github.com/polaris1119/logger" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" ) // 自定义模板函数 diff --git a/logic/subject.go b/internal/logic/subject.go similarity index 99% rename from logic/subject.go rename to internal/logic/subject.go index 9f2d3225..7d2652af 100644 --- a/logic/subject.go +++ b/internal/logic/subject.go @@ -13,7 +13,7 @@ import ( . "github.com/studygolang/studygolang/db" "github.com/studygolang/studygolang/global" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "github.com/polaris1119/goutils" diff --git a/logic/subject_test.go b/internal/logic/subject_test.go similarity index 89% rename from logic/subject_test.go rename to internal/logic/subject_test.go index 47336ec2..d29b0738 100644 --- a/logic/subject_test.go +++ b/internal/logic/subject_test.go @@ -7,11 +7,12 @@ package logic_test import ( - "github.com/studygolang/studygolang/logic" - "github.com/studygolang/studygolang/model" "reflect" "testing" + "github.com/studygolang/studygolang/internal/logic" + "github.com/studygolang/studygolang/internal/model" + "golang.org/x/net/context" ) diff --git a/logic/third_user.go b/internal/logic/third_user.go similarity index 99% rename from logic/third_user.go rename to internal/logic/third_user.go index 71c84380..e2385c9e 100644 --- a/logic/third_user.go +++ b/internal/logic/third_user.go @@ -12,7 +12,7 @@ import ( "io/ioutil" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/logger" diff --git a/logic/topic.go b/internal/logic/topic.go similarity index 99% rename from logic/topic.go rename to internal/logic/topic.go index df97e03e..24494360 100644 --- a/logic/topic.go +++ b/internal/logic/topic.go @@ -14,7 +14,7 @@ import ( "sync" "time" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" . "github.com/studygolang/studygolang/db" diff --git a/logic/topic_node.go b/internal/logic/topic_node.go similarity index 98% rename from logic/topic_node.go rename to internal/logic/topic_node.go index d1cb56a7..a176d995 100644 --- a/logic/topic_node.go +++ b/internal/logic/topic_node.go @@ -11,7 +11,7 @@ import ( "net/url" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/goutils" "github.com/polaris1119/logger" diff --git a/logic/topic_node_test.go b/internal/logic/topic_node_test.go similarity index 100% rename from logic/topic_node_test.go rename to internal/logic/topic_node_test.go diff --git a/logic/topic_test.go b/internal/logic/topic_test.go similarity index 100% rename from logic/topic_test.go rename to internal/logic/topic_test.go diff --git a/logic/uploader.go b/internal/logic/uploader.go similarity index 99% rename from logic/uploader.go rename to internal/logic/uploader.go index 71e78655..78b34f63 100644 --- a/logic/uploader.go +++ b/internal/logic/uploader.go @@ -26,7 +26,7 @@ import ( "golang.org/x/net/context" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/config" "github.com/polaris1119/goutils" diff --git a/logic/user.go b/internal/logic/user.go similarity index 99% rename from logic/user.go rename to internal/logic/user.go index 121e55b3..60f6da76 100644 --- a/logic/user.go +++ b/internal/logic/user.go @@ -15,7 +15,7 @@ import ( "strings" "time" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" "github.com/polaris1119/times" diff --git a/logic/user_rich.go b/internal/logic/user_rich.go similarity index 99% rename from logic/user_rich.go rename to internal/logic/user_rich.go index 4960837f..3535ca50 100644 --- a/logic/user_rich.go +++ b/internal/logic/user_rich.go @@ -12,7 +12,7 @@ import ( "net/url" "time" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" . "github.com/studygolang/studygolang/db" diff --git a/logic/user_rich_test.go b/internal/logic/user_rich_test.go similarity index 100% rename from logic/user_rich_test.go rename to internal/logic/user_rich_test.go diff --git a/logic/user_test.go b/internal/logic/user_test.go similarity index 100% rename from logic/user_test.go rename to internal/logic/user_test.go diff --git a/logic/view.go b/internal/logic/view.go similarity index 98% rename from logic/view.go rename to internal/logic/view.go index da87dfb3..a8685663 100644 --- a/logic/view.go +++ b/internal/logic/view.go @@ -14,7 +14,7 @@ import ( "sync" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/polaris1119/config" "github.com/polaris1119/goutils" diff --git a/logic/view_record.go b/internal/logic/view_record.go similarity index 96% rename from logic/view_record.go rename to internal/logic/view_record.go index 3ddf0732..26b3d9a5 100644 --- a/logic/view_record.go +++ b/internal/logic/view_record.go @@ -7,7 +7,7 @@ package logic import ( - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" . "github.com/studygolang/studygolang/db" diff --git a/logic/view_source.go b/internal/logic/view_source.go similarity index 97% rename from logic/view_source.go rename to internal/logic/view_source.go index 2f20723d..adad94e9 100644 --- a/logic/view_source.go +++ b/internal/logic/view_source.go @@ -10,7 +10,7 @@ import ( "net/http" "strings" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" . "github.com/studygolang/studygolang/db" diff --git a/logic/wechat.go b/internal/logic/wechat.go similarity index 99% rename from logic/wechat.go rename to internal/logic/wechat.go index cf5ceded..a49816d7 100644 --- a/logic/wechat.go +++ b/internal/logic/wechat.go @@ -17,7 +17,7 @@ import ( "strings" "time" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "github.com/studygolang/studygolang/util" . "github.com/studygolang/studygolang/db" diff --git a/logic/wiki.go b/internal/logic/wiki.go similarity index 98% rename from logic/wiki.go rename to internal/logic/wiki.go index ded3e5bc..d419fa2a 100644 --- a/logic/wiki.go +++ b/internal/logic/wiki.go @@ -13,7 +13,7 @@ import ( "strings" . "github.com/studygolang/studygolang/db" - "github.com/studygolang/studygolang/model" + "github.com/studygolang/studygolang/internal/model" "golang.org/x/net/context" diff --git a/model/ad.go b/internal/model/ad.go similarity index 100% rename from model/ad.go rename to internal/model/ad.go diff --git a/model/article.go b/internal/model/article.go similarity index 100% rename from model/article.go rename to internal/model/article.go diff --git a/model/authority.go b/internal/model/authority.go similarity index 100% rename from model/authority.go rename to internal/model/authority.go diff --git a/model/auto_tag.go b/internal/model/auto_tag.go similarity index 100% rename from model/auto_tag.go rename to internal/model/auto_tag.go diff --git a/model/book.go b/internal/model/book.go similarity index 100% rename from model/book.go rename to internal/model/book.go diff --git a/model/comment.go b/internal/model/comment.go similarity index 100% rename from model/comment.go rename to internal/model/comment.go diff --git a/model/default_avatar.go b/internal/model/default_avatar.go similarity index 100% rename from model/default_avatar.go rename to internal/model/default_avatar.go diff --git a/model/document.go b/internal/model/document.go similarity index 100% rename from model/document.go rename to internal/model/document.go diff --git a/model/download.go b/internal/model/download.go similarity index 100% rename from model/download.go rename to internal/model/download.go diff --git a/model/dynamic.go b/internal/model/dynamic.go similarity index 100% rename from model/dynamic.go rename to internal/model/dynamic.go diff --git a/model/favorite.go b/internal/model/favorite.go similarity index 100% rename from model/favorite.go rename to internal/model/favorite.go diff --git a/model/feed.go b/internal/model/feed.go similarity index 100% rename from model/feed.go rename to internal/model/feed.go diff --git a/model/friend_link.go b/internal/model/friend_link.go similarity index 100% rename from model/friend_link.go rename to internal/model/friend_link.go diff --git a/model/gctt.go b/internal/model/gctt.go similarity index 100% rename from model/gctt.go rename to internal/model/gctt.go diff --git a/model/gift.go b/internal/model/gift.go similarity index 100% rename from model/gift.go rename to internal/model/gift.go diff --git a/model/github_user.go b/internal/model/github_user.go similarity index 100% rename from model/github_user.go rename to internal/model/github_user.go diff --git a/model/image.go b/internal/model/image.go similarity index 100% rename from model/image.go rename to internal/model/image.go diff --git a/model/interview_question.go b/internal/model/interview_question.go similarity index 100% rename from model/interview_question.go rename to internal/model/interview_question.go diff --git a/model/learning_material.go b/internal/model/learning_material.go similarity index 100% rename from model/learning_material.go rename to internal/model/learning_material.go diff --git a/model/like.go b/internal/model/like.go similarity index 100% rename from model/like.go rename to internal/model/like.go diff --git a/model/message.go b/internal/model/message.go similarity index 100% rename from model/message.go rename to internal/model/message.go diff --git a/model/mission.go b/internal/model/mission.go similarity index 100% rename from model/mission.go rename to internal/model/mission.go diff --git a/model/morning_reading.go b/internal/model/morning_reading.go similarity index 100% rename from model/morning_reading.go rename to internal/model/morning_reading.go diff --git a/model/openproject.go b/internal/model/openproject.go similarity index 100% rename from model/openproject.go rename to internal/model/openproject.go diff --git a/model/resource.go b/internal/model/resource.go similarity index 100% rename from model/resource.go rename to internal/model/resource.go diff --git a/model/role.go b/internal/model/role.go similarity index 100% rename from model/role.go rename to internal/model/role.go diff --git a/model/search_stat.go b/internal/model/search_stat.go similarity index 100% rename from model/search_stat.go rename to internal/model/search_stat.go diff --git a/model/subject.go b/internal/model/subject.go similarity index 100% rename from model/subject.go rename to internal/model/subject.go diff --git a/model/topic.go b/internal/model/topic.go similarity index 100% rename from model/topic.go rename to internal/model/topic.go diff --git a/model/type.go b/internal/model/type.go similarity index 100% rename from model/type.go rename to internal/model/type.go diff --git a/model/user.go b/internal/model/user.go similarity index 97% rename from model/user.go rename to internal/model/user.go index 4a83a8bd..abea7b60 100644 --- a/model/user.go +++ b/internal/model/user.go @@ -154,12 +154,13 @@ type Me struct { // 活跃用户信息 // 活跃度规则: -// 1、注册成功后 +2 -// 2、登录一次 +1 -// 3、修改资料 +1 -// 4、发帖子 + 10 -// 5、评论 +5 -// 6、创建Wiki页 +10 +// +// 1、注册成功后 +2 +// 2、登录一次 +1 +// 3、修改资料 +1 +// 4、发帖子 + 10 +// 5、评论 +5 +// 6、创建Wiki页 +10 type UserActive struct { Uid int `json:"uid" xorm:"pk"` Username string `json:"username"` diff --git a/model/user_rich.go b/internal/model/user_rich.go similarity index 100% rename from model/user_rich.go rename to internal/model/user_rich.go diff --git a/model/user_setting.go b/internal/model/user_setting.go similarity index 100% rename from model/user_setting.go rename to internal/model/user_setting.go diff --git a/model/view_record.go b/internal/model/view_record.go similarity index 100% rename from model/view_record.go rename to internal/model/view_record.go diff --git a/model/view_source.go b/internal/model/view_source.go similarity index 100% rename from model/view_source.go rename to internal/model/view_source.go diff --git a/model/website_setting.go b/internal/model/website_setting.go similarity index 100% rename from model/website_setting.go rename to internal/model/website_setting.go diff --git a/model/wechat.go b/internal/model/wechat.go similarity index 100% rename from model/wechat.go rename to internal/model/wechat.go diff --git a/model/wechat_msg.go b/internal/model/wechat_msg.go similarity index 100% rename from model/wechat_msg.go rename to internal/model/wechat_msg.go diff --git a/model/wiki.go b/internal/model/wiki.go similarity index 100% rename from model/wiki.go rename to internal/model/wiki.go diff --git a/sg.service b/sg.service new file mode 100644 index 00000000..fcb57bcd --- /dev/null +++ b/sg.service @@ -0,0 +1,13 @@ +[Unit] +Description=studygolang + +[Service] +ExecStart=/data/www/studygolang/bin/studygolang +ExecReload=/bin/kill -USR2 $MAINPID +PIDFile=/data/www/studygolang/pid/studygolang.pid +Restart=always +User=xuxinhua +Group=xuxinhua + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/static/dist/js/sg_libs.js b/static/dist/js/sg_libs.js index 7a8bfcdf..59146ed0 100644 --- a/static/dist/js/sg_libs.js +++ b/static/dist/js/sg_libs.js @@ -88,290 +88,290 @@ var emojis = [ ]; emojis = $.map(emojis, function(value, i) {return {key:':'+value+':', name:value}}); -(function($){ -$.fn.Huploadify = function(opts){ - var itemTemp = '
${fileName}上传删除
'; - var defaults = { - fileTypeExts:'*.*',//允许上传的文件类型,格式'*.jpg;*.doc' - uploader:'',//文件提交的地址 - auto:false,//是否开启自动上传 - method:'post',//发送请求的方式,get或post - multi:true,//是否允许选择多个文件 - formData:null,//发送给服务端的参数,格式:{key1:value1,key2:value2} - fileObjName:'file',//在后端接受文件的参数名称,如PHP中的$_FILES['file'] - fileSizeLimit:2048,//允许上传的文件大小,单位KB - showUploadedPercent:true,//是否实时显示上传的百分比,如20% - showUploadedSize:false,//是否实时显示已上传的文件大小,如1M/2M - buttonText:'选择文件',//上传按钮上的文字 - removeTimeout: 1000,//上传完成后进度条的消失时间 - itemTemplate:itemTemp,//上传队列显示的模板 - onUploadStart:null,//上传开始时的动作 - onUploadSuccess:null,//上传成功的动作 - onUploadComplete:null,//上传完成的动作 - onUploadAllComplete: null, // 批量上传时,所有的都上传完后回调 - onUploadError:null, //上传失败的动作 - onInit:null,//初始化时的动作 - onCancel:null//删除掉某个文件后的回调函数,可传入参数file - } - - var option = $.extend(defaults,opts); - - //将文件的单位由bytes转换为KB或MB,若第二个参数指定为true,则永远转换为KB - var formatFileSize = function(size,byKB){ - if (size> 1024 * 1024&&!byKB){ - size = (Math.round(size * 100 / (1024 * 1024)) / 100).toString() + 'MB'; - } - else{ - size = (Math.round(size * 100 / 1024) / 100).toString() + 'KB'; - } - return size; - } - //根据文件序号获取文件 - var getFile = function(index,files){ - for(var i=0;i