This commit is contained in:
72
backend_v1/database/models/posts.gen.go
Normal file
72
backend_v1/database/models/posts.gen.go
Normal file
@@ -0,0 +1,72 @@
|
||||
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
||||
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
||||
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"go.ipao.vip/gen"
|
||||
"go.ipao.vip/gen/types"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNamePost = "posts"
|
||||
|
||||
// Post mapped from table <posts>
|
||||
type Post struct {
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp without time zone;not null;default:now()" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp without time zone;not null;default:now()" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone" json:"deleted_at"`
|
||||
Status int16 `gorm:"column:status;type:smallint;not null" json:"status"`
|
||||
Title string `gorm:"column:title;type:character varying(128);not null" json:"title"`
|
||||
HeadImages types.JSON `gorm:"column:head_images;type:jsonb;not null;default:[]" json:"head_images"`
|
||||
Description string `gorm:"column:description;type:character varying(256);not null" json:"description"`
|
||||
Content string `gorm:"column:content;type:text;not null" json:"content"`
|
||||
Price int64 `gorm:"column:price;type:bigint;not null" json:"price"`
|
||||
Discount int16 `gorm:"column:discount;type:smallint;not null;default:100" json:"discount"`
|
||||
Views int64 `gorm:"column:views;type:bigint;not null" json:"views"`
|
||||
Likes int64 `gorm:"column:likes;type:bigint;not null" json:"likes"`
|
||||
Tags types.JSON `gorm:"column:tags;type:jsonb;default:{}" json:"tags"`
|
||||
Assets types.JSON `gorm:"column:assets;type:jsonb;default:{}" json:"assets"`
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
// Update applies changed fields to the database using the default DB.
|
||||
func (m *Post) Update(ctx context.Context) (gen.ResultInfo, error) {
|
||||
return Q.Post.WithContext(ctx).Updates(m)
|
||||
}
|
||||
|
||||
// Save upserts the model using the default DB.
|
||||
func (m *Post) Save(ctx context.Context) error { return Q.Post.WithContext(ctx).Save(m) }
|
||||
|
||||
// Create inserts the model using the default DB.
|
||||
func (m *Post) Create(ctx context.Context) error { return Q.Post.WithContext(ctx).Create(m) }
|
||||
|
||||
// Delete removes the row represented by the model using the default DB.
|
||||
func (m *Post) Delete(ctx context.Context) (gen.ResultInfo, error) {
|
||||
return Q.Post.WithContext(ctx).Delete(m)
|
||||
}
|
||||
|
||||
// ForceDelete permanently deletes the row (ignores soft delete) using the default DB.
|
||||
func (m *Post) ForceDelete(ctx context.Context) (gen.ResultInfo, error) {
|
||||
return Q.Post.WithContext(ctx).Unscoped().Delete(m)
|
||||
}
|
||||
|
||||
// Restore sets deleted_at to NULL for this model's primary key using the default DB.
|
||||
func (m *Post) Restore(ctx context.Context) (gen.ResultInfo, error) {
|
||||
return Q.Post.WithContext(ctx).RestoreByID(m.ID)
|
||||
}
|
||||
|
||||
// Reload reloads the model from database by its primary key and overwrites current fields.
|
||||
func (m *Post) Reload(ctx context.Context) error {
|
||||
fresh, err := Q.Post.WithContext(ctx).GetByID(m.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*m = *fresh
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user