// ========================================================================== // This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY. // ========================================================================== package internal import ( "context" "database/sql" "github.com/gogf/gf/database/gdb" "github.com/gogf/gf/frame/g" "github.com/gogf/gf/frame/gmvc" "time" model "dashoo.cn/micro/app/model/proj" ) // ProjBusinessDao is the manager for logic model data accessing // and custom defined data operations functions management. type ProjBusinessDao struct { gmvc.M DB gdb.DB Table string Columns projBusinessColumns } // ProjBusinessColumns defines and stores column names for table proj_business. type projBusinessColumns struct { Id string // 主键 NboCode string // 项目编号 NboName string // 项目名称 NboStatus string // 项目状态 CustId string // 关联客户 CustName string // 客户名称 NboType string // 项目类别(A类B类C类) NboPhase string // 项目阶段(暂不起用) NboSource string // 项目来源 NboBudget string // 项目预算 ApproStatus string // 审批状态(10待提交20审批中30审批通过40审批退回60审批拒绝) ContactId string // 关联联系人 ContactName string // 联系人姓名 ContactPostion string // 联系人岗位 ContactTelephone string // 联系人电话 MakerId string // 关联决策人 MakerName string // 决策人姓名 MakerPost string // 决策人岗位 MakerTelephone string // 决策人电话 SalesModel string // 销售模式(10直销20经销30代理) SaleId string // 归属销售 SaleName string // 销售姓名 DistributorId string // 经销商/代理商ID DistributorName string // 经销商/代理商名称 ObtainTime string // 获取时间 FinalFollowTime string // 最后跟进时间 NextFollowTime string // 下次跟进时间 PlanPurchaseTime string // 计划采购时间 EstTransTime string // 预计成交时间 EstTransPrice string // 预计成交价格 RiskProfile string // 风险情况 Difficulty string // 困难点 Competitor string // 竞争公司 Intervention string // 介入情况 DeptId string // 所属部门ID DeptName string // 所属部门 Remark string // 备注 CreatedBy string // 创建者 CreatedName string // 创建人 CreatedTime string // 创建时间 UpdatedBy string // 更新者 UpdatedName string // 更新人 UpdatedTime string // 更新时间 DeletedTime string // 删除时间 } var ( // ProjBusiness is globally public accessible object for table proj_business operations. ProjBusiness = ProjBusinessDao{ M: g.DB("default").Model("proj_business").Safe(), DB: g.DB("default"), Table: "proj_business", Columns: projBusinessColumns{ Id: "id", NboCode: "nbo_code", NboName: "nbo_name", NboStatus: "nbo_status", CustId: "cust_id", CustName: "cust_name", NboType: "nbo_type", NboPhase: "nbo_phase", NboSource: "nbo_source", NboBudget: "nbo_budget", ApproStatus: "appro_status", ContactId: "contact_id", ContactName: "contact_name", ContactPostion: "contact_postion", ContactTelephone: "contact_telephone", MakerId: "maker_id", MakerName: "maker_name", MakerPost: "maker_post", MakerTelephone: "maker_telephone", SalesModel: "sales_model", SaleId: "sale_id", SaleName: "sale_name", DistributorId: "distributor_id", DistributorName: "distributor_name", ObtainTime: "obtain_time", FinalFollowTime: "final_follow_time", NextFollowTime: "next_follow_time", PlanPurchaseTime: "plan_purchase_time", EstTransTime: "est_trans_time", EstTransPrice: "est_trans_price", RiskProfile: "risk_profile", Difficulty: "difficulty", Competitor: "competitor", Intervention: "Intervention", DeptId: "dept_id", DeptName: "dept_name", Remark: "remark", CreatedBy: "created_by", CreatedName: "created_name", CreatedTime: "created_time", UpdatedBy: "updated_by", UpdatedName: "updated_name", UpdatedTime: "updated_time", DeletedTime: "deleted_time", }, } ) func NewProjBusinessDao(tenant string) ProjBusinessDao { var dao ProjBusinessDao dao = ProjBusinessDao{ M: g.DB(tenant).Model("proj_business").Safe(), DB: g.DB(tenant), Table: "proj_business", Columns: projBusinessColumns{ Id: "id", NboCode: "nbo_code", NboName: "nbo_name", NboStatus: "nbo_status", CustId: "cust_id", CustName: "cust_name", NboType: "nbo_type", NboPhase: "nbo_phase", NboSource: "nbo_source", NboBudget: "nbo_budget", ApproStatus: "appro_status", ContactId: "contact_id", ContactName: "contact_name", ContactPostion: "contact_postion", ContactTelephone: "contact_telephone", MakerId: "maker_id", MakerName: "maker_name", MakerPost: "maker_post", MakerTelephone: "maker_telephone", SalesModel: "sales_model", SaleId: "sale_id", SaleName: "sale_name", DistributorId: "distributor_id", DistributorName: "distributor_name", ObtainTime: "obtain_time", FinalFollowTime: "final_follow_time", NextFollowTime: "next_follow_time", PlanPurchaseTime: "plan_purchase_time", EstTransTime: "est_trans_time", EstTransPrice: "est_trans_price", RiskProfile: "risk_profile", Difficulty: "difficulty", Competitor: "competitor", Intervention: "Intervention", DeptId: "dept_id", DeptName: "dept_name", Remark: "remark", CreatedBy: "created_by", CreatedName: "created_name", CreatedTime: "created_time", UpdatedBy: "updated_by", UpdatedName: "updated_name", UpdatedTime: "updated_time", DeletedTime: "deleted_time", }, } return dao } // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy // of current DB object and with given context in it. // Note that this returned DB object can be used only once, so do not assign it to // a global or package variable for long using. func (d *ProjBusinessDao) Ctx(ctx context.Context) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Ctx(ctx)} } // As sets an alias name for current table. func (d *ProjBusinessDao) As(as string) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.As(as)} } // TX sets the transaction for current operation. func (d *ProjBusinessDao) TX(tx *gdb.TX) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.TX(tx)} } // Master marks the following operation on master node. func (d *ProjBusinessDao) Master() *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Master()} } // Slave marks the following operation on slave node. // Note that it makes sense only if there's any slave node configured. func (d *ProjBusinessDao) Slave() *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Slave()} } // Args sets custom arguments for model operation. func (d *ProjBusinessDao) Args(args ...interface{}) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Args(args...)} } // LeftJoin does "LEFT JOIN ... ON ..." statement on the model. // The parameter can be joined table and its joined condition, // and also with its alias name, like: // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid") // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid") func (d *ProjBusinessDao) LeftJoin(table ...string) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.LeftJoin(table...)} } // RightJoin does "RIGHT JOIN ... ON ..." statement on the model. // The parameter
can be joined table and its joined condition, // and also with its alias name, like: // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid") // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid") func (d *ProjBusinessDao) RightJoin(table ...string) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.RightJoin(table...)} } // InnerJoin does "INNER JOIN ... ON ..." statement on the model. // The parameter
can be joined table and its joined condition, // and also with its alias name, like: // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid") // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid") func (d *ProjBusinessDao) InnerJoin(table ...string) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.InnerJoin(table...)} } // Fields sets the operation fields of the model, multiple fields joined using char ','. // The parameter can be type of string/map/*map/struct/*struct. func (d *ProjBusinessDao) Fields(fieldNamesOrMapStruct ...interface{}) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Fields(fieldNamesOrMapStruct...)} } // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','. // The parameter can be type of string/map/*map/struct/*struct. func (d *ProjBusinessDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)} } // Option sets the extra operation option for the model. func (d *ProjBusinessDao) Option(option int) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Option(option)} } // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers // the data and where attributes for empty values. func (d *ProjBusinessDao) OmitEmpty() *ProjBusinessDao { return &ProjBusinessDao{M: d.M.OmitEmpty()} } // Filter marks filtering the fields which does not exist in the fields of the operated table. func (d *ProjBusinessDao) Filter() *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Filter()} } // Where sets the condition statement for the model. The parameter can be type of // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times, // multiple conditions will be joined into where statement using "AND". // Eg: // Where("uid=10000") // Where("uid", 10000) // Where("money>? AND name like ?", 99999, "vip_%") // Where("uid", 1).Where("name", "john") // Where("status IN (?)", g.Slice{1,2,3}) // Where("age IN(?,?)", 18, 50) // Where(User{ Id : 1, UserName : "john"}) func (d *ProjBusinessDao) Where(where interface{}, args ...interface{}) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Where(where, args...)} } // WherePri does the same logic as M.Where except that if the parameter // is a single condition like int/string/float/slice, it treats the condition as the primary // key value. That is, if primary key is "id" and given parameter as "123", the // WherePri function treats the condition as "id=123", but M.Where treats the condition // as string "123". func (d *ProjBusinessDao) WherePri(where interface{}, args ...interface{}) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.WherePri(where, args...)} } // And adds "AND" condition to the where statement. func (d *ProjBusinessDao) And(where interface{}, args ...interface{}) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.And(where, args...)} } // Or adds "OR" condition to the where statement. func (d *ProjBusinessDao) Or(where interface{}, args ...interface{}) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Or(where, args...)} } // Group sets the "GROUP BY" statement for the model. func (d *ProjBusinessDao) Group(groupBy string) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Group(groupBy)} } // Order sets the "ORDER BY" statement for the model. func (d *ProjBusinessDao) Order(orderBy ...string) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Order(orderBy...)} } // Limit sets the "LIMIT" statement for the model. // The parameter can be either one or two number, if passed two number is passed, // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]" // statement. func (d *ProjBusinessDao) Limit(limit ...int) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Limit(limit...)} } // Offset sets the "OFFSET" statement for the model. // It only makes sense for some databases like SQLServer, PostgreSQL, etc. func (d *ProjBusinessDao) Offset(offset int) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Offset(offset)} } // Page sets the paging number for the model. // The parameter is started from 1 for paging. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement. func (d *ProjBusinessDao) Page(page, limit int) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Page(page, limit)} } // Batch sets the batch operation number for the model. func (d *ProjBusinessDao) Batch(batch int) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Batch(batch)} } // Cache sets the cache feature for the model. It caches the result of the sql, which means // if there's another same sql request, it just reads and returns the result from cache, it // but not committed and executed into the database. // // If the parameter < 0, which means it clear the cache with given . // If the parameter = 0, which means it never expires. // If the parameter > 0, which means it expires after . // // The optional parameter is used to bind a name to the cache, which means you can later // control the cache like changing the or clearing the cache with specified . // // Note that, the cache feature is disabled if the model is operating on a transaction. func (d *ProjBusinessDao) Cache(duration time.Duration, name ...string) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Cache(duration, name...)} } // Data sets the operation data for the model. // The parameter can be type of string/map/gmap/slice/struct/*struct, etc. // Eg: // Data("uid=10000") // Data("uid", 10000) // Data(g.Map{"uid": 10000, "name":"john"}) // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"}) func (d *ProjBusinessDao) Data(data ...interface{}) *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Data(data...)} } // All does "SELECT FROM ..." statement for the model. // It retrieves the records from table and returns the result as []*model.ProjBusiness. // It returns nil if there's no record retrieved with the given conditions from table. // // The optional parameter is the same as the parameter of M.Where function, // see M.Where. func (d *ProjBusinessDao) All(where ...interface{}) ([]*model.ProjBusiness, error) { all, err := d.M.All(where...) if err != nil { return nil, err } var entities []*model.ProjBusiness if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows { return nil, err } return entities, nil } // One retrieves one record from table and returns the result as *model.ProjBusiness. // It returns nil if there's no record retrieved with the given conditions from table. // // The optional parameter is the same as the parameter of M.Where function, // see M.Where. func (d *ProjBusinessDao) One(where ...interface{}) (*model.ProjBusiness, error) { one, err := d.M.One(where...) if err != nil { return nil, err } var entity *model.ProjBusiness if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows { return nil, err } return entity, nil } // FindOne retrieves and returns a single Record by M.WherePri and M.One. // Also see M.WherePri and M.One. func (d *ProjBusinessDao) FindOne(where ...interface{}) (*model.ProjBusiness, error) { one, err := d.M.FindOne(where...) if err != nil { return nil, err } var entity *model.ProjBusiness if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows { return nil, err } return entity, nil } // FindAll retrieves and returns Result by by M.WherePri and M.All. // Also see M.WherePri and M.All. func (d *ProjBusinessDao) FindAll(where ...interface{}) ([]*model.ProjBusiness, error) { all, err := d.M.FindAll(where...) if err != nil { return nil, err } var entities []*model.ProjBusiness if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows { return nil, err } return entities, nil } // Struct retrieves one record from table and converts it into given struct. // The parameter should be type of *struct/**struct. If type **struct is given, // it can create the struct internally during converting. // // The optional parameter is the same as the parameter of Model.Where function, // see Model.Where. // // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions // from table and is not nil. // // Eg: // user := new(User) // err := dao.User.Where("id", 1).Struct(user) // // user := (*User)(nil) // err := dao.User.Where("id", 1).Struct(&user) func (d *ProjBusinessDao) Struct(pointer interface{}, where ...interface{}) error { return d.M.Struct(pointer, where...) } // Structs retrieves records from table and converts them into given struct slice. // The parameter should be type of *[]struct/*[]*struct. It can create and fill the struct // slice internally during converting. // // The optional parameter is the same as the parameter of Model.Where function, // see Model.Where. // // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions // from table and is not empty. // // Eg: // users := ([]User)(nil) // err := dao.User.Structs(&users) // // users := ([]*User)(nil) // err := dao.User.Structs(&users) func (d *ProjBusinessDao) Structs(pointer interface{}, where ...interface{}) error { return d.M.Structs(pointer, where...) } // Scan automatically calls Struct or Structs function according to the type of parameter . // It calls function Struct if is type of *struct/**struct. // It calls function Structs if is type of *[]struct/*[]*struct. // // The optional parameter is the same as the parameter of Model.Where function, // see Model.Where. // // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil. // // Eg: // user := new(User) // err := dao.User.Where("id", 1).Scan(user) // // user := (*User)(nil) // err := dao.User.Where("id", 1).Scan(&user) // // users := ([]User)(nil) // err := dao.User.Scan(&users) // // users := ([]*User)(nil) // err := dao.User.Scan(&users) func (d *ProjBusinessDao) Scan(pointer interface{}, where ...interface{}) error { return d.M.Scan(pointer, where...) } // Chunk iterates the table with given size and callback function. func (d *ProjBusinessDao) Chunk(limit int, callback func(entities []*model.ProjBusiness, err error) bool) { d.M.Chunk(limit, func(result gdb.Result, err error) bool { var entities []*model.ProjBusiness err = result.Structs(&entities) if err == sql.ErrNoRows { return false } return callback(entities, err) }) } // LockUpdate sets the lock for update for current operation. func (d *ProjBusinessDao) LockUpdate() *ProjBusinessDao { return &ProjBusinessDao{M: d.M.LockUpdate()} } // LockShared sets the lock in share mode for current operation. func (d *ProjBusinessDao) LockShared() *ProjBusinessDao { return &ProjBusinessDao{M: d.M.LockShared()} } // Unscoped enables/disables the soft deleting feature. func (d *ProjBusinessDao) Unscoped() *ProjBusinessDao { return &ProjBusinessDao{M: d.M.Unscoped()} }