feat: client 增删改查

This commit is contained in:
Blizzard
2025-05-08 23:03:00 +08:00
parent 75e9157e5e
commit ab51ba91bc
41 changed files with 1093 additions and 57 deletions
+7 -5
View File
@@ -4,15 +4,17 @@ import (
"github.com/redis/go-redis/v9"
"github.com/spf13/viper"
"go.uber.org/zap"
"golang.org/x/sync/singleflight"
"gorm.io/gorm"
"sundynix-go/config"
)
// 全局变量 加载在内存中
var (
Viper *viper.Viper
Logger *zap.Logger
Config *config.Config
DB *gorm.DB
Redis redis.UniversalClient
Viper *viper.Viper
Logger *zap.Logger
Config *config.Config
DB *gorm.DB
Redis redis.UniversalClient
ConcurrencyControl = &singleflight.Group{}
)
+4 -4
View File
@@ -6,10 +6,10 @@ import (
)
type BaseModel struct {
ID uint `gorm:"primarykey" json:"ID"` // 主键ID
CreatedAt time.Time // 创建时间
UpdatedAt time.Time // 更新时间
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间
Id uint `gorm:"primarykey" json:"id"` // 主键ID
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"` // 删除时间
}
// BeforeCreate 定义一个钩子,在创建之前执行自动插入字段