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/logging"
"github.com/spf13/cobra"
"go-template/pkg/protos/documentService"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"leaf
"net"
)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
package s3
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/pkg/credentials"

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@ package documents
import (
"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) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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