| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596 |
- // ==========================================================================
- // 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"
- model2 "lims_adapter/model"
- "time"
- )
- // BaseUserDao is the manager for logic model data accessing
- // and custom defined data operations functions management.
- type BaseUserDao struct {
- gmvc.M
- DB gdb.DB
- Table string
- Columns baseUserColumns
- }
- // BaseUserColumns defines and stores column names for table base_user.
- type baseUserColumns struct {
- Id string //
- Uuid string // 用户Id标识,不易猜出
- AccCode string // 区分不同App的用户
- Code string // 编码
- UserName string // 用户登录名
- Realname string // 用户名
- RoleId string // 角色id
- SecurityLevel string //
- UserFrom string //
- CompanyId string // 公司id
- CompanyName string // 公司名称
- DepartmentId string // 部门id
- DepartmentName string // 部门名称
- WorkgroupId string // 工作组id
- WorkgroupName string // 工作组名称
- WorkCategory string //
- Duty string // 职务
- Title string // 头衔
- Gender string // 性别
- Birthday string //
- Mobile string //
- Telephone string //
- Email string //
- OICQ string //
- HomeAddress string //
- UserPassword string //
- ChangePasswordDate string // 改密码时间
- CommunicationPassword string //
- PublicKey string //
- SignedPassword string //
- Lang string //
- Theme string //
- AllowStartTime string //
- AllowEndTime string //
- LockStartDate string //
- LockEndDate string //
- FirstVisit string //
- PreviousVisit string //
- LastVisit string //
- LogOnCount string //
- IsStaff string //
- UserOnLine string //
- IsVisible string // 是否可视,1为可视
- OpenId string //
- IPAddress string //
- MACAddress string //
- Question string //
- AnswerQuestion string //
- UserAddressId string //
- Enabled string // 是否可用
- AuditStatus string // 激活状态(1激活)
- DeletionStateCode string // 删除状态
- SortCode string //
- Description string //
- CreateOn string //
- CreateUserId string //
- CreateBy string //
- ModifiedOn string //
- ModifiedUserId string //
- ModifiedBy string //
- Photo string //
- QRCode string //
- QRCodeImage string //
- IsCompanyUser string // 是否是企业用户(供方字段用)
- Superior string // 上级部门
- UnitId string // 二级单位ID(供方字段用)
- Unit string //
- DeletedAt string // 删除时间
- }
- var (
- // BaseUser is globally public accessible object for table base_user operations.
- BaseUser = BaseUserDao{
- M: g.DB("default").Model("base_user").Safe(),
- DB: g.DB("default"),
- Table: "base_user",
- Columns: baseUserColumns{
- Id: "Id",
- Uuid: "Uuid",
- AccCode: "AccCode",
- Code: "Code",
- UserName: "UserName",
- Realname: "Realname",
- RoleId: "RoleId",
- SecurityLevel: "SecurityLevel",
- UserFrom: "UserFrom",
- CompanyId: "CompanyId",
- CompanyName: "CompanyName",
- DepartmentId: "DepartmentId",
- DepartmentName: "DepartmentName",
- WorkgroupId: "WorkgroupId",
- WorkgroupName: "WorkgroupName",
- WorkCategory: "WorkCategory",
- Duty: "Duty",
- Title: "Title",
- Gender: "Gender",
- Birthday: "Birthday",
- Mobile: "Mobile",
- Telephone: "Telephone",
- Email: "Email",
- OICQ: "OICQ",
- HomeAddress: "HomeAddress",
- UserPassword: "UserPassword",
- ChangePasswordDate: "ChangePasswordDate",
- CommunicationPassword: "CommunicationPassword",
- PublicKey: "PublicKey",
- SignedPassword: "SignedPassword",
- Lang: "Lang",
- Theme: "Theme",
- AllowStartTime: "AllowStartTime",
- AllowEndTime: "AllowEndTime",
- LockStartDate: "LockStartDate",
- LockEndDate: "LockEndDate",
- FirstVisit: "FirstVisit",
- PreviousVisit: "PreviousVisit",
- LastVisit: "LastVisit",
- LogOnCount: "LogOnCount",
- IsStaff: "IsStaff",
- UserOnLine: "UserOnLine",
- IsVisible: "IsVisible",
- OpenId: "OpenId",
- IPAddress: "IPAddress",
- MACAddress: "MACAddress",
- Question: "Question",
- AnswerQuestion: "AnswerQuestion",
- UserAddressId: "UserAddressId",
- Enabled: "Enabled",
- AuditStatus: "AuditStatus",
- DeletionStateCode: "DeletionStateCode",
- SortCode: "SortCode",
- Description: "Description",
- CreateOn: "CreateOn",
- CreateUserId: "CreateUserId",
- CreateBy: "CreateBy",
- ModifiedOn: "ModifiedOn",
- ModifiedUserId: "ModifiedUserId",
- ModifiedBy: "ModifiedBy",
- Photo: "Photo",
- QRCode: "QRCode",
- QRCodeImage: "QRCodeImage",
- IsCompanyUser: "IsCompanyUser",
- Superior: "Superior",
- UnitId: "UnitId",
- Unit: "Unit",
- DeletedAt: "DeletedAt",
- },
- }
- )
- func NewBaseUserDao(tenant string) BaseUserDao {
- var dao BaseUserDao
- dao = BaseUserDao{
- M: g.DB(tenant).Model("base_user").Safe(),
- DB: g.DB(tenant),
- Table: "base_user",
- Columns: baseUserColumns{
- Id: "Id",
- Uuid: "Uuid",
- AccCode: "AccCode",
- Code: "Code",
- UserName: "UserName",
- Realname: "Realname",
- RoleId: "RoleId",
- SecurityLevel: "SecurityLevel",
- UserFrom: "UserFrom",
- CompanyId: "CompanyId",
- CompanyName: "CompanyName",
- DepartmentId: "DepartmentId",
- DepartmentName: "DepartmentName",
- WorkgroupId: "WorkgroupId",
- WorkgroupName: "WorkgroupName",
- WorkCategory: "WorkCategory",
- Duty: "Duty",
- Title: "Title",
- Gender: "Gender",
- Birthday: "Birthday",
- Mobile: "Mobile",
- Telephone: "Telephone",
- Email: "Email",
- OICQ: "OICQ",
- HomeAddress: "HomeAddress",
- UserPassword: "UserPassword",
- ChangePasswordDate: "ChangePasswordDate",
- CommunicationPassword: "CommunicationPassword",
- PublicKey: "PublicKey",
- SignedPassword: "SignedPassword",
- Lang: "Lang",
- Theme: "Theme",
- AllowStartTime: "AllowStartTime",
- AllowEndTime: "AllowEndTime",
- LockStartDate: "LockStartDate",
- LockEndDate: "LockEndDate",
- FirstVisit: "FirstVisit",
- PreviousVisit: "PreviousVisit",
- LastVisit: "LastVisit",
- LogOnCount: "LogOnCount",
- IsStaff: "IsStaff",
- UserOnLine: "UserOnLine",
- IsVisible: "IsVisible",
- OpenId: "OpenId",
- IPAddress: "IPAddress",
- MACAddress: "MACAddress",
- Question: "Question",
- AnswerQuestion: "AnswerQuestion",
- UserAddressId: "UserAddressId",
- Enabled: "Enabled",
- AuditStatus: "AuditStatus",
- DeletionStateCode: "DeletionStateCode",
- SortCode: "SortCode",
- Description: "Description",
- CreateOn: "CreateOn",
- CreateUserId: "CreateUserId",
- CreateBy: "CreateBy",
- ModifiedOn: "ModifiedOn",
- ModifiedUserId: "ModifiedUserId",
- ModifiedBy: "ModifiedBy",
- Photo: "Photo",
- QRCode: "QRCode",
- QRCodeImage: "QRCodeImage",
- IsCompanyUser: "IsCompanyUser",
- Superior: "Superior",
- UnitId: "UnitId",
- Unit: "Unit",
- DeletedAt: "DeletedAt",
- },
- }
- 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 *BaseUserDao) Ctx(ctx context.Context) *BaseUserDao {
- return &BaseUserDao{M: d.M.Ctx(ctx)}
- }
- // As sets an alias name for current table.
- func (d *BaseUserDao) As(as string) *BaseUserDao {
- return &BaseUserDao{M: d.M.As(as)}
- }
- // TX sets the transaction for current operation.
- func (d *BaseUserDao) TX(tx *gdb.TX) *BaseUserDao {
- return &BaseUserDao{M: d.M.TX(tx)}
- }
- // Master marks the following operation on master node.
- func (d *BaseUserDao) Master() *BaseUserDao {
- return &BaseUserDao{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 *BaseUserDao) Slave() *BaseUserDao {
- return &BaseUserDao{M: d.M.Slave()}
- }
- // Args sets custom arguments for model operation.
- func (d *BaseUserDao) Args(args ...interface{}) *BaseUserDao {
- return &BaseUserDao{M: d.M.Args(args...)}
- }
- // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
- // The parameter <table> 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 *BaseUserDao) LeftJoin(table ...string) *BaseUserDao {
- return &BaseUserDao{M: d.M.LeftJoin(table...)}
- }
- // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
- // The parameter <table> 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 *BaseUserDao) RightJoin(table ...string) *BaseUserDao {
- return &BaseUserDao{M: d.M.RightJoin(table...)}
- }
- // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
- // The parameter <table> 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 *BaseUserDao) InnerJoin(table ...string) *BaseUserDao {
- return &BaseUserDao{M: d.M.InnerJoin(table...)}
- }
- // Fields sets the operation fields of the model, multiple fields joined using char ','.
- // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
- func (d *BaseUserDao) Fields(fieldNamesOrMapStruct ...interface{}) *BaseUserDao {
- return &BaseUserDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
- }
- // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
- // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
- func (d *BaseUserDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *BaseUserDao {
- return &BaseUserDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
- }
- // Option sets the extra operation option for the model.
- func (d *BaseUserDao) Option(option int) *BaseUserDao {
- return &BaseUserDao{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 *BaseUserDao) OmitEmpty() *BaseUserDao {
- return &BaseUserDao{M: d.M.OmitEmpty()}
- }
- // Filter marks filtering the fields which does not exist in the fields of the operated table.
- func (d *BaseUserDao) Filter() *BaseUserDao {
- return &BaseUserDao{M: d.M.Filter()}
- }
- // Where sets the condition statement for the model. The parameter <where> 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 *BaseUserDao) Where(where interface{}, args ...interface{}) *BaseUserDao {
- return &BaseUserDao{M: d.M.Where(where, args...)}
- }
- // WherePri does the same logic as M.Where except that if the parameter <where>
- // 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 <where> parameter as "123", the
- // WherePri function treats the condition as "id=123", but M.Where treats the condition
- // as string "123".
- func (d *BaseUserDao) WherePri(where interface{}, args ...interface{}) *BaseUserDao {
- return &BaseUserDao{M: d.M.WherePri(where, args...)}
- }
- // And adds "AND" condition to the where statement.
- func (d *BaseUserDao) And(where interface{}, args ...interface{}) *BaseUserDao {
- return &BaseUserDao{M: d.M.And(where, args...)}
- }
- // Or adds "OR" condition to the where statement.
- func (d *BaseUserDao) Or(where interface{}, args ...interface{}) *BaseUserDao {
- return &BaseUserDao{M: d.M.Or(where, args...)}
- }
- // Group sets the "GROUP BY" statement for the model.
- func (d *BaseUserDao) Group(groupBy string) *BaseUserDao {
- return &BaseUserDao{M: d.M.Group(groupBy)}
- }
- // Order sets the "ORDER BY" statement for the model.
- func (d *BaseUserDao) Order(orderBy ...string) *BaseUserDao {
- return &BaseUserDao{M: d.M.Order(orderBy...)}
- }
- // Limit sets the "LIMIT" statement for the model.
- // The parameter <limit> 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 *BaseUserDao) Limit(limit ...int) *BaseUserDao {
- return &BaseUserDao{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 *BaseUserDao) Offset(offset int) *BaseUserDao {
- return &BaseUserDao{M: d.M.Offset(offset)}
- }
- // Page sets the paging number for the model.
- // The parameter <page> is started from 1 for paging.
- // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
- func (d *BaseUserDao) Page(page, limit int) *BaseUserDao {
- return &BaseUserDao{M: d.M.Page(page, limit)}
- }
- // Batch sets the batch operation number for the model.
- func (d *BaseUserDao) Batch(batch int) *BaseUserDao {
- return &BaseUserDao{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 <duration> < 0, which means it clear the cache with given <name>.
- // If the parameter <duration> = 0, which means it never expires.
- // If the parameter <duration> > 0, which means it expires after <duration>.
- //
- // The optional parameter <name> is used to bind a name to the cache, which means you can later
- // control the cache like changing the <duration> or clearing the cache with specified <name>.
- //
- // Note that, the cache feature is disabled if the model is operating on a transaction.
- func (d *BaseUserDao) Cache(duration time.Duration, name ...string) *BaseUserDao {
- return &BaseUserDao{M: d.M.Cache(duration, name...)}
- }
- // Data sets the operation data for the model.
- // The parameter <data> 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 *BaseUserDao) Data(data ...interface{}) *BaseUserDao {
- return &BaseUserDao{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.BaseUser.
- // It returns nil if there's no record retrieved with the given conditions from table.
- //
- // The optional parameter <where> is the same as the parameter of M.Where function,
- // see M.Where.
- func (d *BaseUserDao) All(where ...interface{}) ([]*model2.BaseUser, error) {
- all, err := d.M.All(where...)
- if err != nil {
- return nil, err
- }
- var entities []*model2.BaseUser
- 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.BaseUser.
- // It returns nil if there's no record retrieved with the given conditions from table.
- //
- // The optional parameter <where> is the same as the parameter of M.Where function,
- // see M.Where.
- func (d *BaseUserDao) One(where ...interface{}) (*model2.BaseUser, error) {
- one, err := d.M.One(where...)
- if err != nil {
- return nil, err
- }
- var entity *model2.BaseUser
- 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 *BaseUserDao) FindOne(where ...interface{}) (*model2.BaseUser, error) {
- one, err := d.M.FindOne(where...)
- if err != nil {
- return nil, err
- }
- var entity *model2.BaseUser
- 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 *BaseUserDao) FindAll(where ...interface{}) ([]*model2.BaseUser, error) {
- all, err := d.M.FindAll(where...)
- if err != nil {
- return nil, err
- }
- var entities []*model2.BaseUser
- 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 <pointer> should be type of *struct/**struct. If type **struct is given,
- // it can create the struct internally during converting.
- //
- // The optional parameter <where> 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 <pointer> 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 *BaseUserDao) 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 <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
- // slice internally during converting.
- //
- // The optional parameter <where> 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 <pointer> is not empty.
- //
- // Eg:
- // users := ([]User)(nil)
- // err := dao.User.Structs(&users)
- //
- // users := ([]*User)(nil)
- // err := dao.User.Structs(&users)
- func (d *BaseUserDao) 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 <pointer>.
- // It calls function Struct if <pointer> is type of *struct/**struct.
- // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
- //
- // The optional parameter <where> 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 *BaseUserDao) Scan(pointer interface{}, where ...interface{}) error {
- return d.M.Scan(pointer, where...)
- }
- // Chunk iterates the table with given size and callback function.
- func (d *BaseUserDao) Chunk(limit int, callback func(entities []*model2.BaseUser, err error) bool) {
- d.M.Chunk(limit, func(result gdb.Result, err error) bool {
- var entities []*model2.BaseUser
- 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 *BaseUserDao) LockUpdate() *BaseUserDao {
- return &BaseUserDao{M: d.M.LockUpdate()}
- }
- // LockShared sets the lock in share mode for current operation.
- func (d *BaseUserDao) LockShared() *BaseUserDao {
- return &BaseUserDao{M: d.M.LockShared()}
- }
- // Unscoped enables/disables the soft deleting feature.
- func (d *BaseUserDao) Unscoped() *BaseUserDao {
- return &BaseUserDao{M: d.M.Unscoped()}
- }
|