360 lines
9.7 KiB
Go
360 lines
9.7 KiB
Go
// 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 queries
|
||
|
||
import (
|
||
"context"
|
||
|
||
"gorm.io/gorm"
|
||
"gorm.io/gorm/clause"
|
||
"gorm.io/gorm/schema"
|
||
|
||
"gorm.io/gen"
|
||
"gorm.io/gen/field"
|
||
|
||
"gorm.io/plugin/dbresolver"
|
||
|
||
"platform/web/models"
|
||
)
|
||
|
||
func newLogsRequest(db *gorm.DB, opts ...gen.DOOption) logsRequest {
|
||
_logsRequest := logsRequest{}
|
||
|
||
_logsRequest.logsRequestDo.UseDB(db, opts...)
|
||
_logsRequest.logsRequestDo.UseModel(&models.LogsRequest{})
|
||
|
||
tableName := _logsRequest.logsRequestDo.TableName()
|
||
_logsRequest.ALL = field.NewAsterisk(tableName)
|
||
_logsRequest.ID = field.NewInt32(tableName, "id")
|
||
_logsRequest.Identity = field.NewInt32(tableName, "identity")
|
||
_logsRequest.Visitor = field.NewInt32(tableName, "visitor")
|
||
_logsRequest.IP = field.NewString(tableName, "ip")
|
||
_logsRequest.Ua = field.NewString(tableName, "ua")
|
||
_logsRequest.Method = field.NewString(tableName, "method")
|
||
_logsRequest.Path = field.NewString(tableName, "path")
|
||
_logsRequest.Latency = field.NewString(tableName, "latency")
|
||
_logsRequest.Status = field.NewInt32(tableName, "status")
|
||
_logsRequest.Error = field.NewString(tableName, "error")
|
||
_logsRequest.Time = field.NewField(tableName, "time")
|
||
|
||
_logsRequest.fillFieldMap()
|
||
|
||
return _logsRequest
|
||
}
|
||
|
||
type logsRequest struct {
|
||
logsRequestDo
|
||
|
||
ALL field.Asterisk
|
||
ID field.Int32 // 访问日志ID
|
||
Identity field.Int32 // 访客身份:0-游客,1-用户,2-服务,3-管理员
|
||
Visitor field.Int32 // 访客ID
|
||
IP field.String // IP地址
|
||
Ua field.String // 用户代理
|
||
Method field.String // 请求方法
|
||
Path field.String // 请求路径
|
||
Latency field.String // 请求延迟
|
||
Status field.Int32 // 响应状态码
|
||
Error field.String // 错误信息
|
||
Time field.Field // 请求时间
|
||
|
||
fieldMap map[string]field.Expr
|
||
}
|
||
|
||
func (l logsRequest) Table(newTableName string) *logsRequest {
|
||
l.logsRequestDo.UseTable(newTableName)
|
||
return l.updateTableName(newTableName)
|
||
}
|
||
|
||
func (l logsRequest) As(alias string) *logsRequest {
|
||
l.logsRequestDo.DO = *(l.logsRequestDo.As(alias).(*gen.DO))
|
||
return l.updateTableName(alias)
|
||
}
|
||
|
||
func (l *logsRequest) updateTableName(table string) *logsRequest {
|
||
l.ALL = field.NewAsterisk(table)
|
||
l.ID = field.NewInt32(table, "id")
|
||
l.Identity = field.NewInt32(table, "identity")
|
||
l.Visitor = field.NewInt32(table, "visitor")
|
||
l.IP = field.NewString(table, "ip")
|
||
l.Ua = field.NewString(table, "ua")
|
||
l.Method = field.NewString(table, "method")
|
||
l.Path = field.NewString(table, "path")
|
||
l.Latency = field.NewString(table, "latency")
|
||
l.Status = field.NewInt32(table, "status")
|
||
l.Error = field.NewString(table, "error")
|
||
l.Time = field.NewField(table, "time")
|
||
|
||
l.fillFieldMap()
|
||
|
||
return l
|
||
}
|
||
|
||
func (l *logsRequest) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||
_f, ok := l.fieldMap[fieldName]
|
||
if !ok || _f == nil {
|
||
return nil, false
|
||
}
|
||
_oe, ok := _f.(field.OrderExpr)
|
||
return _oe, ok
|
||
}
|
||
|
||
func (l *logsRequest) fillFieldMap() {
|
||
l.fieldMap = make(map[string]field.Expr, 11)
|
||
l.fieldMap["id"] = l.ID
|
||
l.fieldMap["identity"] = l.Identity
|
||
l.fieldMap["visitor"] = l.Visitor
|
||
l.fieldMap["ip"] = l.IP
|
||
l.fieldMap["ua"] = l.Ua
|
||
l.fieldMap["method"] = l.Method
|
||
l.fieldMap["path"] = l.Path
|
||
l.fieldMap["latency"] = l.Latency
|
||
l.fieldMap["status"] = l.Status
|
||
l.fieldMap["error"] = l.Error
|
||
l.fieldMap["time"] = l.Time
|
||
}
|
||
|
||
func (l logsRequest) clone(db *gorm.DB) logsRequest {
|
||
l.logsRequestDo.ReplaceConnPool(db.Statement.ConnPool)
|
||
return l
|
||
}
|
||
|
||
func (l logsRequest) replaceDB(db *gorm.DB) logsRequest {
|
||
l.logsRequestDo.ReplaceDB(db)
|
||
return l
|
||
}
|
||
|
||
type logsRequestDo struct{ gen.DO }
|
||
|
||
func (l logsRequestDo) Debug() *logsRequestDo {
|
||
return l.withDO(l.DO.Debug())
|
||
}
|
||
|
||
func (l logsRequestDo) WithContext(ctx context.Context) *logsRequestDo {
|
||
return l.withDO(l.DO.WithContext(ctx))
|
||
}
|
||
|
||
func (l logsRequestDo) ReadDB() *logsRequestDo {
|
||
return l.Clauses(dbresolver.Read)
|
||
}
|
||
|
||
func (l logsRequestDo) WriteDB() *logsRequestDo {
|
||
return l.Clauses(dbresolver.Write)
|
||
}
|
||
|
||
func (l logsRequestDo) Session(config *gorm.Session) *logsRequestDo {
|
||
return l.withDO(l.DO.Session(config))
|
||
}
|
||
|
||
func (l logsRequestDo) Clauses(conds ...clause.Expression) *logsRequestDo {
|
||
return l.withDO(l.DO.Clauses(conds...))
|
||
}
|
||
|
||
func (l logsRequestDo) Returning(value interface{}, columns ...string) *logsRequestDo {
|
||
return l.withDO(l.DO.Returning(value, columns...))
|
||
}
|
||
|
||
func (l logsRequestDo) Not(conds ...gen.Condition) *logsRequestDo {
|
||
return l.withDO(l.DO.Not(conds...))
|
||
}
|
||
|
||
func (l logsRequestDo) Or(conds ...gen.Condition) *logsRequestDo {
|
||
return l.withDO(l.DO.Or(conds...))
|
||
}
|
||
|
||
func (l logsRequestDo) Select(conds ...field.Expr) *logsRequestDo {
|
||
return l.withDO(l.DO.Select(conds...))
|
||
}
|
||
|
||
func (l logsRequestDo) Where(conds ...gen.Condition) *logsRequestDo {
|
||
return l.withDO(l.DO.Where(conds...))
|
||
}
|
||
|
||
func (l logsRequestDo) Order(conds ...field.Expr) *logsRequestDo {
|
||
return l.withDO(l.DO.Order(conds...))
|
||
}
|
||
|
||
func (l logsRequestDo) Distinct(cols ...field.Expr) *logsRequestDo {
|
||
return l.withDO(l.DO.Distinct(cols...))
|
||
}
|
||
|
||
func (l logsRequestDo) Omit(cols ...field.Expr) *logsRequestDo {
|
||
return l.withDO(l.DO.Omit(cols...))
|
||
}
|
||
|
||
func (l logsRequestDo) Join(table schema.Tabler, on ...field.Expr) *logsRequestDo {
|
||
return l.withDO(l.DO.Join(table, on...))
|
||
}
|
||
|
||
func (l logsRequestDo) LeftJoin(table schema.Tabler, on ...field.Expr) *logsRequestDo {
|
||
return l.withDO(l.DO.LeftJoin(table, on...))
|
||
}
|
||
|
||
func (l logsRequestDo) RightJoin(table schema.Tabler, on ...field.Expr) *logsRequestDo {
|
||
return l.withDO(l.DO.RightJoin(table, on...))
|
||
}
|
||
|
||
func (l logsRequestDo) Group(cols ...field.Expr) *logsRequestDo {
|
||
return l.withDO(l.DO.Group(cols...))
|
||
}
|
||
|
||
func (l logsRequestDo) Having(conds ...gen.Condition) *logsRequestDo {
|
||
return l.withDO(l.DO.Having(conds...))
|
||
}
|
||
|
||
func (l logsRequestDo) Limit(limit int) *logsRequestDo {
|
||
return l.withDO(l.DO.Limit(limit))
|
||
}
|
||
|
||
func (l logsRequestDo) Offset(offset int) *logsRequestDo {
|
||
return l.withDO(l.DO.Offset(offset))
|
||
}
|
||
|
||
func (l logsRequestDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *logsRequestDo {
|
||
return l.withDO(l.DO.Scopes(funcs...))
|
||
}
|
||
|
||
func (l logsRequestDo) Unscoped() *logsRequestDo {
|
||
return l.withDO(l.DO.Unscoped())
|
||
}
|
||
|
||
func (l logsRequestDo) Create(values ...*models.LogsRequest) error {
|
||
if len(values) == 0 {
|
||
return nil
|
||
}
|
||
return l.DO.Create(values)
|
||
}
|
||
|
||
func (l logsRequestDo) CreateInBatches(values []*models.LogsRequest, batchSize int) error {
|
||
return l.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 (l logsRequestDo) Save(values ...*models.LogsRequest) error {
|
||
if len(values) == 0 {
|
||
return nil
|
||
}
|
||
return l.DO.Save(values)
|
||
}
|
||
|
||
func (l logsRequestDo) First() (*models.LogsRequest, error) {
|
||
if result, err := l.DO.First(); err != nil {
|
||
return nil, err
|
||
} else {
|
||
return result.(*models.LogsRequest), nil
|
||
}
|
||
}
|
||
|
||
func (l logsRequestDo) Take() (*models.LogsRequest, error) {
|
||
if result, err := l.DO.Take(); err != nil {
|
||
return nil, err
|
||
} else {
|
||
return result.(*models.LogsRequest), nil
|
||
}
|
||
}
|
||
|
||
func (l logsRequestDo) Last() (*models.LogsRequest, error) {
|
||
if result, err := l.DO.Last(); err != nil {
|
||
return nil, err
|
||
} else {
|
||
return result.(*models.LogsRequest), nil
|
||
}
|
||
}
|
||
|
||
func (l logsRequestDo) Find() ([]*models.LogsRequest, error) {
|
||
result, err := l.DO.Find()
|
||
return result.([]*models.LogsRequest), err
|
||
}
|
||
|
||
func (l logsRequestDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.LogsRequest, err error) {
|
||
buf := make([]*models.LogsRequest, 0, batchSize)
|
||
err = l.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 (l logsRequestDo) FindInBatches(result *[]*models.LogsRequest, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||
return l.DO.FindInBatches(result, batchSize, fc)
|
||
}
|
||
|
||
func (l logsRequestDo) Attrs(attrs ...field.AssignExpr) *logsRequestDo {
|
||
return l.withDO(l.DO.Attrs(attrs...))
|
||
}
|
||
|
||
func (l logsRequestDo) Assign(attrs ...field.AssignExpr) *logsRequestDo {
|
||
return l.withDO(l.DO.Assign(attrs...))
|
||
}
|
||
|
||
func (l logsRequestDo) Joins(fields ...field.RelationField) *logsRequestDo {
|
||
for _, _f := range fields {
|
||
l = *l.withDO(l.DO.Joins(_f))
|
||
}
|
||
return &l
|
||
}
|
||
|
||
func (l logsRequestDo) Preload(fields ...field.RelationField) *logsRequestDo {
|
||
for _, _f := range fields {
|
||
l = *l.withDO(l.DO.Preload(_f))
|
||
}
|
||
return &l
|
||
}
|
||
|
||
func (l logsRequestDo) FirstOrInit() (*models.LogsRequest, error) {
|
||
if result, err := l.DO.FirstOrInit(); err != nil {
|
||
return nil, err
|
||
} else {
|
||
return result.(*models.LogsRequest), nil
|
||
}
|
||
}
|
||
|
||
func (l logsRequestDo) FirstOrCreate() (*models.LogsRequest, error) {
|
||
if result, err := l.DO.FirstOrCreate(); err != nil {
|
||
return nil, err
|
||
} else {
|
||
return result.(*models.LogsRequest), nil
|
||
}
|
||
}
|
||
|
||
func (l logsRequestDo) FindByPage(offset int, limit int) (result []*models.LogsRequest, count int64, err error) {
|
||
result, err = l.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 = l.Offset(-1).Limit(-1).Count()
|
||
return
|
||
}
|
||
|
||
func (l logsRequestDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||
count, err = l.Count()
|
||
if err != nil {
|
||
return
|
||
}
|
||
|
||
err = l.Offset(offset).Limit(limit).Scan(result)
|
||
return
|
||
}
|
||
|
||
func (l logsRequestDo) Scan(result interface{}) (err error) {
|
||
return l.DO.Scan(result)
|
||
}
|
||
|
||
func (l logsRequestDo) Delete(models ...*models.LogsRequest) (result gen.ResultInfo, err error) {
|
||
return l.DO.Delete(models)
|
||
}
|
||
|
||
func (l *logsRequestDo) withDO(do gen.Dao) *logsRequestDo {
|
||
l.DO = *do.(*gen.DO)
|
||
return l
|
||
}
|