Browse Source

项目初始化

huangyan 9 months ago
commit
c8311c32b4

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/project_management.iml" filepath="$PROJECT_DIR$/.idea/project_management.iml" />
+    </modules>
+  </component>
+</project>

+ 9 - 0
.idea/project_management.iml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="Go" enabled="true" />
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 37 - 0
app/controller/apply.go

@@ -0,0 +1,37 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/go-playground/validator/v10"
+	"project_management/app/e"
+	"project_management/app/model"
+	"project_management/app/services"
+	"project_management/unity"
+)
+
+var Apply services.Apply = &model.Apply{}
+
+func GetApplyList(c *gin.Context) {
+
+}
+
+// AddApply 添加应用
+func AddApply(c *gin.Context) {
+	var apply model.Apply
+	if err := c.ShouldBindJSON(&apply); err != nil {
+		e.ResponseWithMsg(c, e.JSONParsingFailed, e.JSONParsingFailed.GetMsg())
+		return
+	}
+	validate := validator.New()
+	if err := validate.Struct(apply); err != nil {
+		e.ResponseWithMsg(c, e.ERROR, err.Error())
+		return
+	}
+	// 生成应用ID
+	id := unity.RandomAppID()
+	for model.AppIdISRepeat(id) {
+		id = unity.RandomAppID()
+	}
+	apply.AppID = id
+	Apply.AddApply(apply)
+}

+ 47 - 0
app/e/R.go

@@ -0,0 +1,47 @@
+package e
+
+import (
+	"github.com/gin-gonic/gin"
+	"net/http"
+	"project_management/unity"
+)
+
+type R struct {
+	Code    Rescode     `json:"code"`
+	Message any         `json:"message"`
+	Data    interface{} `json:"data"`
+}
+
+func ResponseError(c *gin.Context, code Rescode) {
+	c.JSON(http.StatusOK, &R{
+		Code:    code,
+		Message: code.GetMsg(),
+		Data:    nil,
+	})
+}
+func ResponseSuccess(c *gin.Context, data interface{}) {
+	c.JSON(http.StatusOK, &R{
+		Code:    SUCCESS,
+		Message: SUCCESS.GetMsg(),
+		Data:    data,
+	})
+}
+func ResponseWithMsg(c *gin.Context, code Rescode, msg any) {
+	c.JSON(http.StatusOK, &R{
+		Code:    code,
+		Message: msg,
+		Data:    nil,
+	})
+}
+func ResPonsePage(c *gin.Context, data interface{}, total int64, params unity.QueryPageParams) {
+	c.JSON(http.StatusOK, &R{
+		Code:    SUCCESS,
+		Message: SUCCESS.GetMsg(),
+		Data: gin.H{
+			"result":    data,
+			"total":     total,
+			"current":   params.Page,
+			"page_size": params.Size,
+		},
+	})
+}

+ 67 - 0
app/e/code_msg.go

@@ -0,0 +1,67 @@
+package e
+
+type Rescode int64
+
+const (
+	SUCCESS Rescode = 200 + iota
+	ERROR
+)
+
+const (
+	TokenIsInvalid Rescode = 1001 + iota
+	TokenIsExpired
+	DELETEFAIL
+	UPDATEFAIL
+	PaginationFailed
+	JSONParsingFailed
+	TheUserAlreadyExists
+	AlreadyExists
+	TheSystemIsAbnormal
+	CodeIsError
+	TheVerificationCodeWasNotSent
+	AccountExists
+	Theuseralreadyexists
+	ThePhoneNumberIsWrong
+	AnExceptionOccursWhenSendingAnSMSVerificationCode
+	TokenIsFaild
+	ThePasswordIsWrongOrThePhoneNumberIsIncorrect
+	HasSend
+	TheUserIsEmpty
+	Repeat
+)
+
+var MsgFlags = map[Rescode]string{
+	SUCCESS:                       "ok",
+	ERROR:                         "fail",
+	DELETEFAIL:                    "删除失败",
+	TheUserAlreadyExists:          "用户已存在",
+	TheSystemIsAbnormal:           "系统异常",
+	CodeIsError:                   "验证码错误",
+	UPDATEFAIL:                    "更新失败",
+	Theuseralreadyexists:          "用户已存在",
+	JSONParsingFailed:             "json解析失败",
+	ThePhoneNumberIsWrong:         "手机号错误",
+	HasSend:                       "验证码已发送",
+	AlreadyExists:                 "手机号已存在",
+	AccountExists:                 "账号已存在",
+	PaginationFailed:              "分页查询失败",
+	TheVerificationCodeWasNotSent: "验证码未发送",
+	AnExceptionOccursWhenSendingAnSMSVerificationCode: "发送短信验证码出现异常",
+	ThePasswordIsWrongOrThePhoneNumberIsIncorrect:     "手机号或者密码错误",
+	TokenIsInvalid: "Token 无效",
+	TokenIsExpired: "Token 过期",
+	TokenIsFaild:   "Token 生成失败",
+	TheUserIsEmpty: "用户为空",
+	Repeat:         "应用名重复",
+}
+
+func (c Rescode) GetMsg() string {
+	// 检查Rescode是否在MsgFlags中定义,避免返回意外的消息
+	msg, ok := MsgFlags[c]
+	if ok {
+		return msg
+	} else {
+		// 如果Rescode无效,则返回错误消息
+		return MsgFlags[ERROR]
+	}
+}

