-
Notifications
You must be signed in to change notification settings - Fork 1
/
userpassword.go
215 lines (187 loc) · 6.62 KB
/
userpassword.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
// Code generated by ent, DO NOT EDIT.
package userpassword
import (
"fmt"
"io"
"strconv"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/99designs/gqlgen/graphql"
"github.com/woocoos/knockout-go/ent/schemax/typex"
)
const (
// Label holds the string label denoting the userpassword type in the database.
Label = "user_password"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedBy holds the string denoting the created_by field in the database.
FieldCreatedBy = "created_by"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedBy holds the string denoting the updated_by field in the database.
FieldUpdatedBy = "updated_by"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldScene holds the string denoting the scene field in the database.
FieldScene = "scene"
// FieldPassword holds the string denoting the password field in the database.
FieldPassword = "password"
// FieldSalt holds the string denoting the salt field in the database.
FieldSalt = "salt"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// EdgeUser holds the string denoting the user edge name in mutations.
EdgeUser = "user"
// Table holds the table name of the userpassword in the database.
Table = "user_password"
// UserTable is the table that holds the user relation/edge.
UserTable = "user_password"
// UserInverseTable is the table name for the User entity.
// It exists in this package in order to avoid circular dependency with the "user" package.
UserInverseTable = "user"
// UserColumn is the table column denoting the user relation/edge.
UserColumn = "user_id"
)
// Columns holds all SQL columns for userpassword fields.
var Columns = []string{
FieldID,
FieldCreatedBy,
FieldCreatedAt,
FieldUpdatedBy,
FieldUpdatedAt,
FieldUserID,
FieldScene,
FieldPassword,
FieldSalt,
FieldStatus,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
// import _ "github.com/woocoos/knockout/ent/runtime"
var (
Hooks [2]ent.Hook
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// SaltValidator is a validator for the "salt" field. It is called by the builders before save.
SaltValidator func(string) error
)
// Scene defines the type for the "scene" enum field.
type Scene string
// Scene values.
const (
SceneLogin Scene = "login"
)
func (s Scene) String() string {
return string(s)
}
// SceneValidator is a validator for the "scene" field enum values. It is called by the builders before save.
func SceneValidator(s Scene) error {
switch s {
case SceneLogin:
return nil
default:
return fmt.Errorf("userpassword: invalid enum value for scene field: %q", s)
}
}
const DefaultStatus typex.SimpleStatus = "active"
// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
func StatusValidator(s typex.SimpleStatus) error {
switch s.String() {
case "active", "inactive", "processing", "disabled":
return nil
default:
return fmt.Errorf("userpassword: invalid enum value for status field: %q", s)
}
}
// OrderOption defines the ordering options for the UserPassword queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedBy orders the results by the created_by field.
func ByCreatedBy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedBy, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedBy orders the results by the updated_by field.
func ByUpdatedBy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedBy, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByScene orders the results by the scene field.
func ByScene(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldScene, opts...).ToFunc()
}
// ByPassword orders the results by the password field.
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPassword, opts...).ToFunc()
}
// BySalt orders the results by the salt field.
func BySalt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSalt, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByUserField orders the results by user field.
func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
}
}
func newUserStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(UserInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
)
}
// MarshalGQL implements graphql.Marshaler interface.
func (e Scene) MarshalGQL(w io.Writer) {
io.WriteString(w, strconv.Quote(e.String()))
}
// UnmarshalGQL implements graphql.Unmarshaler interface.
func (e *Scene) UnmarshalGQL(val interface{}) error {
str, ok := val.(string)
if !ok {
return fmt.Errorf("enum %T must be a string", val)
}
*e = Scene(str)
if err := SceneValidator(*e); err != nil {
return fmt.Errorf("%s is not a valid Scene", str)
}
return nil
}
var (
// typex.SimpleStatus must implement graphql.Marshaler.
_ graphql.Marshaler = (*typex.SimpleStatus)(nil)
// typex.SimpleStatus must implement graphql.Unmarshaler.
_ graphql.Unmarshaler = (*typex.SimpleStatus)(nil)
)