feat: add gormv2 and support sqlite

This commit is contained in:
engigu
2024-04-29 17:31:13 +08:00
parent 44054ae157
commit 33e44ce596
22 changed files with 236 additions and 279 deletions
+8 -8
View File
@@ -3,13 +3,13 @@ package models
type SendTasksIns struct {
UUIDModel
TaskID string `json:"task_id" gorm:"type:varchar(12) comment '任务id';default:'';index:task_id"`
WayID string `json:"way_id" gorm:"type:varchar(12) comment '渠道id';default:'';index:way_id"`
WayType string `json:"way_type" gorm:"type:varchar(100) comment '渠道类型';default:'';index:way_type"`
ContentType string `json:"content_type" gorm:"type:varchar(100) comment '实例类型';default:'';index:content_type"`
Config string `json:"config" gorm:"type:text comment '实例配置';"`
Extra string `json:"extra" gorm:"type:text comment '额外信息';"`
Enable int `json:"enable" gorm:"type:int comment '开启、暂停状态';default:1;"`
TaskID string `json:"task_id" gorm:"type:varchar(12) ;default:'';index"`
WayID string `json:"way_id" gorm:"type:varchar(12) ;default:'';index"`
WayType string `json:"way_type" gorm:"type:varchar(100) ;default:'';index"`
ContentType string `json:"content_type" gorm:"type:varchar(100) ;default:'';index"`
Config string `json:"config" gorm:"type:text ;"`
Extra string `json:"extra" gorm:"type:text ;"`
Enable int `json:"enable" gorm:"type:int ;default:1;"`
}
// InsEmailConfig 实例里面的邮箱config
@@ -39,7 +39,7 @@ func ManyAddTaskIns(taskIns []SendTasksIns) error {
tx := db.Begin()
for _, ins := range taskIns {
// 存在就跳过这条ins记录
err := db.Where("id = ?", ins.ID).Find(&SendTasksIns{}).Error
err := db.Where("id = ?", ins.ID).Take(&SendTasksIns{}).Error
if err == nil {
continue
}