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

package gen_table

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

// Entity is the golang structure for table gen_table.
type Entity struct {
	TableId        int64       `orm:"table_id,primary" json:"table_id"`        // 编号
	TableName      string      `orm:"table_name"       json:"table_name"`      // 表名称
	TableComment   string      `orm:"table_comment"    json:"table_comment"`   // 表描述
	ClassName      string      `orm:"class_name"       json:"class_name"`      // 实体类名称
	TplCategory    string      `orm:"tpl_category"     json:"tpl_category"`    // 使用的模板（crud单表操作 tree树表操作）
	PackageName    string      `orm:"package_name"     json:"package_name"`    // 生成包路径
	ModuleName     string      `orm:"module_name"      json:"module_name"`     // 生成模块名
	BusinessName   string      `orm:"business_name"    json:"business_name"`   // 生成业务名
	FunctionName   string      `orm:"function_name"    json:"function_name"`   // 生成功能名
	FunctionAuthor string      `orm:"function_author"  json:"function_author"` // 生成功能作者
	Options        string      `orm:"options"          json:"options"`         // 其它生成选项
	CreateBy       string      `orm:"create_by"        json:"create_by"`       // 创建者
	CreateTime     *gtime.Time `orm:"create_time"      json:"create_time"`     // 创建时间
	UpdateBy       string      `orm:"update_by"        json:"update_by"`       // 更新者
	UpdateTime     *gtime.Time `orm:"update_time"      json:"update_time"`     // 更新时间
	Remark         string      `orm:"remark"           json:"remark"`          // 备注
}

//修改页面请求参数
type EditReq struct {
	TableId        int64  `p:"tableId" v:"required#主键ID不能为空"`
	TableName      string `p:"tableName"  v:"required#表名称不能为空"`
	TableComment   string `p:"tableComment"  v:"required#表描述不能为空"`
	ClassName      string `p:"className" v:"required#实体类名称不能为空"`
	FunctionAuthor string `p:"functionAuthor"  v:"required#作者不能为空"`
	TplCategory    string `p:"tplCategory"`
	PackageName    string `p:"packageName" v:"required#生成包路径不能为空"`
	ModuleName     string `p:"moduleName" v:"required#生成模块名不能为空"`
	BusinessName   string `p:"businessName" v:"required#生成业务名不能为空"`
	FunctionName   string `p:"functionName" v:"required#生成功能名不能为空"`
	Remark         string `p:"remark"`
	Params         string `p:"params"`
	Columns        string `p:"columns"`
	TreeCode       string `p:"tree_code"`
	TreeParentCode string `p:"tree_parent_code"`
	TreeName       string `p:"tree_name"`
	UserName       string
}

// 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()
}