+ 30 - 0
app/middleware/admin_middleware.go

@@ -0,0 +1,30 @@
+package middlewares
+
+import (
+	"github.com/bytedance/sonic"
+	"github.com/gin-gonic/gin"
+	"project_management/app/e"
+	"project_management/nats"
+	"time"
+)
+
+func AdminMiddleware() gin.HandlerFunc {
+	return func(c *gin.Context) {
+		header := c.GetHeader("Authorization")
+		request, err := nats.Nats.Request("login_token_validation", []byte(header), 3*time.Second)
+		if err != nil {
+			e.ResponseWithMsg(c, e.TokenIsInvalid, e.TokenIsInvalid.GetMsg())
+		} else {
+			var response UserResponse
+			sonic.Unmarshal(request.Data, &response)
+			users := response.User.(map[string]interface{})
+			role := users["role"].(string)
+			if role == "admin" {
+				c.Next()
+			} else {
+				e.ResponseWithMsg(c, e.TokenIsInvalid, e.TokenIsInvalid.GetMsg())
+				c.Abort()
+			}
+		}
+	}
+}

+ 24 - 0
app/middleware/cors.go

@@ -0,0 +1,24 @@
+package middlewares
+
+import (
+	"github.com/gin-gonic/gin"
+	"net/http"
+)
+
+func Cors() gin.HandlerFunc {
+	return func(c *gin.Context) {
+		method := c.Request.Method
+		origin := c.Request.Header.Get("Origin")
+		if origin != "" {
+			c.Header("Access-Control-Allow-Origin", "*") // 可将将 * 替换为指定的域名
+			c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE")
+			c.Header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization")
+			c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Cache-Control, Content-Language, Content-Type")
+			c.Header("Access-Control-Allow-Credentials", "true")
+		}
+		if method == "OPTIONS" {
+			c.AbortWithStatus(http.StatusNoContent)
+		}
+		c.Next()
+	}
+}

+ 35 - 0
app/middleware/login_middleware.go

@@ -0,0 +1,35 @@
+package middlewares
+
+import (
+	"github.com/bytedance/sonic"
+	"github.com/gin-gonic/gin"
+	"project_management/app/e"
+	"project_management/nats"
+	"time"
+)
+
+type UserResponse struct {
+	Code    int    `json:"code"`
+	Message string `json:"message"`
+	User    any    `json:"user,omitempty"`
+}
+
+func LoginMiddleware() gin.HandlerFunc {
+	return func(c *gin.Context) {
+		header := c.GetHeader("Authorization")
+		request, err := nats.Nats.Request("login_token_validation", []byte(header), 3*time.Second)
+		if err != nil {
+			e.ResponseWithMsg(c, e.TokenIsInvalid, e.TokenIsInvalid.GetMsg())
+		} else {
+			var response UserResponse
+			sonic.Unmarshal(request.Data, &response)
+			if response.Code == 200 {
+				c.Set("user", response.User)
+				c.Next()
+			} else {
+				e.ResponseWithMsg(c, e.TokenIsInvalid, e.TokenIsInvalid.GetMsg())
+				c.Abort()
+			}
+		}
+	}
+}

+ 43 - 0
app/model/apply.go

