🎨 Update project structure
This commit is contained in:
parent
a1aa418496
commit
05a59113c9
44
.idea/workspace.xml
generated
44
.idea/workspace.xml
generated
@ -4,7 +4,36 @@
|
|||||||
<option name="autoReloadType" value="ALL" />
|
<option name="autoReloadType" value="ALL" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":bug: Fix uuid duplicate when link exists" />
|
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":bug: Fix uuid duplicate when link exists">
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/Dockerfile" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/cmd/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/main.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/database/migrator.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/migrator.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/database/source.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/source.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/grpc/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/attachments.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/grpc/client.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/client.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/attachments.pb.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/proto/attachments.pb.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/attachments.proto" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/proto/attachments.proto" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/attachments_grpc.pb.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/proto/attachments_grpc.pb.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/grpc/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/server.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/meta.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/meta.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/models/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/accounts.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/models/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/attachments.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/models/base.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/base.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/models/destination.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/destination.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/models/metadata.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/metadata.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/server/attachments_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/attachments_api.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/server/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/auth.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/server/startup.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/startup.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/server/utils.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/utils.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/server/well_known_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/well_known_api.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/services/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/attachments.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/services/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/auth.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/services/cleaner.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/cleaner.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/services/jwt.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/jwt.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/services/recycler.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/recycler.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/services/uploader.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/uploader.go" afterDir="false" />
|
||||||
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
@ -41,13 +70,20 @@
|
|||||||
"settings.editor.selected.configurable": "preferences.lookFeel"
|
"settings.editor.selected.configurable": "preferences.lookFeel"
|
||||||
}
|
}
|
||||||
}</component>
|
}</component>
|
||||||
|
<component name="RecentsManager">
|
||||||
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
|
<recent name="$PROJECT_DIR$/pkg" />
|
||||||
|
<recent name="$PROJECT_DIR$/pkg/internal" />
|
||||||
|
</key>
|
||||||
|
</component>
|
||||||
<component name="RunManager">
|
<component name="RunManager">
|
||||||
<configuration name="Backend" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
<configuration name="Backend" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
||||||
<module name="Paperclip" />
|
<module name="Paperclip" />
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
<working_directory value="$PROJECT_DIR$" />
|
||||||
<kind value="FILE" />
|
<kind value="FILE" />
|
||||||
|
<package value="git.solsynth.dev/hydrogen/paperclip" />
|
||||||
<directory value="$PROJECT_DIR$" />
|
<directory value="$PROJECT_DIR$" />
|
||||||
<filePath value="$PROJECT_DIR$/pkg/cmd/main.go" />
|
<filePath value="$PROJECT_DIR$/pkg/main.go" />
|
||||||
<output_directory value="$PROJECT_DIR$/dist" />
|
<output_directory value="$PROJECT_DIR$/dist" />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -55,8 +91,8 @@
|
|||||||
<component name="SharedIndexes">
|
<component name="SharedIndexes">
|
||||||
<attachedChunks>
|
<attachedChunks>
|
||||||
<set>
|
<set>
|
||||||
<option value="bundled-gosdk-33c477a475b1-b97fc8a1e17c-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-241.14494.238" />
|
<option value="bundled-gosdk-33c477a475b1-e0158606a674-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-241.17890.21" />
|
||||||
<option value="bundled-js-predefined-1d06a55b98c1-74d2a5396914-JavaScript-GO-241.14494.238" />
|
<option value="bundled-js-predefined-1d06a55b98c1-0b3e54e931b4-JavaScript-GO-241.17890.21" />
|
||||||
</set>
|
</set>
|
||||||
</attachedChunks>
|
</attachedChunks>
|
||||||
</component>
|
</component>
|
||||||
|
@ -5,7 +5,7 @@ RUN apk add nodejs npm
|
|||||||
|
|
||||||
WORKDIR /source
|
WORKDIR /source
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildvcs -o /dist ./pkg/cmd/main.go
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildvcs -o /dist ./pkg/main.go
|
||||||
|
|
||||||
# Runtime
|
# Runtime
|
||||||
FROM golang:alpine
|
FROM golang:alpine
|
||||||
|
@ -3,10 +3,10 @@ package grpc
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/database"
|
||||||
|
"git.solsynth.dev/hydrogen/paperclip/pkg/proto"
|
||||||
"google.golang.org/protobuf/types/known/emptypb"
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/database"
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/grpc/proto"
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/models"
|
"git.solsynth.dev/hydrogen/paperclip/pkg/models"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
)
|
)
|
@ -1,9 +1,9 @@
|
|||||||
package grpc
|
package grpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.solsynth.dev/hydrogen/paperclip/pkg/proto"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/grpc/proto"
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/reflection"
|
"google.golang.org/grpc/reflection"
|
@ -3,13 +3,13 @@ package server
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/database"
|
||||||
|
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/grpc"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/grpc"
|
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
|
"git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/database"
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/models"
|
"git.solsynth.dev/hydrogen/paperclip/pkg/models"
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/services"
|
"git.solsynth.dev/hydrogen/paperclip/pkg/services"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
@ -2,12 +2,12 @@ package services
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/database"
|
||||||
"mime"
|
"mime"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/database"
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/models"
|
"git.solsynth.dev/hydrogen/paperclip/pkg/models"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
@ -4,11 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/database"
|
||||||
|
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/grpc"
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/database"
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/grpc"
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/models"
|
"git.solsynth.dev/hydrogen/paperclip/pkg/models"
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
|
"git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
@ -1,9 +1,9 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
database2 "git.solsynth.dev/hydrogen/paperclip/pkg/internal/database"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/database"
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,8 +12,8 @@ func DoAutoDatabaseCleanup() {
|
|||||||
log.Debug().Time("deadline", deadline).Msg("Now cleaning up entire database...")
|
log.Debug().Time("deadline", deadline).Msg("Now cleaning up entire database...")
|
||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
for _, model := range database.AutoMaintainRange {
|
for _, model := range database2.AutoMaintainRange {
|
||||||
tx := database.C.Unscoped().Delete(model, "deleted_at >= ?", deadline)
|
tx := database2.C.Unscoped().Delete(model, "deleted_at >= ?", deadline)
|
||||||
if tx.Error != nil {
|
if tx.Error != nil {
|
||||||
log.Error().Err(tx.Error).Msg("An error occurred when running auth context cleanup...")
|
log.Error().Err(tx.Error).Msg("An error occurred when running auth context cleanup...")
|
||||||
}
|
}
|
@ -1,17 +1,17 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
database2 "git.solsynth.dev/hydrogen/paperclip/pkg/internal/database"
|
||||||
|
grpc2 "git.solsynth.dev/hydrogen/paperclip/pkg/internal/grpc"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/grpc"
|
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/server"
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/server"
|
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/services"
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/services"
|
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
|
|
||||||
paperclip "git.solsynth.dev/hydrogen/paperclip/pkg"
|
"git.solsynth.dev/hydrogen/paperclip/pkg/internal"
|
||||||
"git.solsynth.dev/hydrogen/paperclip/pkg/database"
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@ -35,14 +35,14 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Connect to database
|
// Connect to database
|
||||||
if err := database.NewSource(); err != nil {
|
if err := database2.NewSource(); err != nil {
|
||||||
log.Fatal().Err(err).Msg("An error occurred when connect to database.")
|
log.Fatal().Err(err).Msg("An error occurred when connect to database.")
|
||||||
} else if err := database.RunMigration(database.C); err != nil {
|
} else if err := database2.RunMigration(database2.C); err != nil {
|
||||||
log.Fatal().Err(err).Msg("An error occurred when running database auto migration.")
|
log.Fatal().Err(err).Msg("An error occurred when running database auto migration.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect other services
|
// Connect other services
|
||||||
if err := grpc.ConnectPassport(); err != nil {
|
if err := grpc2.ConnectPassport(); err != nil {
|
||||||
log.Fatal().Err(err).Msg("An error occurred when connecting to passport grpc endpoint...")
|
log.Fatal().Err(err).Msg("An error occurred when connecting to passport grpc endpoint...")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,19 +57,19 @@ func main() {
|
|||||||
|
|
||||||
// Grpc Server
|
// Grpc Server
|
||||||
go func() {
|
go func() {
|
||||||
if err := grpc.StartGrpc(); err != nil {
|
if err := grpc2.StartGrpc(); err != nil {
|
||||||
log.Fatal().Err(err).Msg("An message occurred when starting grpc server.")
|
log.Fatal().Err(err).Msg("An message occurred when starting grpc server.")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Messages
|
// Messages
|
||||||
log.Info().Msgf("Paperclip v%s is started...", paperclip.AppVersion)
|
log.Info().Msgf("Paperclip v%s is started...", pkg.AppVersion)
|
||||||
|
|
||||||
quit := make(chan os.Signal, 1)
|
quit := make(chan os.Signal, 1)
|
||||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||||
<-quit
|
<-quit
|
||||||
|
|
||||||
log.Info().Msgf("Paperclip v%s is quitting...", paperclip.AppVersion)
|
log.Info().Msgf("Paperclip v%s is quitting...", pkg.AppVersion)
|
||||||
|
|
||||||
quartz.Stop()
|
quartz.Stop()
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user