// ==========================================================================
// This is auto-generated by gf cli tool. You may not really want to edit it.
// ==========================================================================

package model_info

import (
	"database/sql"
	"github.com/gogf/gf/database/gdb"
)

// Entity is the golang structure for table model_info.
type Entity struct {
	ModelId         uint   `orm:"model_id,primary"  json:"model_id"`          // 模型ID
	ModelCategoryId uint   `orm:"model_category_id" json:"model_category_id"` // 模板分类id
	ModelName       string `orm:"model_name"        json:"model_name"`        // 模型标识
	ModelTitle      string `orm:"model_title"       json:"model_title"`       // 模型名称
	ModelPk         string `orm:"model_pk"          json:"model_pk"`          // 主键字段
	ModelOrder      string `orm:"model_order"       json:"model_order"`       // 默认排序字段
	ModelSort       string `orm:"model_sort"        json:"model_sort"`        // 表单字段排序
	ModelList       string `orm:"model_list"        json:"model_list"`        // 列表显示字段，为空显示全部
	ModelEdit       string `orm:"model_edit"        json:"model_edit"`        // 可编辑字段，为空则除主键外均可以编辑
	ModelIndexes    string `orm:"model_indexes"     json:"model_indexes"`     // 索引字段
	SearchList      string `orm:"search_list"       json:"search_list"`       // 高级搜索的字段
	CreateTime      uint64 `orm:"create_time"       json:"create_time"`       // 创建时间
	UpdateTime      uint64 `orm:"update_time"       json:"update_time"`       // 更新时间
	ModelStatus     uint   `orm:"model_status"      json:"model_status"`      // 状态
	ModelEngine     string `orm:"model_engine"      json:"model_engine"`      // 数据库引擎
	CreateBy        uint64 `orm:"create_by"         json:"create_by"`         // 创建人
	UpdateBy        uint64 `orm:"update_by"         json:"update_by"`         // 修改人
}

// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
// the data and where attributes for empty values.
func (r *Entity) OmitEmpty() *arModel {
	return Model.Data(r).OmitEmpty()
}

// Inserts does "INSERT...INTO..." statement for inserting current object into table.
func (r *Entity) Insert() (result sql.Result, err error) {
	return Model.Data(r).Insert()
}

// InsertIgnore does "INSERT IGNORE INTO ..." statement for inserting current object into table.
func (r *Entity) InsertIgnore() (result sql.Result, err error) {
	return Model.Data(r).InsertIgnore()
}

// Replace does "REPLACE...INTO..." statement for inserting current object into table.
// If there's already another same record in the table (it checks using primary key or unique index),
// it deletes it and insert this one.
func (r *Entity) Replace() (result sql.Result, err error) {
	return Model.Data(r).Replace()
}

// Save does "INSERT...INTO..." statement for inserting/updating current object into table.
// It updates the record if there's already another same record in the table
// (it checks using primary key or unique index).
func (r *Entity) Save() (result sql.Result, err error) {
	return Model.Data(r).Save()
}

// Update does "UPDATE...WHERE..." statement for updating current object from table.
// It updates the record if there's already another same record in the table
// (it checks using primary key or unique index).
func (r *Entity) Update() (result sql.Result, err error) {
	return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
}

// Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
func (r *Entity) Delete() (result sql.Result, err error) {
	return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
}
