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

package wf_run

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

// Entity is the golang structure for table wf_run.
type Entity struct {
	Id             uint   `orm:"id,primary"       json:"id"`               //
	Pid            uint   `orm:"pid"              json:"pid"`              // work_run父流转公文ID 值大于0则这个是子流程，完成后或者要返回父流程
	FromTable      string `orm:"from_table"       json:"from_table"`       // 单据表，不带前缀
	FromId         int    `orm:"from_id"          json:"from_id"`          //
	FromTitle      string `orm:"from_title"       json:"from_title"`       // 业务表标题字段
	FromStatus     string `orm:"from_status"       json:"from_status"`     // 业务表审批状态字段
	PidFlowStep    uint   `orm:"pid_flow_step"    json:"pid_flow_step"`    // 父pid的flow_id中的第几步骤进入的,取回这个work_flow_step的child_over决定结束子流程的动作
	CacheRunId     uint   `orm:"cache_run_id"     json:"cache_run_id"`     // 多个子流程时pid无法识别cache所以加这个字段pid>0
	Uid            uint   `orm:"uid"              json:"uid"`              //
	FlowId         uint   `orm:"flow_id"          json:"flow_id"`          // 流程id 正常流程
	CatId          uint   `orm:"cat_id"           json:"cat_id"`           // 流程分类ID即公文分类ID
	RunName        string `orm:"run_name"         json:"run_name"`         // 公文名称
	RunFlowId      uint   `orm:"run_flow_id"      json:"run_flow_id"`      // 流转到什么流程 最新流程，查询优化，进入子流程时将简化查询，子流程与父流程同步
	RunFlowProcess string `orm:"run_flow_process" json:"run_flow_process"` // 流转到第几步
	AttIds         string `orm:"att_ids"          json:"att_ids"`          // 公文附件ids
	Endtime        uint   `orm:"endtime"          json:"endtime"`          // 结束时间
	Status         uint   `orm:"status"           json:"status"`           // 状态，0流程中，1通过,2回退
	IsDel          uint   `orm:"is_del"           json:"is_del"`           //
	Updatetime     uint   `orm:"updatetime"       json:"updatetime"`       //
	Dateline       uint   `orm:"dateline"         json:"dateline"`         //
	IsSing         int    `orm:"is_sing"          json:"is_sing"`          //
	SingId         int    `orm:"sing_id"          json:"sing_id"`          //
}

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