建立仓库

This commit is contained in:
2025-08-05 10:51:35 +08:00
commit 4bbc05fe1f
36 changed files with 1946 additions and 0 deletions

33
actions/configs.go Normal file
View File

@@ -0,0 +1,33 @@
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
}