添加 submit 表记录每次提交配置;顺序排列提交配置
This commit is contained in:
27
actions/submit.go
Normal file
27
actions/submit.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
"zzman/clients/jd"
|
||||
"zzman/model"
|
||||
)
|
||||
|
||||
func RecordSubmit(time time.Time, gatewat model.Gateway, edges []jd.EdgeInfo) error {
|
||||
config, err := json.Marshal(edges)
|
||||
if err != nil {
|
||||
return fmt.Errorf("序列化提交数据失败:%w", err)
|
||||
}
|
||||
|
||||
err = model.DB.Create(&model.Submit{
|
||||
Time: time,
|
||||
Gateway: gatewat.Macaddr,
|
||||
Config: string(config),
|
||||
}).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf("保存提交记录失败:%w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user