@@ -0,0 +1,43 @@
+package model
+
+import (
+	"gorm.io/gorm"
+	"project_management/app/e"
+	"project_management/global"
+	"strings"
+	"time"
+)
+
+type Apply struct {
+	gorm.Model
+	AppID             string    `gorm:"type:varchar(50);not null;unique" json:"app_id"`                                              // 应用id
+	AppName           string    `gorm:"type:varchar(50);index:idx_name,unique" json:"app_name" validate:"required" min:"3" max:"20"` // 应用名称
+	AppDescription    string    `gorm:"type:varchar(50);not null;unique" json:"app_description" validate:"required"`                 // 应用描述
+	CertificationTime time.Time `gorm:"type:datetime;not null;unique" json:"certification_time"`                                     // 认证到期时间
+	State             int       `gorm:"type:int;not null;unique" json:"state"`                                                       // 状态 0 正常 1 停用 2 过期 3 禁用
+}
+
+func (a Apply) AddApply(apply Apply) e.Rescode {
+	//TODO implement me
+	//默认每一应用有一年免费时间
+	apply.CertificationTime = apply.CreatedAt.Add(time.Hour * 24 * 365)
+	apply.State = 0
+	tx := global.DBLink.Create(&apply)
+	if tx.Error != nil {
+		errMsg := tx.Error.Error()
+		if strings.Contains(errMsg, "Duplicate entry") {
+			return e.Repeat
+		}
+	}
+	if tx.RowsAffected > 0 {
+		return e.SUCCESS
+	}
+	return e.SUCCESS
+}
+func AppIdISRepeat(id string) bool {
+	tx := global.DBLink.Where("app_id = ?", id).First(&Apply{})
+	if tx.RowsAffected > 0 {
+		return true
+	}
+	return false
+}

+ 11 - 0
app/router.go

@@ -0,0 +1,11 @@
+package app
+
+import (
+	"github.com/gin-gonic/gin"
+	"project_management/global"
+)
+
+func InitRouter() error {
+	engine := gin.New()
+	return engine.Run(global.ServerSetting.Port)
+}

+ 10 - 0
app/services/apply.go

@@ -0,0 +1,10 @@
+package services
+
+import (
+	"project_management/app/e"
+	"project_management/app/model"
+)
+
+type Apply interface {
+	AddApply(apply model.Apply) e.Rescode
+}

+ 45 - 0
configs/config.yaml

@@ -0,0 +1,45 @@
+database:
+  # 数据库类型
+  dialect: mysql
+  # host地址
+  host: 127.0.0.1
+  # 端口
+  port: 3306
+  # 数据库名称
+  db: project_management
+  # 数据库用户名
+  userName: root
+  # 数据库密码
+  password: 123456
+  # 其他配置参数
+  otherParams: charset=utf8mb4&parseTime=True&loc=Local
+  # 最大空闲连接数
+  maxIdleConn: 20
+  # 最大连接数
+  maxOpenConn: 200
+  # 连接超时关闭时间,单位:秒
+  connMaxLifetime: 60
+jwt:
+  secret: "xxxxx"
+  refresh_expire: 168
+  Issuer: "lc_oauth"
+# 服务相关配置
+server:
+  # 启动模式 debug、release
+  mode: debug
+  # http服务信息
+  insecureServingInfo:
+  # 监听端口
+  port: ":9999"
+subMail:
+  appid: "97173"
+  signature: "f639a60e41ee0554921d89884f5ff87e"
+redis:
+  addr: "192.168.0.100:6379"
+  password: ""
+  db: 0
+nats:
+  NatsServer_Url: "nats://127.0.0.0:4222"
+swag:
+  # 将环境变量 NAME_OF_ENV_VARIABLE设置为任意值,则 /swagger/*any 返回404响应
+  enable: "NAME_OF_ENV_VARIABLE"

+ 46 - 0
configs/setting.go

@@ -0,0 +1,46 @@
+package global
+
+import "github.com/spf13/viper"
+
+type Settings struct {
+	vp *viper.Viper
+}
+
+var sections = make(map[string]interface{})
+
+// NewSetting 读取配置
+func NewSetting() (*Settings, error) {
+	vp := viper.New()
+	vp.SetConfigName("config")
+	vp.AddConfigPath("configs")
+	vp.SetConfigType("yaml")
+	err := vp.ReadInConfig()
+	if err != nil {
+		return nil, err
+	}
+	s := &Settings{vp}
+	return s, nil
+}
+
+// ReadSection 读取指定的一段
+func (s *Settings) ReadSection(k string, v interface{}) error {
+	err := s.vp.UnmarshalKey(k, v)
+	if err != nil {
+		return err
+	}
+	if _, ok := sections[k]; !ok {
+		sections[k] = v
+	}
+	return nil
+}
+
+// ReloadAllSection 重新加载
+func (s *Settings) ReloadAllSection() error {
+	for k, v := range sections {
+		err := s.ReadSection(k, v)
+		if err != nil {
+			return err
+		}
+	}
+	return nil
+}

