-
Notifications
You must be signed in to change notification settings - Fork 0
/
delimiters.go
43 lines (37 loc) · 1 KB
/
delimiters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package mysql
import (
"github.com/Milefer7/compliation_exp/model"
"log"
)
type DelimiterMySQL struct{}
func NewDelimiterMySQL() *DelimiterMySQL {
return &DelimiterMySQL{}
}
func (d *DelimiterMySQL) ReadDelimiters() ([]model.Delimiter, error) {
deli := []model.Delimiter{}
result := db.Find(&deli)
if result.Error != nil {
log.Printf("ReadDelimiter数据库查询错误: %s", result.Error)
}
return deli, result.Error
}
func (d *DelimiterMySQL) UpdateDelimiters(Delimiters []model.Delimiter) error {
for _, delimiter := range Delimiters {
result := db.Save(&delimiter)
if result.Error != nil {
log.Printf("UpdateDelimiter数据库更新错误: %s", result.Error)
return result.Error
}
}
return nil
}
func (d *DelimiterMySQL) CreateDelimiters(Delimiters []model.Delimiter) error {
for _, delimiter := range Delimiters {
result := db.Create(&delimiter)
if result.Error != nil {
log.Printf("CreateDelimiter数据库创建错误: %s", result.Error)
return result.Error
}
}
return nil
}