This commit is contained in:
ivamp 2024-11-23 01:55:15 +08:00
parent bd4223a58c
commit eaccbd34e4
38 changed files with 107 additions and 105 deletions

View File

@ -4,9 +4,9 @@ import (
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth"
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"go-template/pkg/protos/documentService"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/reflection" "google.golang.org/grpc/reflection"
"leaf
"net" "net"
) )

View File

@ -3,7 +3,7 @@ package cmd
import ( import (
"context" "context"
"fmt" "fmt"
"go-template/internal/migrations" "leafdev.top/Leaf/api-platform/internal/migrations"
"os" "os"
"strings" "strings"
"time" "time"

View File

@ -1,7 +1,7 @@
package cmd package cmd
import ( import (
"go-template/internal/base" "leafdev.top/Leaf/api-platform/internal/base"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )

View File

@ -4,18 +4,18 @@
package cmd package cmd
import ( import (
"go-template/internal/base" "leafdev.top/Leaf/api-platform/internal/base"
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
"go-template/internal/base/logger" "leafdev.top/Leaf/api-platform/internal/base/logger"
"go-template/internal/base/orm" "leafdev.top/Leaf/api-platform/internal/base/orm"
"go-template/internal/base/redis" "leafdev.top/Leaf/api-platform/internal/base/redis"
"go-template/internal/base/s3" "leafdev.top/Leaf/api-platform/internal/base/s3"
"go-template/internal/base/server" "leafdev.top/Leaf/api-platform/internal/base/server"
"go-template/internal/batch" "leafdev.top/Leaf/api-platform/internal/batch"
"go-template/internal/dao" "leafdev.top/Leaf/api-platform/internal/dao"
"go-template/internal/handler" "leafdev.top/Leaf/api-platform/internal/handler"
"go-template/internal/router" "leafdev.top/Leaf/api-platform/internal/router"
"go-template/internal/service" "leafdev.top/Leaf/api-platform/internal/service"
"github.com/google/wire" "github.com/google/wire"
) )

View File

@ -8,26 +8,26 @@ package cmd
import ( import (
"github.com/google/wire" "github.com/google/wire"
"go-template/internal/base" "leafdev.top/Leaf/api-platform/internal/base"
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
"go-template/internal/base/logger" "leafdev.top/Leaf/api-platform/internal/base/logger"
"go-template/internal/base/orm" "leafdev.top/Leaf/api-platform/internal/base/orm"
"go-template/internal/base/redis" "leafdev.top/Leaf/api-platform/internal/base/redis"
"go-template/internal/base/s3" "leafdev.top/Leaf/api-platform/internal/base/s3"
"go-template/internal/base/server" "leafdev.top/Leaf/api-platform/internal/base/server"
"go-template/internal/batch" "leafdev.top/Leaf/api-platform/internal/batch"
"go-template/internal/dao" "leafdev.top/Leaf/api-platform/internal/dao"
"go-template/internal/handler" "leafdev.top/Leaf/api-platform/internal/handler"
"go-template/internal/handler/grpc" "leafdev.top/Leaf/api-platform/internal/handler/grpc"
"go-template/internal/handler/grpc/documents" "leafdev.top/Leaf/api-platform/internal/handler/grpc/documents"
"go-template/internal/handler/grpc/interceptor" "leafdev.top/Leaf/api-platform/internal/handler/grpc/interceptor"
"go-template/internal/handler/http" "leafdev.top/Leaf/api-platform/internal/handler/http"
"go-template/internal/handler/http/controller/v1" "leafdev.top/Leaf/api-platform/internal/handler/http/controller/v1"
"go-template/internal/router" "leafdev.top/Leaf/api-platform/internal/router"
"go-template/internal/service" "leafdev.top/Leaf/api-platform/internal/service"
"go-template/internal/service/auth" "leafdev.top/Leaf/api-platform/internal/service/auth"
"go-template/internal/service/jwks" "leafdev.top/Leaf/api-platform/internal/service/jwks"
"go-template/internal/service/stream" "leafdev.top/Leaf/api-platform/internal/service/stream"
) )
// Injectors from wire.go: // Injectors from wire.go:

2
go.mod
View File

@ -1,4 +1,4 @@
module go-template module leafdev.top/Leaf/api-platform
go 1.23.2 go 1.23.2

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"go-template/internal/entity" "leafdev.top/Leaf/api-platform/internal/entity"
"gorm.io/gen" "gorm.io/gen"
) )

View File

@ -10,7 +10,7 @@ import (
"strings" "strings"
) )
const frameworkModuleName = "leafdev.top/ecosystem/billing" const frameworkModuleName = "leafdev.top/Leaf/api-platform"
func main() { func main() {
// 输入新的 go.mod module // 输入新的 go.mod module

View File

@ -1,16 +1,17 @@
package base package base
import ( import (
"go-template/internal/base/conf" "gorm.io/gorm"
"go-template/internal/base/logger" "leafdev.top/Leaf/api-platform/int
"go-template/internal/base/redis" "leafdev.top/Leaf/api-platform/internal/base/conf"
"go-template/internal/base/s3" "leafdev.top/Leaf/api-platform/internal/base/logger"
"go-template/internal/base/server" "leafdev.top/Leaf/api-platform/internal/base/redis"
"go-template/internal/batch" "leafdev.top/Leaf/api-platform/internal/base/s3"
"go-template/internal/dao" "leafdev.top/Leaf/api-platform/internal/base/server"
"go-template/internal/handler" "leafdev.top/Leaf/api-platform/internal/batch"
"go-template/internal/handler/http" "leafdev.top/Leaf/api-platform/internal/dao"
"go-template/internal/service" "leafdev.top/Leaf/api-platform/internal/handler"
"leafdev.top/Leaf/api-platform/internal/handler/http"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -1,7 +1,7 @@
package conf package conf
import ( import (
"go-template/configs" "leafdev.top/Leaf/api-platform/configs"
"os" "os"
) )

View File

@ -1,7 +1,7 @@
package conf package conf
import ( import (
"go-template/internal/base/logger" "leafdev.top/Leaf/api-platform/internal/base/logger"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"

View File

@ -2,8 +2,9 @@ package orm
import ( import (
"fmt" "fmt"
"go-template/internal/base/conf" "gorm.io/driver/postgres"
"go-template/internal/base/logger" "leafdev.top/Leaf/api-p
"leafdev.top/Leaf/api-platform/internal/base/conf"
"gorm.io/driver/postgres" "gorm.io/driver/postgres"
"gorm.io/gorm" "gorm.io/gorm"

View File

@ -3,7 +3,7 @@ package redis
import ( import (
"context" "context"
"fmt" "fmt"
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
"github.com/bsm/redislock" "github.com/bsm/redislock"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"

View File

@ -1,7 +1,7 @@
package s3 package s3
import ( import (
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
"github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials" "github.com/minio/minio-go/v7/pkg/credentials"

View File

@ -4,11 +4,11 @@ import (
"github.com/labstack/echo-contrib/echoprometheus" "github.com/labstack/echo-contrib/echoprometheus"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
echoMiddleware "github.com/labstack/echo/v4/middleware" echoMiddleware "github.com/labstack/echo/v4/middleware"
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
httpHandlers "go-template/internal/handler/http" httpHandlers "leafdev.top/Leaf/api-platform/internal/handler/http"
"go-template/internal/handler/http/response" "leafdev.top/Leaf/api-platform/internal/handler/http/response"
"go-template/internal/router" "leafdev.top/Leaf/api-platform/internal/router"
"go-template/pkg/consts" "leafdev.top/Leaf/api-platform/pkg/consts"
"net/http" "net/http"
) )

View File

@ -1,7 +1,7 @@
package batch package batch
import ( import (
"go-template/internal/base/logger" "leafdev.top/Leaf/api-platform/internal/base/logger"
) )
type Batch struct { type Batch struct {

View File

@ -16,7 +16,7 @@ import (
"gorm.io/plugin/dbresolver" "gorm.io/plugin/dbresolver"
"go-template/internal/entity" "leafdev.top/Leaf/api-platform/internal/entity"
) )
func newUser(db *gorm.DB, opts ...gen.DOOption) user { func newUser(db *gorm.DB, opts ...gen.DOOption) user {

View File

@ -1,7 +1,7 @@
package entity package entity
import ( import (
"go-template/internal/schema" "leafdev.top/Leaf/api-platform/internal/schema"
"time" "time"
) )

View File

@ -2,7 +2,7 @@ package documents
import ( import (
"context" "context"
"go-template/pkg/protos/documentService" "leafdev.top/Leaf/api-platform/pkg/protos/documentService"
) )
func (d *DocumentService) ListDocuments(ctx context.Context, req *documentService.ListDocumentsRequest) (*documentService.ListDocumentsResponse, error) { func (d *DocumentService) ListDocuments(ctx context.Context, req *documentService.ListDocumentsRequest) (*documentService.ListDocumentsResponse, error) {

View File

@ -1,8 +1,8 @@
package documents package documents
import ( import (
"go-template/internal/dao" "leafdev.top/Leaf/api-platform/internal/dao"
"go-template/pkg/protos/documentService" "leafdev.top/Leaf/api-platform/pkg/protos/documentService"
) )
type DocumentService struct { type DocumentService struct {

View File

@ -4,9 +4,9 @@ import (
"context" "context"
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth"
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging"
"go-template/internal/schema" "leafdev.top/Leaf/api-platform/internal/schema"
auth2 "go-template/internal/service/auth" auth2 "leafdev.top/Leaf/api-platform/internal/service/auth"
"go-template/pkg/consts" "leafdev.top/Leaf/api-platform/pkg/consts"
) )
type Auth struct { type Auth struct {

View File

@ -4,8 +4,8 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging"
"go-template/internal/base/logger"
"go.uber.org/zap" "go.uber.org/zap"
"leafdev.top/Leaf/api-platform/internal/base/logger"
) )
type Logger struct { type Logger struct {

View File

@ -2,8 +2,8 @@ package grpc
import ( import (
"github.com/google/wire" "github.com/google/wire"
"go-template/internal/handler/grpc/documents" "leafdev.top/Leaf/api-platform/internal/handler/grpc/documents"
"go-template/internal/handler/grpc/interceptor" "leafdev.top/Leaf/api-platform/internal/handler/grpc/interceptor"
) )
var ProviderSet = wire.NewSet( var ProviderSet = wire.NewSet(

View File

@ -2,8 +2,8 @@ package handler
import ( import (
"github.com/google/wire" "github.com/google/wire"
"go-template/internal/handler/grpc" "leafdev.top/Leaf/api-platform/internal/handler/grpc"
"go-template/internal/handler/http" "leafdev.top/Leaf/api-platform/internal/handler/http"
) )
var ProviderSet = wire.NewSet( var ProviderSet = wire.NewSet(

View File

@ -2,9 +2,9 @@ package v1
import ( import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"go-template/internal/handler/http/response" "leafdev.top/Leaf/api-platform/internal/handler/http/response"
"go-template/internal/schema" "leafdev.top/Leaf/api-platform/internal/schema"
"go-template/internal/service/auth" "leafdev.top/Leaf/api-platform/internal/service/auth"
"net/http" "net/http"
) )

View File

@ -2,11 +2,11 @@ package middleware
import ( import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
"go-template/internal/handler/http/response" "leafdev.top/Leaf/api-platform/internal/handler/http/response"
"go-template/internal/schema" "leafdev.top/Leaf/api-platform/internal/schema"
"go-template/internal/service/auth" "leafdev.top/Leaf/api-platform/internal/service/auth"
"go-template/pkg/consts" "leafdev.top/Leaf/api-platform/pkg/consts"
"net/http" "net/http"
"slices" "slices"
"strings" "strings"

View File

@ -3,11 +3,11 @@ package http
import ( import (
"github.com/google/wire" "github.com/google/wire"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
"go-template/internal/base/logger" "leafdev.top/Leaf/api-platform/internal/base/logger"
v1 "go-template/internal/handler/http/controller/v1" v1 "leafdev.top/Leaf/api-platform/internal/handler/http/controller/v1"
"go-template/internal/handler/http/middleware" "leafdev.top/Leaf/api-platform/internal/handler/http/middleware"
"go-template/internal/service/auth" "leafdev.top/Leaf/api-platform/internal/service/auth"
) )
type IMiddleware interface { type IMiddleware interface {

View File

@ -2,7 +2,7 @@ package migrations
import ( import (
"embed" "embed"
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
) )
//go:embed *.sql //go:embed *.sql

View File

@ -2,7 +2,7 @@ package router
import ( import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"go-template/internal/handler/http" "leafdev.top/Leaf/api-platform/internal/handler/http"
) )
// 两种方法都可以 // 两种方法都可以

View File

@ -2,7 +2,7 @@ package router
import ( import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
_ "go-template/docs" _ "leafdev.top/Leaf/api-platform/docs"
echoSwagger "github.com/swaggo/echo-swagger" echoSwagger "github.com/swaggo/echo-swagger"
) )

View File

@ -4,11 +4,11 @@ import (
"context" "context"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
"go-template/internal/base/logger" "leafdev.top/Leaf/api-platform/internal/base/logger"
"go-template/internal/schema" "leafdev.top/Leaf/api-platform/internal/schema"
"go-template/internal/service/jwks" "leafdev.top/Leaf/api-platform/internal/service/jwks"
"go-template/pkg/consts" "leafdev.top/Leaf/api-platform/pkg/consts"
) )
type Service struct { type Service struct {

View File

@ -2,8 +2,8 @@ package jwks
import ( import (
"errors" "errors"
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
"go-template/internal/base/logger" "leafdev.top/Leaf/api-platform/internal/base/logger"
"github.com/MicahParks/keyfunc/v3" "github.com/MicahParks/keyfunc/v3"
"github.com/golang-jwt/jwt/v5" "github.com/golang-jwt/jwt/v5"

View File

@ -1,10 +1,10 @@
package service package service
import ( import (
"go-template/internal/base/logger" "leafdev.top/Leaf/api-platform/internal/base/logger"
"go-template/internal/service/auth" "leafdev.top/Leaf/api-platform/internal/service/auth"
"go-template/internal/service/jwks" "leafdev.top/Leaf/api-platform/internal/service/jwks"
"go-template/internal/service/stream" "leafdev.top/Leaf/api-platform/internal/service/stream"
"github.com/google/wire" "github.com/google/wire"
) )

View File

@ -3,7 +3,7 @@ package stream
import ( import (
"context" "context"
"github.com/segmentio/kafka-go" "github.com/segmentio/kafka-go"
"go-template/internal/schema" "leafdev.top/Leaf/api-platform/internal/schema"
"time" "time"
) )

View File

@ -1,7 +1,7 @@
package stream package stream
import ( import (
"go-template/internal/base/conf" "leafdev.top/Leaf/api-platform/internal/base/conf"
) )
type Service struct { type Service struct {

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"go-template/cmd" "leafdev.top/Leaf/api-platform/cmd"
) )
// @title API Docs // @title API Docs

View File

@ -2,7 +2,7 @@ package consts
import ( import (
"errors" "errors"
"go-template/internal/schema" "leafdev.top/Leaf/api-platform/internal/schema"
) )
const ( const (

View File

@ -1,6 +1,6 @@
package consts package consts
import "go-template/internal/schema" import "leafdev.top/Leaf/api-platform/internal/schema"
const ( const (
RoleSuperAdmin schema.UserRole = "super-admin" RoleSuperAdmin schema.UserRole = "super-admin"