+ 12 - 0
database/migrate.go

@@ -0,0 +1,12 @@
+package database
+
+import (
+	"gorm.io/gorm"
+	"project_management/app/model"
+)
+
+func Migrate(db *gorm.DB) {
+	db.Set("gorm:table_options", "ENGINE=InnoDB").AutoMigrate(
+		model.Apply{},
+	)
+}

+ 34 - 0
global/db.go

@@ -0,0 +1,34 @@
+package global
+
+import (
+	"fmt"
+	"gorm.io/driver/mysql"
+	"gorm.io/gorm"
+	"gorm.io/gorm/logger"
+)
+
+var (
+	DBLink *gorm.DB
+)
+
+func SetupDBLink() error {
+	var err error
+	dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?%s",
+		DatabaseSetting.UserName,
+		DatabaseSetting.Password,
+		DatabaseSetting.Host,
+		DatabaseSetting.Db,
+		DatabaseSetting.OtherParams,
+	)
+	DBLink, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
+		DisableForeignKeyConstraintWhenMigrating: true,
+		Logger:                                   logger.Default.LogMode(logger.Info),
+	})
+	if err != nil {
+		return err
+	}
+	//DBLink.SingularTable(true)
+	//DBLink.DB().SetMaxIdleConns(DatabaseSetting.MaxIdleConn)
+	//DBLink.DB().SetMaxOpenConns(DatabaseSetting.MaxOpenConn)
+	return nil
+}

+ 24 - 0
global/redis.go

@@ -0,0 +1,24 @@
+package global
+
+import (
+	"context"
+	"fmt"
+	"github.com/go-redis/redis/v8"
+	"project_management/simple_zap"
+)
+
+var Rdb *redis.Client
+
+func SetupRedisLink() {
+	Rdb = redis.NewClient(&redis.Options{
+		Addr:     RedisSetting.Addr,
+		Password: "",
+		DB:       0,
+	})
+	ctx := context.Background()
+	_, err := Rdb.Ping(ctx).Result()
+	if err != nil {
+		simple_zap.WithCtx(context.Background()).Sugar().Warn("redis连接失败", err)
+		fmt.Println(err)
+	}
+}

+ 76 - 0
global/setting.go

