Files
jh-zz/actions/configs.go
2025-08-09 14:42:19 +08:00

34 lines
647 B
Go

package actions
import (
"gorm.io/gorm"
"zzman/model"
)
func FindConfigsByGateway(tx *gorm.DB, macaddr string) ([]model.Config, error) {
var configs []model.Config
err := tx.Find(&configs, "macaddr = ?", macaddr).Error
if err != nil {
return nil, err
}
return configs, nil
}
func CreateConfigs(tx *gorm.DB, configs []model.Config) error {
if len(configs) == 0 {
return nil
}
// 使用事务批量插入配置
return tx.Create(&configs).Error
}
func UpdateConfigs(tx *gorm.DB, configs []model.ConfigUpdate) error {
if len(configs) == 0 {
return nil
}
// 使用事务批量更新配置
return tx.Updates(&configs).Error
}