-
Notifications
You must be signed in to change notification settings - Fork 0
/
statement.go
77 lines (63 loc) · 1.63 KB
/
statement.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package eorm
// 条件组装 用户API层
type Statement struct {
clause *Clause
}
func NewStatement() *Statement {
return &Statement{
clause: newClause(),
}
}
// SetTableName 设置表名
func (s *Statement) SetTableName(tableName string) *Statement {
s.clause.tablename = tableName
return s
}
// 新增数据API
func (s *Statement) InsertStruct(vars interface{}) *Statement {
s.clause.insertStruct(vars)
return s
}
// 修改数据API
func (s *Statement) UpdateStruct(vars interface{}) *Statement {
s.clause.updateStruct(vars)
return s
}
// where条件
func (s *Statement) AndEqual(field string, value interface{}) *Statement {
s.clause.andEqual(field, value)
return s
}
func (s *Statement) AndGreaterThan(field string, value interface{}) *Statement {
s.clause.andGreaterThan(field, value)
return s
}
func (s *Statement) AndLessThan(field string, value interface{}) *Statement {
s.clause.andLessThan(field, value)
return s
}
func (s *Statement) AndLike(field string, value interface{}) *Statement {
s.clause.andLike(field, value)
return s
}
func (s *Statement) OrEqual(field string, value interface{}) *Statement {
s.clause.orEqual(field, value)
return s
}
func (s *Statement) OrGreaterThan(field string, value interface{}) *Statement {
s.clause.orGreaterThan(field, value)
return s
}
func (s *Statement) OrLessThan(field string, value interface{}) *Statement {
s.clause.orLessThan(field, value)
return s
}
func (s *Statement) OrLike(field string, value interface{}) *Statement {
s.clause.orLike(field, value)
return s
}
// Select
func (s *Statement) Select(field ...string) *Statement {
s.clause.selectField(field...)
return s
}