@@ -0,0 +1,76 @@
+package global
+
+import (
+	global "project_management/configs"
+)
+
+// DatabaseSettingS 数据库配置
+type DatabaseSettingS struct {
+	Dialect         string `json:"dialect"`
+	Host            string `json:"host"`
+	Port            string `json:"port"`
+	UserName        string `json:"userName"`
+	Password        string `json:"password"`
+	Db              string `json:"db"`
+	OtherParams     string `json:"otherParams"`
+	MaxIdleConn     int    `json:"max_idle_conn"`
+	MaxOpenConn     int    `json:"max_open_conn"`
+	ConnMaxLifetime string `json:"conn_max_lifetime"`
+}
+
+// Nats 配置
+type Nats struct {
+	NatsServerUrl string `json:"NatsServer_Url"`
+}
+
+// Jwt 配置
+type Jwt struct {
+	Secret        string `json:"secret"`
+	RefreshExpire int    `json:"refresh_expire"`
+	Issuer        string `json:"issuer"`
+}
+
+// ServerSettingS 服务器配置
+type ServerSettingS struct {
+	Mode                string `json:"mode"`
+	Port                string `json:"port"`
+	InsecureServingInfo string `json:"insecure_serving_info"`
+}
+type SubMail struct {
+	Appid     string `json:"appid"`
+	Signature string `json:"signature"`
+}
+type Redis struct {
+	Addr     string `json:"addr"`
+	Password string `json:"password"`
+	DB       int    `json:"db"`
+}
+type Swagger struct {
+	Enable string `json:"enable"`
+}
+
+var (
+	DatabaseSetting *DatabaseSettingS
+	NatsSetting     *Nats
+	JwtSetting      *Jwt
+	ServerSetting   *ServerSettingS
+	SubMailSetting  *SubMail
+	RedisSetting    *Redis
+	SwaggerSetting  *Swagger
+)
+
+// SetupSetting 读取配置到全局变量
+func SetupSetting() error {
+	s, err := global.NewSetting()
+	err = s.ReadSection("Database", &DatabaseSetting)
+	err = s.ReadSection("Nats", &NatsSetting)
+	err = s.ReadSection("Jwt", &JwtSetting)
+	err = s.ReadSection("Server", &ServerSetting)
+	err = s.ReadSection("SubMail", &SubMailSetting)
+	err = s.ReadSection("Redis", &RedisSetting)
+	err = s.ReadSection("Swagger", &SwaggerSetting)
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 65 - 0
go.mod

@@ -0,0 +1,65 @@
+module project_management
+
+go 1.21
+
+require (
+	github.com/gin-gonic/gin v1.10.0
+	github.com/go-playground/locales v0.14.1
+	github.com/go-playground/universal-translator v0.18.1
+	github.com/go-playground/validator/v10 v10.22.0
+	github.com/go-redis/redis/v8 v8.11.5
+	github.com/nats-io/nats.go v1.36.0
+	github.com/spf13/viper v1.19.0
+	go.uber.org/zap v1.27.0
+	gopkg.in/natefinch/lumberjack.v2 v2.2.1
+	gorm.io/driver/mysql v1.5.7
+	gorm.io/gorm v1.25.10
+)
+
+require (
+	github.com/bytedance/sonic v1.11.6 // indirect
+	github.com/bytedance/sonic/loader v0.1.1 // indirect
+	github.com/cespare/xxhash/v2 v2.1.2 // indirect
+	github.com/cloudwego/base64x v0.1.4 // indirect
+	github.com/cloudwego/iasm v0.2.0 // indirect
+	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
+	github.com/fsnotify/fsnotify v1.7.0 // indirect
+	github.com/gabriel-vasile/mimetype v1.4.3 // indirect
+	github.com/gin-contrib/sse v0.1.0 // indirect
+	github.com/go-sql-driver/mysql v1.7.0 // indirect
+	github.com/goccy/go-json v0.10.2 // indirect
+	github.com/hashicorp/hcl v1.0.0 // indirect
+	github.com/jinzhu/inflection v1.0.0 // indirect
+	github.com/jinzhu/now v1.1.5 // indirect
+	github.com/json-iterator/go v1.1.12 // indirect
+	github.com/klauspost/compress v1.17.2 // indirect
+	github.com/klauspost/cpuid/v2 v2.2.7 // indirect
+	github.com/leodido/go-urn v1.4.0 // indirect
+	github.com/magiconair/properties v1.8.7 // indirect
+	github.com/mattn/go-isatty v0.0.20 // indirect
+	github.com/mitchellh/mapstructure v1.5.0 // indirect
+	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+	github.com/modern-go/reflect2 v1.0.2 // indirect
+	github.com/nats-io/nkeys v0.4.7 // indirect
+	github.com/nats-io/nuid v1.0.1 // indirect
+	github.com/pelletier/go-toml/v2 v2.2.2 // indirect
+	github.com/sagikazarmark/locafero v0.4.0 // indirect
+	github.com/sagikazarmark/slog-shim v0.1.0 // indirect
+	github.com/sourcegraph/conc v0.3.0 // indirect
+	github.com/spf13/afero v1.11.0 // indirect
+	github.com/spf13/cast v1.6.0 // indirect
+	github.com/spf13/pflag v1.0.5 // indirect
+	github.com/subosito/gotenv v1.6.0 // indirect
+	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
+	github.com/ugorji/go/codec v1.2.12 // indirect
+	go.uber.org/multierr v1.10.0 // indirect
+	golang.org/x/arch v0.8.0 // indirect
+	golang.org/x/crypto v0.23.0 // indirect
+	golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
+	golang.org/x/net v0.25.0 // indirect
+	golang.org/x/sys v0.20.0 // indirect
+	golang.org/x/text v0.15.0 // indirect
+	google.golang.org/protobuf v1.34.1 // indirect
+	gopkg.in/ini.v1 v1.67.0 // indirect
+	gopkg.in/yaml.v3 v3.0.1 // indirect
+)

+ 169 - 0
go.sum

@@ -0,0 +1,169 @@
+github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
+github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
+github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
+github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
+github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
+github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
+github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
+github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
+github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
+github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
+github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
+github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
+github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
+github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
+github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
+github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
+github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
+github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
+github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
+github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
+github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
+github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
+github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
+github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
+github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
+github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
+github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
+github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
+github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
+github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
+github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
+github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
+github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
+github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
+github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
+github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
+github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
+github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
+github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
+github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
+github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
+github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
+github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4=
+github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
+github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
+github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
+github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
+github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
+github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
+github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
+github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
+github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
+github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
+github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
+github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
+github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
+github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/nats-io/nats.go v1.36.0 h1:suEUPuWzTSse/XhESwqLxXGuj8vGRuPRoG7MoRN/qyU=
+github.com/nats-io/nats.go v1.36.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
+github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI=
+github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc=
+github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
+github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
+github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
+github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
+github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
+github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
+github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
+github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
+github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
+github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
+github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
+github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
+github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
+github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
+github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
+github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
+github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
+github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
+github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
+github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
+github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
+github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
+github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
+github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
+github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
+github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
+github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
+github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
+github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
+github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
+github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
+go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
+go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
+go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
+go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
+go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
+go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
+golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
+golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
+golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
+golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
+golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
+golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
+golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
+golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
+golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
+golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
+google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
+gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
+gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
+gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
+gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
+gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s=
+gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
+nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
+rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

+ 44 - 0
main.go

@@ -0,0 +1,44 @@
+package main
+
+import (
+	"context"
+	"project_management/app"
+	"project_management/database"
+	"project_management/global"
+	"project_management/simple_zap"
+	"project_management/unity"
+)
+
+func init() {
+	err := global.SetupSetting()
+	if err != nil {
+		simple_zap.WithCtx(context.Background()).Sugar().Warn(err, "配置文件读取失败")
+	}
+	err = global.SetupDBLink()
+	if err != nil {
+		simple_zap.WithCtx(context.Background()).Sugar().Warn(err, "数据库连接失败")
+	}
+	// 数据库迁移
+	database.Migrate(global.DBLink)
+	//本地化
+	if err = unity.Translator("zh"); err != nil {
+		simple_zap.WithCtx(context.Background()).Sugar().Warn(err, "注册本地化失败")
+	}
+	//nats
+	//nats.SetupNats()
+}
+
+// @title 面板开发
+// @version 1.0
+// @description 面板开发
+// @Host 127.0.0.1:8081
+// @BasePath /api
+//
+//go:generate swag init --parseDependency --parseDepth=6
+func main() {
+	err := app.InitRouter()
+	if err != nil {
+		simple_zap.WithCtx(context.Background()).Sugar().Warn(err, "项目初始化失败")
+		return
+	}
+}

+ 19 - 0
nats/Nats.go

@@ -0,0 +1,19 @@
+package nats
+
+import (
+	"context"
+	"github.com/nats-io/nats.go"
+	"project_management/global"
+	"project_management/simple_zap"
+)
+
+var Nats *nats.Conn
+
+func SetupNats() {
+	var err error
+	Nats, err = nats.Connect(global.NatsSetting.NatsServerUrl)
+	if err != nil {
+		simple_zap.WithCtx(context.Background()).Sugar().Warn(err, "nats 连接失败")
+		panic(err)
+	}
+}

+ 62 - 0
simple_zap/simple_zap.go

@@ -0,0 +1,62 @@
+package simple_zap
+
+import (
+	"context"
+	"go.uber.org/zap"
+	"go.uber.org/zap/zapcore"
+	"gopkg.in/natefinch/lumberjack.v2"
+)
+
+const loggerCtxKey = "baozhida"
+
+var Logger *zap.Logger
+
+func init() {
+	hook := lumberjack.Logger{
+		Filename:   "./log/app.log",
+		MaxSize:    1,
+		Compress:   true,
+		MaxAge:     30,
+		MaxBackups: 7,
+		LocalTime:  true,
+	}
+	encoder_config := zapcore.EncoderConfig{
+		MessageKey:     "message",
+		LevelKey:       "level",
+		TimeKey:        "time",
+		CallerKey:      "lineNum",
+		FunctionKey:    "func",
+		LineEnding:     zapcore.DefaultLineEnding,      // 回车符换行
+		EncodeLevel:    zapcore.LowercaseLevelEncoder,  // level小写: info,debug,warn等 而不是 Info, Debug,Warn等
+		EncodeTime:     zapcore.ISO8601TimeEncoder,     // 时间格式: "2006-01-02T15:04:05.000Z0700"
+		EncodeDuration: zapcore.SecondsDurationEncoder, // 时间戳用float64型,更加准确, 另一种是NanosDurationEncoder int64
+		EncodeCaller:   zapcore.ShortCallerEncoder,     // 产生日志文件的路径格式: 包名/文件名:行号
+	}
+	caller := zap.AddCaller()         //日志打印输出 文件名, 行号, 函数名
+	development := zap.Development()  // 可输出 dpanic, panic 级别的日志
+	field := zap.Fields()             // 负责给日志生成一个个 k-v 对
+	var syncers []zapcore.WriteSyncer // io writer
+	syncers = append(syncers, zapcore.AddSync(&hook))
+	atomic_level := zap.NewAtomicLevel()  // 设置日志 level
+	atomic_level.SetLevel(zap.DebugLevel) // 打印 debug, info, warn,eror, depanic,panic,fetal 全部级别日志
+	core := zapcore.NewCore(zapcore.NewJSONEncoder(encoder_config), zapcore.NewMultiWriteSyncer(syncers...), atomic_level)
+	Logger = zap.New(core, caller, development, field)
+
+}
+
+// NewCtx 给 ctx 注入一个 looger, logger 中包含Field(内含日志打印的 k-v对)
+func NewCtx(ctx context.Context, fields ...zapcore.Field) context.Context {
+	return context.WithValue(ctx, loggerCtxKey, WithCtx(ctx).With(fields...))
+}
+
+// WithCtx 尝试从 context 中获取带有 traceId Field的 logge
+func WithCtx(ctx context.Context) *zap.Logger {
+	if ctx == nil {
+		return Logger
+	}
+	ctx_logger, ok := ctx.Value(loggerCtxKey).(*zap.Logger)
+	if ok {
+		return ctx_logger
+	}
+	return Logger
+}

+ 16 - 0
unity/getuid.go

@@ -0,0 +1,16 @@
+package unity
+
+import (
+	"github.com/gin-gonic/gin"
+)
+
+func GetUId(c *gin.Context) int {
+	//mustGet := c.MustGet("user")
+	value, exists := c.Get("user")
+	if exists {
+		users := value.(map[string]interface{})
+		id := int(users["ID"].(float64))
+		return id
+	}
+	return 0
+}

+ 29 - 0
unity/randomId.go

@@ -0,0 +1,29 @@
+package unity
+
+import (
+	"math/rand"
+	"time"
+)
+
+// RandomId 生成32位随机id
+func RandomId() string {
+	const letterBytes = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+	rand.Seed(time.Now().UnixNano())
+
+	b := make([]byte, 32)
+	for i := range b {
+		b[i] = letterBytes[rand.Intn(len(letterBytes))]
+	}
+	return string(b)
+}
+
+// RandomAppID 生成12位随机appid
+func RandomAppID() string {
+	const letterBytes = "0123456789"
+	rand.Seed(time.Now().UnixNano())
+	b := make([]byte, 12)
+	for i := range b {
+		b[i] = letterBytes[rand.Intn(len(letterBytes))]
+	}
+	return string(b)
+}

+ 120 - 0
unity/unity.go

@@ -0,0 +1,120 @@
+package unity
+
+import (
+	"errors"
+	"project_management/global"
+)
+
+type PageParams struct {
+	Page int    `json:"page" form:"page"`
+	Size int    `json:"size" form:"size"`
+	Desc string `json:"desc" form:"desc"`
+}
+type QueryPageParams struct {
+	Page  int    `json:"page" form:"page"`
+	Size  int    `json:"size" form:"size"`
+	Query string `json:"query" form:"query"`
+	Desc  string `json:"desc" form:"desc"`
+}
+
+// Paginate 使用给定的DB连接执行分页查询
+func Paginate[T any](params PageParams, model T) (result []T, total int64, current int, err error) {
+	var count int64
+	if err = global.DBLink.Model(model).Count(&count).Error; err != nil {
+		return nil, 0, 0, err
+	}
+
+	// 计算总页数
+	//	totalPages := int(math.Ceil(float64(count) / float64(params.Size)))
+	// 计算偏移量并设置分页大小
+	offset := (params.Page - 1) * params.Size
+	// 执行实际分页查询
+	if err = global.DBLink.Offset(offset).Limit(params.Size).Order(params.Desc).Find(&result).Error; err != nil {
+		return nil, 0, 0, err
+	}
+	return result, count, params.Page, nil
+}
+
+func PaginateWithCondition[T any](params QueryPageParams, model T, queryCond interface{}) (result []T, total int64, err error) {
+	var count int64
+	if queryCond != nil {
+		if err = global.DBLink.Model(model).Where(queryCond, params.Query).Count(&count).Error; err != nil {
+			return nil, 0, err
+		}
+		// 计算查询的偏移量,并设置每次查询的记录数量
+		offset := (params.Page - 1) * params.Size
+		// 执行分页查询,包括偏移量设置、限制查询数量、排序及应用额外查询条件
+		if err = global.DBLink.Offset(offset).Limit(params.Size).Order(params.Desc).Where(queryCond, params.Query).Find(&result).Error; err != nil {
+			return nil, 0, err
+		}
+	} else {
+		if err = global.DBLink.Model(model).Count(&count).Error; err != nil {
+			return nil, 0, err
+		}
+		// 计算查询的偏移量,并设置每次查询的记录数量
+		offset := (params.Page - 1) * params.Size
+		// 执行分页查询,包括偏移量设置、限制查询数量、排序及应用额外查询条件
+		if err = global.DBLink.Offset(offset).Limit(params.Size).Order(params.Desc).Find(&result).Error; err != nil {
+			return nil, 0, err
+		}
+	}
+	return result, count, nil
+}
+
+func AddGenericItem[T any](item T, mapper func(T) interface{}) error {
+	dbModel := mapper(item)
+	if err := global.DBLink.Create(dbModel).Error; err != nil {
+		return err
+	}
+	return nil
+}
+
+// GetById 根据id查询
+func GetById[T any](id int, model T) (T, error) {
+	tx := global.DBLink.Where("id = ?", id).First(&model)
+	if tx.RowsAffected <= 0 {
+		return model, errors.New("查询失败,当前id不存在")
+	} else {
+		return model, nil
+	}
+}
+
+// UpdateById 根据id进行修改
+func UpdateById[T any](id int, model T) (T, error) {
+	tx := global.DBLink.Where("id = ?", id).Updates(&model)
+	if tx.RowsAffected > 0 {
+		return model, nil
+	} else {
+		return model, errors.New("修改失败当前id不存在")
+	}
+}
+
+// Add 添加
+func Add[T any](model T) (T, error) {
+	tx := global.DBLink.Create(&model)
+	if tx.RowsAffected > 0 {
+		return model, nil
+	} else {
+		return model, errors.New("添加失败")
+	}
+}
+
+// DeleteById 根据id删除
+func DeleteById[T any](id int, model T) (T, error) {
+	tx := global.DBLink.Where("id = ?", id).Delete(&model)
+	if tx.RowsAffected > 0 {
+		return model, nil
+	} else {
+		return model, errors.New("删除失败当前id不存在")
+	}
+}
+
+// QueryAll 获取所有信息
+func QueryAll(table string) ([]any, error) {
+	var result []any
+	tx := global.DBLink.Table(table).Find(&result)
+	if tx.Error != nil {
+		return result, errors.New("查询失败")
+	}
+	return result, nil
+}

+ 57 - 0
unity/zh_cn.go

@@ -0,0 +1,57 @@
+package unity
+
+import (
+	"fmt"
+	"github.com/gin-gonic/gin/binding"
+	"github.com/go-playground/locales/en"
+	"github.com/go-playground/locales/zh"
+	ut "github.com/go-playground/universal-translator"
+	"github.com/go-playground/validator/v10"
+	enTranslations "github.com/go-playground/validator/v10/translations/en"
+	zhTranslations "github.com/go-playground/validator/v10/translations/zh"
+)
+
+var Trans ut.Translator // 声明一个全局的Translator变量
+
+// Translator 是一个用于设置验证器本地化翻译的函数
+func Translator(local string) error {
+	// 验证并获取Validator引擎实例
+	if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
+		// 初始化英语和中文翻译器
+		zhT := zh.New()
+		enT := en.New()
+
+		// 创建一个通用翻译器实例,传入多个翻译器(这里是英语和中文)
+		uni := ut.New(enT, zhT, enT)
+
+		// 尝试从通用翻译器中获取指定语言的翻译器
+		var found bool
+		Trans, found = uni.GetTranslator(local)
+		if !found {
+			return fmt.Errorf("failed to find translator for %s", local)
+		}
+
+		// 根据本地化语言注册相应的翻译器到验证器中
+		switch local {
+		case "en":
+			err := enTranslations.RegisterDefaultTranslations(v, Trans)
+			if err != nil {
+				return err
+			}
+		case "zh":
+			err := zhTranslations.RegisterDefaultTranslations(v, Trans)
+			if err != nil {
+				return err
+			}
+		default:
+			// 如果指定了不受支持的语言,默认使用英文
+			err := enTranslations.RegisterDefaultTranslations(v, Trans)
+			if err != nil {
+				return err
+			}
+		}
+	} else {
+		return fmt.Errorf("validator engine not found")
+	}
+	return nil
+}