mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat(wip): site category
This commit is contained in:
parent
ed3c02fc6f
commit
7ad5cac3b8
73 changed files with 713 additions and 235 deletions
|
@ -28,7 +28,7 @@ func newAcmeUser(db *gorm.DB, opts ...gen.DOOption) acmeUser {
|
|||
|
||||
tableName := _acmeUser.acmeUserDo.TableName()
|
||||
_acmeUser.ALL = field.NewAsterisk(tableName)
|
||||
_acmeUser.ID = field.NewInt(tableName, "id")
|
||||
_acmeUser.ID = field.NewUint64(tableName, "id")
|
||||
_acmeUser.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_acmeUser.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_acmeUser.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -49,7 +49,7 @@ type acmeUser struct {
|
|||
acmeUserDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -76,7 +76,7 @@ func (a acmeUser) As(alias string) *acmeUser {
|
|||
|
||||
func (a *acmeUser) updateTableName(table string) *acmeUser {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt(table, "id")
|
||||
a.ID = field.NewUint64(table, "id")
|
||||
a.CreatedAt = field.NewTime(table, "created_at")
|
||||
a.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
a.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -130,7 +130,7 @@ func (a acmeUser) replaceDB(db *gorm.DB) acmeUser {
|
|||
type acmeUserDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (a acmeUserDo) FirstByID(id int) (result *model.AcmeUser, err error) {
|
||||
func (a acmeUserDo) FirstByID(id uint64) (result *model.AcmeUser, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -145,7 +145,7 @@ func (a acmeUserDo) FirstByID(id int) (result *model.AcmeUser, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (a acmeUserDo) DeleteByID(id int) (err error) {
|
||||
func (a acmeUserDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newAuthToken(db *gorm.DB, opts ...gen.DOOption) authToken {
|
|||
|
||||
tableName := _authToken.authTokenDo.TableName()
|
||||
_authToken.ALL = field.NewAsterisk(tableName)
|
||||
_authToken.UserID = field.NewInt(tableName, "user_id")
|
||||
_authToken.UserID = field.NewUint64(tableName, "user_id")
|
||||
_authToken.Token = field.NewString(tableName, "token")
|
||||
_authToken.ExpiredAt = field.NewInt64(tableName, "expired_at")
|
||||
|
||||
|
@ -41,7 +41,7 @@ type authToken struct {
|
|||
authTokenDo
|
||||
|
||||
ALL field.Asterisk
|
||||
UserID field.Int
|
||||
UserID field.Uint64
|
||||
Token field.String
|
||||
ExpiredAt field.Int64
|
||||
|
||||
|
@ -60,7 +60,7 @@ func (a authToken) As(alias string) *authToken {
|
|||
|
||||
func (a *authToken) updateTableName(table string) *authToken {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.UserID = field.NewInt(table, "user_id")
|
||||
a.UserID = field.NewUint64(table, "user_id")
|
||||
a.Token = field.NewString(table, "token")
|
||||
a.ExpiredAt = field.NewInt64(table, "expired_at")
|
||||
|
||||
|
@ -98,7 +98,7 @@ func (a authToken) replaceDB(db *gorm.DB) authToken {
|
|||
type authTokenDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (a authTokenDo) FirstByID(id int) (result *model.AuthToken, err error) {
|
||||
func (a authTokenDo) FirstByID(id uint64) (result *model.AuthToken, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -113,7 +113,7 @@ func (a authTokenDo) FirstByID(id int) (result *model.AuthToken, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (a authTokenDo) DeleteByID(id int) (err error) {
|
||||
func (a authTokenDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
|||
|
||||
tableName := _user.userDo.TableName()
|
||||
_user.ALL = field.NewAsterisk(tableName)
|
||||
_user.ID = field.NewInt(tableName, "id")
|
||||
_user.ID = field.NewUint64(tableName, "id")
|
||||
_user.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_user.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_user.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -46,7 +46,7 @@ type user struct {
|
|||
userDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -70,7 +70,7 @@ func (u user) As(alias string) *user {
|
|||
|
||||
func (u *user) updateTableName(table string) *user {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewInt(table, "id")
|
||||
u.ID = field.NewUint64(table, "id")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -118,7 +118,7 @@ func (u user) replaceDB(db *gorm.DB) user {
|
|||
type userDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (u userDo) FirstByID(id int) (result *model.User, err error) {
|
||||
func (u userDo) FirstByID(id uint64) (result *model.User, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -133,7 +133,7 @@ func (u userDo) FirstByID(id int) (result *model.User, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (u userDo) DeleteByID(id int) (err error) {
|
||||
func (u userDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -98,7 +98,7 @@ func (b banIP) replaceDB(db *gorm.DB) banIP {
|
|||
type banIPDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (b banIPDo) FirstByID(id int) (result *model.BanIP, err error) {
|
||||
func (b banIPDo) FirstByID(id uint64) (result *model.BanIP, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -113,7 +113,7 @@ func (b banIPDo) FirstByID(id int) (result *model.BanIP, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (b banIPDo) DeleteByID(id int) (err error) {
|
||||
func (b banIPDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newCert(db *gorm.DB, opts ...gen.DOOption) cert {
|
|||
|
||||
tableName := _cert.certDo.TableName()
|
||||
_cert.ALL = field.NewAsterisk(tableName)
|
||||
_cert.ID = field.NewInt(tableName, "id")
|
||||
_cert.ID = field.NewUint64(tableName, "id")
|
||||
_cert.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_cert.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_cert.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -39,8 +39,8 @@ func newCert(db *gorm.DB, opts ...gen.DOOption) cert {
|
|||
_cert.SSLCertificateKeyPath = field.NewString(tableName, "ssl_certificate_key_path")
|
||||
_cert.AutoCert = field.NewInt(tableName, "auto_cert")
|
||||
_cert.ChallengeMethod = field.NewString(tableName, "challenge_method")
|
||||
_cert.DnsCredentialID = field.NewInt(tableName, "dns_credential_id")
|
||||
_cert.ACMEUserID = field.NewInt(tableName, "acme_user_id")
|
||||
_cert.DnsCredentialID = field.NewUint64(tableName, "dns_credential_id")
|
||||
_cert.ACMEUserID = field.NewUint64(tableName, "acme_user_id")
|
||||
_cert.KeyType = field.NewString(tableName, "key_type")
|
||||
_cert.Log = field.NewString(tableName, "log")
|
||||
_cert.Resource = field.NewField(tableName, "resource")
|
||||
|
@ -68,7 +68,7 @@ type cert struct {
|
|||
certDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -79,8 +79,8 @@ type cert struct {
|
|||
SSLCertificateKeyPath field.String
|
||||
AutoCert field.Int
|
||||
ChallengeMethod field.String
|
||||
DnsCredentialID field.Int
|
||||
ACMEUserID field.Int
|
||||
DnsCredentialID field.Uint64
|
||||
ACMEUserID field.Uint64
|
||||
KeyType field.String
|
||||
Log field.String
|
||||
Resource field.Field
|
||||
|
@ -106,7 +106,7 @@ func (c cert) As(alias string) *cert {
|
|||
|
||||
func (c *cert) updateTableName(table string) *cert {
|
||||
c.ALL = field.NewAsterisk(table)
|
||||
c.ID = field.NewInt(table, "id")
|
||||
c.ID = field.NewUint64(table, "id")
|
||||
c.CreatedAt = field.NewTime(table, "created_at")
|
||||
c.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
c.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -117,8 +117,8 @@ func (c *cert) updateTableName(table string) *cert {
|
|||
c.SSLCertificateKeyPath = field.NewString(table, "ssl_certificate_key_path")
|
||||
c.AutoCert = field.NewInt(table, "auto_cert")
|
||||
c.ChallengeMethod = field.NewString(table, "challenge_method")
|
||||
c.DnsCredentialID = field.NewInt(table, "dns_credential_id")
|
||||
c.ACMEUserID = field.NewInt(table, "acme_user_id")
|
||||
c.DnsCredentialID = field.NewUint64(table, "dns_credential_id")
|
||||
c.ACMEUserID = field.NewUint64(table, "acme_user_id")
|
||||
c.KeyType = field.NewString(table, "key_type")
|
||||
c.Log = field.NewString(table, "log")
|
||||
c.Resource = field.NewField(table, "resource")
|
||||
|
@ -319,7 +319,7 @@ func (a certBelongsToACMEUserTx) Count() int64 {
|
|||
type certDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (c certDo) FirstByID(id int) (result *model.Cert, err error) {
|
||||
func (c certDo) FirstByID(id uint64) (result *model.Cert, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -334,7 +334,7 @@ func (c certDo) FirstByID(id int) (result *model.Cert, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (c certDo) DeleteByID(id int) (err error) {
|
||||
func (c certDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -94,7 +94,7 @@ func (c chatGPTLog) replaceDB(db *gorm.DB) chatGPTLog {
|
|||
type chatGPTLogDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (c chatGPTLogDo) FirstByID(id int) (result *model.ChatGPTLog, err error) {
|
||||
func (c chatGPTLogDo) FirstByID(id uint64) (result *model.ChatGPTLog, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -109,7 +109,7 @@ func (c chatGPTLogDo) FirstByID(id int) (result *model.ChatGPTLog, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (c chatGPTLogDo) DeleteByID(id int) (err error) {
|
||||
func (c chatGPTLogDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newConfigBackup(db *gorm.DB, opts ...gen.DOOption) configBackup {
|
|||
|
||||
tableName := _configBackup.configBackupDo.TableName()
|
||||
_configBackup.ALL = field.NewAsterisk(tableName)
|
||||
_configBackup.ID = field.NewInt(tableName, "id")
|
||||
_configBackup.ID = field.NewUint64(tableName, "id")
|
||||
_configBackup.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_configBackup.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_configBackup.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -45,7 +45,7 @@ type configBackup struct {
|
|||
configBackupDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -68,7 +68,7 @@ func (c configBackup) As(alias string) *configBackup {
|
|||
|
||||
func (c *configBackup) updateTableName(table string) *configBackup {
|
||||
c.ALL = field.NewAsterisk(table)
|
||||
c.ID = field.NewInt(table, "id")
|
||||
c.ID = field.NewUint64(table, "id")
|
||||
c.CreatedAt = field.NewTime(table, "created_at")
|
||||
c.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
c.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -114,7 +114,7 @@ func (c configBackup) replaceDB(db *gorm.DB) configBackup {
|
|||
type configBackupDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (c configBackupDo) FirstByID(id int) (result *model.ConfigBackup, err error) {
|
||||
func (c configBackupDo) FirstByID(id uint64) (result *model.ConfigBackup, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -129,7 +129,7 @@ func (c configBackupDo) FirstByID(id int) (result *model.ConfigBackup, err error
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (c configBackupDo) DeleteByID(id int) (err error) {
|
||||
func (c configBackupDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newConfig(db *gorm.DB, opts ...gen.DOOption) config {
|
|||
|
||||
tableName := _config.configDo.TableName()
|
||||
_config.ALL = field.NewAsterisk(tableName)
|
||||
_config.ID = field.NewInt(tableName, "id")
|
||||
_config.ID = field.NewUint64(tableName, "id")
|
||||
_config.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_config.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_config.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -46,7 +46,7 @@ type config struct {
|
|||
configDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -70,7 +70,7 @@ func (c config) As(alias string) *config {
|
|||
|
||||
func (c *config) updateTableName(table string) *config {
|
||||
c.ALL = field.NewAsterisk(table)
|
||||
c.ID = field.NewInt(table, "id")
|
||||
c.ID = field.NewUint64(table, "id")
|
||||
c.CreatedAt = field.NewTime(table, "created_at")
|
||||
c.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
c.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -118,7 +118,7 @@ func (c config) replaceDB(db *gorm.DB) config {
|
|||
type configDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (c configDo) FirstByID(id int) (result *model.Config, err error) {
|
||||
func (c configDo) FirstByID(id uint64) (result *model.Config, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -133,7 +133,7 @@ func (c configDo) FirstByID(id int) (result *model.Config, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (c configDo) DeleteByID(id int) (err error) {
|
||||
func (c configDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newDnsCredential(db *gorm.DB, opts ...gen.DOOption) dnsCredential {
|
|||
|
||||
tableName := _dnsCredential.dnsCredentialDo.TableName()
|
||||
_dnsCredential.ALL = field.NewAsterisk(tableName)
|
||||
_dnsCredential.ID = field.NewInt(tableName, "id")
|
||||
_dnsCredential.ID = field.NewUint64(tableName, "id")
|
||||
_dnsCredential.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_dnsCredential.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_dnsCredential.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -45,7 +45,7 @@ type dnsCredential struct {
|
|||
dnsCredentialDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -68,7 +68,7 @@ func (d dnsCredential) As(alias string) *dnsCredential {
|
|||
|
||||
func (d *dnsCredential) updateTableName(table string) *dnsCredential {
|
||||
d.ALL = field.NewAsterisk(table)
|
||||
d.ID = field.NewInt(table, "id")
|
||||
d.ID = field.NewUint64(table, "id")
|
||||
d.CreatedAt = field.NewTime(table, "created_at")
|
||||
d.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
d.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -114,7 +114,7 @@ func (d dnsCredential) replaceDB(db *gorm.DB) dnsCredential {
|
|||
type dnsCredentialDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (d dnsCredentialDo) FirstByID(id int) (result *model.DnsCredential, err error) {
|
||||
func (d dnsCredentialDo) FirstByID(id uint64) (result *model.DnsCredential, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -129,7 +129,7 @@ func (d dnsCredentialDo) FirstByID(id int) (result *model.DnsCredential, err err
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (d dnsCredentialDo) DeleteByID(id int) (err error) {
|
||||
func (d dnsCredentialDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newEnvironment(db *gorm.DB, opts ...gen.DOOption) environment {
|
|||
|
||||
tableName := _environment.environmentDo.TableName()
|
||||
_environment.ALL = field.NewAsterisk(tableName)
|
||||
_environment.ID = field.NewInt(tableName, "id")
|
||||
_environment.ID = field.NewUint64(tableName, "id")
|
||||
_environment.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_environment.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_environment.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -36,8 +36,6 @@ func newEnvironment(db *gorm.DB, opts ...gen.DOOption) environment {
|
|||
_environment.URL = field.NewString(tableName, "url")
|
||||
_environment.Token = field.NewString(tableName, "token")
|
||||
_environment.Enabled = field.NewBool(tableName, "enabled")
|
||||
_environment.OperationSync = field.NewBool(tableName, "operation_sync")
|
||||
_environment.SyncApiRegex = field.NewString(tableName, "sync_api_regex")
|
||||
|
||||
_environment.fillFieldMap()
|
||||
|
||||
|
@ -47,17 +45,15 @@ func newEnvironment(db *gorm.DB, opts ...gen.DOOption) environment {
|
|||
type environment struct {
|
||||
environmentDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
Name field.String
|
||||
URL field.String
|
||||
Token field.String
|
||||
Enabled field.Bool
|
||||
OperationSync field.Bool
|
||||
SyncApiRegex field.String
|
||||
ALL field.Asterisk
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
Name field.String
|
||||
URL field.String
|
||||
Token field.String
|
||||
Enabled field.Bool
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
@ -74,7 +70,7 @@ func (e environment) As(alias string) *environment {
|
|||
|
||||
func (e *environment) updateTableName(table string) *environment {
|
||||
e.ALL = field.NewAsterisk(table)
|
||||
e.ID = field.NewInt(table, "id")
|
||||
e.ID = field.NewUint64(table, "id")
|
||||
e.CreatedAt = field.NewTime(table, "created_at")
|
||||
e.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
e.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -82,8 +78,6 @@ func (e *environment) updateTableName(table string) *environment {
|
|||
e.URL = field.NewString(table, "url")
|
||||
e.Token = field.NewString(table, "token")
|
||||
e.Enabled = field.NewBool(table, "enabled")
|
||||
e.OperationSync = field.NewBool(table, "operation_sync")
|
||||
e.SyncApiRegex = field.NewString(table, "sync_api_regex")
|
||||
|
||||
e.fillFieldMap()
|
||||
|
||||
|
@ -100,7 +94,7 @@ func (e *environment) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|||
}
|
||||
|
||||
func (e *environment) fillFieldMap() {
|
||||
e.fieldMap = make(map[string]field.Expr, 10)
|
||||
e.fieldMap = make(map[string]field.Expr, 8)
|
||||
e.fieldMap["id"] = e.ID
|
||||
e.fieldMap["created_at"] = e.CreatedAt
|
||||
e.fieldMap["updated_at"] = e.UpdatedAt
|
||||
|
@ -109,8 +103,6 @@ func (e *environment) fillFieldMap() {
|
|||
e.fieldMap["url"] = e.URL
|
||||
e.fieldMap["token"] = e.Token
|
||||
e.fieldMap["enabled"] = e.Enabled
|
||||
e.fieldMap["operation_sync"] = e.OperationSync
|
||||
e.fieldMap["sync_api_regex"] = e.SyncApiRegex
|
||||
}
|
||||
|
||||
func (e environment) clone(db *gorm.DB) environment {
|
||||
|
@ -126,7 +118,7 @@ func (e environment) replaceDB(db *gorm.DB) environment {
|
|||
type environmentDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (e environmentDo) FirstByID(id int) (result *model.Environment, err error) {
|
||||
func (e environmentDo) FirstByID(id uint64) (result *model.Environment, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -141,7 +133,7 @@ func (e environmentDo) FirstByID(id int) (result *model.Environment, err error)
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (e environmentDo) DeleteByID(id int) (err error) {
|
||||
func (e environmentDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -29,6 +29,7 @@ var (
|
|||
Notification *notification
|
||||
Passkey *passkey
|
||||
Site *site
|
||||
SiteCategory *siteCategory
|
||||
Stream *stream
|
||||
User *user
|
||||
)
|
||||
|
@ -47,6 +48,7 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
|||
Notification = &Q.Notification
|
||||
Passkey = &Q.Passkey
|
||||
Site = &Q.Site
|
||||
SiteCategory = &Q.SiteCategory
|
||||
Stream = &Q.Stream
|
||||
User = &Q.User
|
||||
}
|
||||
|
@ -66,6 +68,7 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
|||
Notification: newNotification(db, opts...),
|
||||
Passkey: newPasskey(db, opts...),
|
||||
Site: newSite(db, opts...),
|
||||
SiteCategory: newSiteCategory(db, opts...),
|
||||
Stream: newStream(db, opts...),
|
||||
User: newUser(db, opts...),
|
||||
}
|
||||
|
@ -86,6 +89,7 @@ type Query struct {
|
|||
Notification notification
|
||||
Passkey passkey
|
||||
Site site
|
||||
SiteCategory siteCategory
|
||||
Stream stream
|
||||
User user
|
||||
}
|
||||
|
@ -107,6 +111,7 @@ func (q *Query) clone(db *gorm.DB) *Query {
|
|||
Notification: q.Notification.clone(db),
|
||||
Passkey: q.Passkey.clone(db),
|
||||
Site: q.Site.clone(db),
|
||||
SiteCategory: q.SiteCategory.clone(db),
|
||||
Stream: q.Stream.clone(db),
|
||||
User: q.User.clone(db),
|
||||
}
|
||||
|
@ -135,6 +140,7 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
|||
Notification: q.Notification.replaceDB(db),
|
||||
Passkey: q.Passkey.replaceDB(db),
|
||||
Site: q.Site.replaceDB(db),
|
||||
SiteCategory: q.SiteCategory.replaceDB(db),
|
||||
Stream: q.Stream.replaceDB(db),
|
||||
User: q.User.replaceDB(db),
|
||||
}
|
||||
|
@ -153,6 +159,7 @@ type queryCtx struct {
|
|||
Notification *notificationDo
|
||||
Passkey *passkeyDo
|
||||
Site *siteDo
|
||||
SiteCategory *siteCategoryDo
|
||||
Stream *streamDo
|
||||
User *userDo
|
||||
}
|
||||
|
@ -171,6 +178,7 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
|||
Notification: q.Notification.WithContext(ctx),
|
||||
Passkey: q.Passkey.WithContext(ctx),
|
||||
Site: q.Site.WithContext(ctx),
|
||||
SiteCategory: q.SiteCategory.WithContext(ctx),
|
||||
Stream: q.Stream.WithContext(ctx),
|
||||
User: q.User.WithContext(ctx),
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ func newNotification(db *gorm.DB, opts ...gen.DOOption) notification {
|
|||
|
||||
tableName := _notification.notificationDo.TableName()
|
||||
_notification.ALL = field.NewAsterisk(tableName)
|
||||
_notification.ID = field.NewInt(tableName, "id")
|
||||
_notification.ID = field.NewUint64(tableName, "id")
|
||||
_notification.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_notification.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_notification.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -45,7 +45,7 @@ type notification struct {
|
|||
notificationDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -68,7 +68,7 @@ func (n notification) As(alias string) *notification {
|
|||
|
||||
func (n *notification) updateTableName(table string) *notification {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.ID = field.NewInt(table, "id")
|
||||
n.ID = field.NewUint64(table, "id")
|
||||
n.CreatedAt = field.NewTime(table, "created_at")
|
||||
n.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
n.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -114,7 +114,7 @@ func (n notification) replaceDB(db *gorm.DB) notification {
|
|||
type notificationDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (n notificationDo) FirstByID(id int) (result *model.Notification, err error) {
|
||||
func (n notificationDo) FirstByID(id uint64) (result *model.Notification, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -129,7 +129,7 @@ func (n notificationDo) FirstByID(id int) (result *model.Notification, err error
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (n notificationDo) DeleteByID(id int) (err error) {
|
||||
func (n notificationDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,12 +28,12 @@ func newPasskey(db *gorm.DB, opts ...gen.DOOption) passkey {
|
|||
|
||||
tableName := _passkey.passkeyDo.TableName()
|
||||
_passkey.ALL = field.NewAsterisk(tableName)
|
||||
_passkey.ID = field.NewInt(tableName, "id")
|
||||
_passkey.ID = field.NewUint64(tableName, "id")
|
||||
_passkey.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_passkey.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_passkey.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_passkey.Name = field.NewString(tableName, "name")
|
||||
_passkey.UserID = field.NewInt(tableName, "user_id")
|
||||
_passkey.UserID = field.NewUint64(tableName, "user_id")
|
||||
_passkey.RawID = field.NewString(tableName, "raw_id")
|
||||
_passkey.Credential = field.NewField(tableName, "credential")
|
||||
_passkey.LastUsedAt = field.NewInt64(tableName, "last_used_at")
|
||||
|
@ -47,12 +47,12 @@ type passkey struct {
|
|||
passkeyDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
Name field.String
|
||||
UserID field.Int
|
||||
UserID field.Uint64
|
||||
RawID field.String
|
||||
Credential field.Field
|
||||
LastUsedAt field.Int64
|
||||
|
@ -72,12 +72,12 @@ func (p passkey) As(alias string) *passkey {
|
|||
|
||||
func (p *passkey) updateTableName(table string) *passkey {
|
||||
p.ALL = field.NewAsterisk(table)
|
||||
p.ID = field.NewInt(table, "id")
|
||||
p.ID = field.NewUint64(table, "id")
|
||||
p.CreatedAt = field.NewTime(table, "created_at")
|
||||
p.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
p.DeletedAt = field.NewField(table, "deleted_at")
|
||||
p.Name = field.NewString(table, "name")
|
||||
p.UserID = field.NewInt(table, "user_id")
|
||||
p.UserID = field.NewUint64(table, "user_id")
|
||||
p.RawID = field.NewString(table, "raw_id")
|
||||
p.Credential = field.NewField(table, "credential")
|
||||
p.LastUsedAt = field.NewInt64(table, "last_used_at")
|
||||
|
@ -122,7 +122,7 @@ func (p passkey) replaceDB(db *gorm.DB) passkey {
|
|||
type passkeyDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (p passkeyDo) FirstByID(id int) (result *model.Passkey, err error) {
|
||||
func (p passkeyDo) FirstByID(id uint64) (result *model.Passkey, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -137,7 +137,7 @@ func (p passkeyDo) FirstByID(id int) (result *model.Passkey, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (p passkeyDo) DeleteByID(id int) (err error) {
|
||||
func (p passkeyDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
370
query/site_categories.gen.go
Normal file
370
query/site_categories.gen.go
Normal file
|
@ -0,0 +1,370 @@
|
|||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
)
|
||||
|
||||
func newSiteCategory(db *gorm.DB, opts ...gen.DOOption) siteCategory {
|
||||
_siteCategory := siteCategory{}
|
||||
|
||||
_siteCategory.siteCategoryDo.UseDB(db, opts...)
|
||||
_siteCategory.siteCategoryDo.UseModel(&model.SiteCategory{})
|
||||
|
||||
tableName := _siteCategory.siteCategoryDo.TableName()
|
||||
_siteCategory.ALL = field.NewAsterisk(tableName)
|
||||
_siteCategory.ID = field.NewUint64(tableName, "id")
|
||||
_siteCategory.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_siteCategory.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_siteCategory.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_siteCategory.Name = field.NewString(tableName, "name")
|
||||
_siteCategory.SyncNodeIds = field.NewField(tableName, "sync_node_ids")
|
||||
|
||||
_siteCategory.fillFieldMap()
|
||||
|
||||
return _siteCategory
|
||||
}
|
||||
|
||||
type siteCategory struct {
|
||||
siteCategoryDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
Name field.String
|
||||
SyncNodeIds field.Field
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (s siteCategory) Table(newTableName string) *siteCategory {
|
||||
s.siteCategoryDo.UseTable(newTableName)
|
||||
return s.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (s siteCategory) As(alias string) *siteCategory {
|
||||
s.siteCategoryDo.DO = *(s.siteCategoryDo.As(alias).(*gen.DO))
|
||||
return s.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (s *siteCategory) updateTableName(table string) *siteCategory {
|
||||
s.ALL = field.NewAsterisk(table)
|
||||
s.ID = field.NewUint64(table, "id")
|
||||
s.CreatedAt = field.NewTime(table, "created_at")
|
||||
s.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
s.DeletedAt = field.NewField(table, "deleted_at")
|
||||
s.Name = field.NewString(table, "name")
|
||||
s.SyncNodeIds = field.NewField(table, "sync_node_ids")
|
||||
|
||||
s.fillFieldMap()
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *siteCategory) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := s.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (s *siteCategory) fillFieldMap() {
|
||||
s.fieldMap = make(map[string]field.Expr, 6)
|
||||
s.fieldMap["id"] = s.ID
|
||||
s.fieldMap["created_at"] = s.CreatedAt
|
||||
s.fieldMap["updated_at"] = s.UpdatedAt
|
||||
s.fieldMap["deleted_at"] = s.DeletedAt
|
||||
s.fieldMap["name"] = s.Name
|
||||
s.fieldMap["sync_node_ids"] = s.SyncNodeIds
|
||||
}
|
||||
|
||||
func (s siteCategory) clone(db *gorm.DB) siteCategory {
|
||||
s.siteCategoryDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s siteCategory) replaceDB(db *gorm.DB) siteCategory {
|
||||
s.siteCategoryDo.ReplaceDB(db)
|
||||
return s
|
||||
}
|
||||
|
||||
type siteCategoryDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (s siteCategoryDo) FirstByID(id uint64) (result *model.SiteCategory, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
params = append(params, id)
|
||||
generateSQL.WriteString("id=? ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = s.UnderlyingDB().Where(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
||||
err = executeSQL.Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (s siteCategoryDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
params = append(params, id)
|
||||
generateSQL.WriteString("update site_categories set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=? ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = s.UnderlyingDB().Exec(generateSQL.String(), params...) // ignore_security_alert
|
||||
err = executeSQL.Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Debug() *siteCategoryDo {
|
||||
return s.withDO(s.DO.Debug())
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) WithContext(ctx context.Context) *siteCategoryDo {
|
||||
return s.withDO(s.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) ReadDB() *siteCategoryDo {
|
||||
return s.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) WriteDB() *siteCategoryDo {
|
||||
return s.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Session(config *gorm.Session) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Session(config))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Clauses(conds ...clause.Expression) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Returning(value interface{}, columns ...string) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Not(conds ...gen.Condition) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Or(conds ...gen.Condition) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Select(conds ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Where(conds ...gen.Condition) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Order(conds ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Distinct(cols ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Omit(cols ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Join(table schema.Tabler, on ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) LeftJoin(table schema.Tabler, on ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) RightJoin(table schema.Tabler, on ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Group(cols ...field.Expr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Having(conds ...gen.Condition) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Limit(limit int) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Offset(offset int) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Unscoped() *siteCategoryDo {
|
||||
return s.withDO(s.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Create(values ...*model.SiteCategory) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.DO.Create(values)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) CreateInBatches(values []*model.SiteCategory, batchSize int) error {
|
||||
return s.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (s siteCategoryDo) Save(values ...*model.SiteCategory) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.DO.Save(values)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) First() (*model.SiteCategory, error) {
|
||||
if result, err := s.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SiteCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Take() (*model.SiteCategory, error) {
|
||||
if result, err := s.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SiteCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Last() (*model.SiteCategory, error) {
|
||||
if result, err := s.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SiteCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Find() ([]*model.SiteCategory, error) {
|
||||
result, err := s.DO.Find()
|
||||
return result.([]*model.SiteCategory), err
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SiteCategory, err error) {
|
||||
buf := make([]*model.SiteCategory, 0, batchSize)
|
||||
err = s.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) FindInBatches(result *[]*model.SiteCategory, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return s.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Attrs(attrs ...field.AssignExpr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Assign(attrs ...field.AssignExpr) *siteCategoryDo {
|
||||
return s.withDO(s.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Joins(fields ...field.RelationField) *siteCategoryDo {
|
||||
for _, _f := range fields {
|
||||
s = *s.withDO(s.DO.Joins(_f))
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Preload(fields ...field.RelationField) *siteCategoryDo {
|
||||
for _, _f := range fields {
|
||||
s = *s.withDO(s.DO.Preload(_f))
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) FirstOrInit() (*model.SiteCategory, error) {
|
||||
if result, err := s.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SiteCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) FirstOrCreate() (*model.SiteCategory, error) {
|
||||
if result, err := s.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SiteCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) FindByPage(offset int, limit int) (result []*model.SiteCategory, count int64, err error) {
|
||||
result, err = s.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = s.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = s.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = s.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Scan(result interface{}) (err error) {
|
||||
return s.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (s siteCategoryDo) Delete(models ...*model.SiteCategory) (result gen.ResultInfo, err error) {
|
||||
return s.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (s *siteCategoryDo) withDO(do gen.Dao) *siteCategoryDo {
|
||||
s.DO = *do.(*gen.DO)
|
||||
return s
|
||||
}
|
|
@ -28,7 +28,7 @@ func newSite(db *gorm.DB, opts ...gen.DOOption) site {
|
|||
|
||||
tableName := _site.siteDo.TableName()
|
||||
_site.ALL = field.NewAsterisk(tableName)
|
||||
_site.ID = field.NewInt(tableName, "id")
|
||||
_site.ID = field.NewUint64(tableName, "id")
|
||||
_site.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_site.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_site.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -44,7 +44,7 @@ type site struct {
|
|||
siteDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -66,7 +66,7 @@ func (s site) As(alias string) *site {
|
|||
|
||||
func (s *site) updateTableName(table string) *site {
|
||||
s.ALL = field.NewAsterisk(table)
|
||||
s.ID = field.NewInt(table, "id")
|
||||
s.ID = field.NewUint64(table, "id")
|
||||
s.CreatedAt = field.NewTime(table, "created_at")
|
||||
s.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
s.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -110,7 +110,7 @@ func (s site) replaceDB(db *gorm.DB) site {
|
|||
type siteDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (s siteDo) FirstByID(id int) (result *model.Site, err error) {
|
||||
func (s siteDo) FirstByID(id uint64) (result *model.Site, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -125,7 +125,7 @@ func (s siteDo) FirstByID(id int) (result *model.Site, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (s siteDo) DeleteByID(id int) (err error) {
|
||||
func (s siteDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
|
@ -28,7 +28,7 @@ func newStream(db *gorm.DB, opts ...gen.DOOption) stream {
|
|||
|
||||
tableName := _stream.streamDo.TableName()
|
||||
_stream.ALL = field.NewAsterisk(tableName)
|
||||
_stream.ID = field.NewInt(tableName, "id")
|
||||
_stream.ID = field.NewUint64(tableName, "id")
|
||||
_stream.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_stream.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_stream.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
@ -44,7 +44,7 @@ type stream struct {
|
|||
streamDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
@ -66,7 +66,7 @@ func (s stream) As(alias string) *stream {
|
|||
|
||||
func (s *stream) updateTableName(table string) *stream {
|
||||
s.ALL = field.NewAsterisk(table)
|
||||
s.ID = field.NewInt(table, "id")
|
||||
s.ID = field.NewUint64(table, "id")
|
||||
s.CreatedAt = field.NewTime(table, "created_at")
|
||||
s.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
s.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
@ -110,7 +110,7 @@ func (s stream) replaceDB(db *gorm.DB) stream {
|
|||
type streamDo struct{ gen.DO }
|
||||
|
||||
// FirstByID Where("id=@id")
|
||||
func (s streamDo) FirstByID(id int) (result *model.Stream, err error) {
|
||||
func (s streamDo) FirstByID(id uint64) (result *model.Stream, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
@ -125,7 +125,7 @@ func (s streamDo) FirstByID(id int) (result *model.Stream, err error) {
|
|||
}
|
||||
|
||||
// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
||||
func (s streamDo) DeleteByID(id int) (err error) {
|
||||
func (s streamDo) DeleteByID(id uint64) (err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue