• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yyle88 / gormcngen / 12226047375

08 Dec 2024 11:06PM UTC coverage: 54.699% (-2.5%) from 57.2%
12226047375

push

github

yangyile
伴随底层库的升级而增加字段验证特性

7 of 41 new or added lines in 3 files covered. (17.07%)

291 of 532 relevant lines covered (54.7%)

9.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/examples/example5/example5.go
1
package example5 // Package example5 我试试把注释写到这里行不行
2

3
import (
4
        "time"
5

6
        "github.com/yyle88/gormcnm"
7
)
8

9
type Person struct {
10
        ID        int32  `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
11
        Name      string `gorm:"not null,type:text"`
12
        BirthDate string
13
        Gender    bool
14
        CreatedAt time.Time `gorm:"autoCreateTime"`
15
        UpdatedAt time.Time `gorm:"autoUpdateTime"`
16
}
17

NEW
18
func (one *Person) Columns() *personColumns {
×
NEW
19
        return &personColumns{
×
NEW
20
                ID:        gormcnm.Cnm(one.ID, "id"),
×
NEW
21
                Name:      gormcnm.Cnm(one.Name, "name"),
×
NEW
22
                BirthDate: gormcnm.Cnm(one.BirthDate, "birth_date"),
×
NEW
23
                Gender:    gormcnm.Cnm(one.Gender, "gender"),
×
NEW
24
                CreatedAt: gormcnm.Cnm(one.CreatedAt, "created_at"),
×
NEW
25
                UpdatedAt: gormcnm.Cnm(one.UpdatedAt, "updated_at"),
×
NEW
26
        }
×
NEW
27
}
×
28

29
type personColumns struct {
30
        // Embedding operation functions make it easy to use // 继承操作函数便于使用
31
        gormcnm.ColumnOperationClass
32
        // The column names and types of the model's columns // 模型各列的列名和类型
33
        ID        gormcnm.ColumnName[int32]
34
        Name      gormcnm.ColumnName[string]
35
        BirthDate gormcnm.ColumnName[string]
36
        Gender    gormcnm.ColumnName[bool]
37
        CreatedAt gormcnm.ColumnName[time.Time]
38
        UpdatedAt gormcnm.ColumnName[time.Time]
39
}
40

41
type Example struct {
42
        ID        int32     `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
43
        Name      string    `gorm:"not null,type:text"`
44
        CreatedAt time.Time `gorm:"autoCreateTime"`
45
        UpdatedAt time.Time `gorm:"autoUpdateTime"`
46
}
47

NEW
48
func (one *Example) Columns() *exampleColumns {
×
NEW
49
        return &exampleColumns{
×
NEW
50
                ID:        gormcnm.Cnm(one.ID, "id"),
×
NEW
51
                Name:      gormcnm.Cnm(one.Name, "name"),
×
NEW
52
                CreatedAt: gormcnm.Cnm(one.CreatedAt, "created_at"),
×
NEW
53
                UpdatedAt: gormcnm.Cnm(one.UpdatedAt, "updated_at"),
×
NEW
54
        }
×
NEW
55
}
×
56

57
type exampleColumns struct {
58
        // Embedding operation functions make it easy to use // 继承操作函数便于使用
59
        gormcnm.ColumnOperationClass
60
        // The column names and types of the model's columns // 模型各列的列名和类型
61
        ID        gormcnm.ColumnName[int32]
62
        Name      gormcnm.ColumnName[string]
63
        CreatedAt gormcnm.ColumnName[time.Time]
64
        UpdatedAt gormcnm.ColumnName[time.Time]
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc