6
0

base_user.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. // ==========================================================================
  2. // This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
  3. // ==========================================================================
  4. package internal
  5. import (
  6. "context"
  7. "database/sql"
  8. "github.com/gogf/gf/database/gdb"
  9. "github.com/gogf/gf/frame/g"
  10. "github.com/gogf/gf/frame/gmvc"
  11. model2 "lims_adapter/model"
  12. "time"
  13. )
  14. // BaseUserDao is the manager for logic model data accessing
  15. // and custom defined data operations functions management.
  16. type BaseUserDao struct {
  17. gmvc.M
  18. DB gdb.DB
  19. Table string
  20. Columns baseUserColumns
  21. }
  22. // BaseUserColumns defines and stores column names for table base_user.
  23. type baseUserColumns struct {
  24. Id string //
  25. Uuid string // 用户Id标识,不易猜出
  26. AccCode string // 区分不同App的用户
  27. Code string // 编码
  28. UserName string // 用户登录名
  29. Realname string // 用户名
  30. RoleId string // 角色id
  31. SecurityLevel string //
  32. UserFrom string //
  33. CompanyId string // 公司id
  34. CompanyName string // 公司名称
  35. DepartmentId string // 部门id
  36. DepartmentName string // 部门名称
  37. WorkgroupId string // 工作组id
  38. WorkgroupName string // 工作组名称
  39. WorkCategory string //
  40. Duty string // 职务
  41. Title string // 头衔
  42. Gender string // 性别
  43. Birthday string //
  44. Mobile string //
  45. Telephone string //
  46. Email string //
  47. OICQ string //
  48. HomeAddress string //
  49. UserPassword string //
  50. ChangePasswordDate string // 改密码时间
  51. CommunicationPassword string //
  52. PublicKey string //
  53. SignedPassword string //
  54. Lang string //
  55. Theme string //
  56. AllowStartTime string //
  57. AllowEndTime string //
  58. LockStartDate string //
  59. LockEndDate string //
  60. FirstVisit string //
  61. PreviousVisit string //
  62. LastVisit string //
  63. LogOnCount string //
  64. IsStaff string //
  65. UserOnLine string //
  66. IsVisible string // 是否可视,1为可视
  67. OpenId string //
  68. IPAddress string //
  69. MACAddress string //
  70. Question string //
  71. AnswerQuestion string //
  72. UserAddressId string //
  73. Enabled string // 是否可用
  74. AuditStatus string // 激活状态(1激活)
  75. DeletionStateCode string // 删除状态
  76. SortCode string //
  77. Description string //
  78. CreateOn string //
  79. CreateUserId string //
  80. CreateBy string //
  81. ModifiedOn string //
  82. ModifiedUserId string //
  83. ModifiedBy string //
  84. Photo string //
  85. QRCode string //
  86. QRCodeImage string //
  87. IsCompanyUser string // 是否是企业用户(供方字段用)
  88. Superior string // 上级部门
  89. UnitId string // 二级单位ID(供方字段用)
  90. Unit string //
  91. DeletedAt string // 删除时间
  92. }
  93. var (
  94. // BaseUser is globally public accessible object for table base_user operations.
  95. BaseUser = BaseUserDao{
  96. M: g.DB("default").Model("base_user").Safe(),
  97. DB: g.DB("default"),
  98. Table: "base_user",
  99. Columns: baseUserColumns{
  100. Id: "Id",
  101. Uuid: "Uuid",
  102. AccCode: "AccCode",
  103. Code: "Code",
  104. UserName: "UserName",
  105. Realname: "Realname",
  106. RoleId: "RoleId",
  107. SecurityLevel: "SecurityLevel",
  108. UserFrom: "UserFrom",
  109. CompanyId: "CompanyId",
  110. CompanyName: "CompanyName",
  111. DepartmentId: "DepartmentId",
  112. DepartmentName: "DepartmentName",
  113. WorkgroupId: "WorkgroupId",
  114. WorkgroupName: "WorkgroupName",
  115. WorkCategory: "WorkCategory",
  116. Duty: "Duty",
  117. Title: "Title",
  118. Gender: "Gender",
  119. Birthday: "Birthday",
  120. Mobile: "Mobile",
  121. Telephone: "Telephone",
  122. Email: "Email",
  123. OICQ: "OICQ",
  124. HomeAddress: "HomeAddress",
  125. UserPassword: "UserPassword",
  126. ChangePasswordDate: "ChangePasswordDate",
  127. CommunicationPassword: "CommunicationPassword",
  128. PublicKey: "PublicKey",
  129. SignedPassword: "SignedPassword",
  130. Lang: "Lang",
  131. Theme: "Theme",
  132. AllowStartTime: "AllowStartTime",
  133. AllowEndTime: "AllowEndTime",
  134. LockStartDate: "LockStartDate",
  135. LockEndDate: "LockEndDate",
  136. FirstVisit: "FirstVisit",
  137. PreviousVisit: "PreviousVisit",
  138. LastVisit: "LastVisit",
  139. LogOnCount: "LogOnCount",
  140. IsStaff: "IsStaff",
  141. UserOnLine: "UserOnLine",
  142. IsVisible: "IsVisible",
  143. OpenId: "OpenId",
  144. IPAddress: "IPAddress",
  145. MACAddress: "MACAddress",
  146. Question: "Question",
  147. AnswerQuestion: "AnswerQuestion",
  148. UserAddressId: "UserAddressId",
  149. Enabled: "Enabled",
  150. AuditStatus: "AuditStatus",
  151. DeletionStateCode: "DeletionStateCode",
  152. SortCode: "SortCode",
  153. Description: "Description",
  154. CreateOn: "CreateOn",
  155. CreateUserId: "CreateUserId",
  156. CreateBy: "CreateBy",
  157. ModifiedOn: "ModifiedOn",
  158. ModifiedUserId: "ModifiedUserId",
  159. ModifiedBy: "ModifiedBy",
  160. Photo: "Photo",
  161. QRCode: "QRCode",
  162. QRCodeImage: "QRCodeImage",
  163. IsCompanyUser: "IsCompanyUser",
  164. Superior: "Superior",
  165. UnitId: "UnitId",
  166. Unit: "Unit",
  167. DeletedAt: "DeletedAt",
  168. },
  169. }
  170. )
  171. func NewBaseUserDao(tenant string) BaseUserDao {
  172. var dao BaseUserDao
  173. dao = BaseUserDao{
  174. M: g.DB(tenant).Model("base_user").Safe(),
  175. DB: g.DB(tenant),
  176. Table: "base_user",
  177. Columns: baseUserColumns{
  178. Id: "Id",
  179. Uuid: "Uuid",
  180. AccCode: "AccCode",
  181. Code: "Code",
  182. UserName: "UserName",
  183. Realname: "Realname",
  184. RoleId: "RoleId",
  185. SecurityLevel: "SecurityLevel",
  186. UserFrom: "UserFrom",
  187. CompanyId: "CompanyId",
  188. CompanyName: "CompanyName",
  189. DepartmentId: "DepartmentId",
  190. DepartmentName: "DepartmentName",
  191. WorkgroupId: "WorkgroupId",
  192. WorkgroupName: "WorkgroupName",
  193. WorkCategory: "WorkCategory",
  194. Duty: "Duty",
  195. Title: "Title",
  196. Gender: "Gender",
  197. Birthday: "Birthday",
  198. Mobile: "Mobile",
  199. Telephone: "Telephone",
  200. Email: "Email",
  201. OICQ: "OICQ",
  202. HomeAddress: "HomeAddress",
  203. UserPassword: "UserPassword",
  204. ChangePasswordDate: "ChangePasswordDate",
  205. CommunicationPassword: "CommunicationPassword",
  206. PublicKey: "PublicKey",
  207. SignedPassword: "SignedPassword",
  208. Lang: "Lang",
  209. Theme: "Theme",
  210. AllowStartTime: "AllowStartTime",
  211. AllowEndTime: "AllowEndTime",
  212. LockStartDate: "LockStartDate",
  213. LockEndDate: "LockEndDate",
  214. FirstVisit: "FirstVisit",
  215. PreviousVisit: "PreviousVisit",
  216. LastVisit: "LastVisit",
  217. LogOnCount: "LogOnCount",
  218. IsStaff: "IsStaff",
  219. UserOnLine: "UserOnLine",
  220. IsVisible: "IsVisible",
  221. OpenId: "OpenId",
  222. IPAddress: "IPAddress",
  223. MACAddress: "MACAddress",
  224. Question: "Question",
  225. AnswerQuestion: "AnswerQuestion",
  226. UserAddressId: "UserAddressId",
  227. Enabled: "Enabled",
  228. AuditStatus: "AuditStatus",
  229. DeletionStateCode: "DeletionStateCode",
  230. SortCode: "SortCode",
  231. Description: "Description",
  232. CreateOn: "CreateOn",
  233. CreateUserId: "CreateUserId",
  234. CreateBy: "CreateBy",
  235. ModifiedOn: "ModifiedOn",
  236. ModifiedUserId: "ModifiedUserId",
  237. ModifiedBy: "ModifiedBy",
  238. Photo: "Photo",
  239. QRCode: "QRCode",
  240. QRCodeImage: "QRCodeImage",
  241. IsCompanyUser: "IsCompanyUser",
  242. Superior: "Superior",
  243. UnitId: "UnitId",
  244. Unit: "Unit",
  245. DeletedAt: "DeletedAt",
  246. },
  247. }
  248. return dao
  249. }
  250. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  251. // of current DB object and with given context in it.
  252. // Note that this returned DB object can be used only once, so do not assign it to
  253. // a global or package variable for long using.
  254. func (d *BaseUserDao) Ctx(ctx context.Context) *BaseUserDao {
  255. return &BaseUserDao{M: d.M.Ctx(ctx)}
  256. }
  257. // As sets an alias name for current table.
  258. func (d *BaseUserDao) As(as string) *BaseUserDao {
  259. return &BaseUserDao{M: d.M.As(as)}
  260. }
  261. // TX sets the transaction for current operation.
  262. func (d *BaseUserDao) TX(tx *gdb.TX) *BaseUserDao {
  263. return &BaseUserDao{M: d.M.TX(tx)}
  264. }
  265. // Master marks the following operation on master node.
  266. func (d *BaseUserDao) Master() *BaseUserDao {
  267. return &BaseUserDao{M: d.M.Master()}
  268. }
  269. // Slave marks the following operation on slave node.
  270. // Note that it makes sense only if there's any slave node configured.
  271. func (d *BaseUserDao) Slave() *BaseUserDao {
  272. return &BaseUserDao{M: d.M.Slave()}
  273. }
  274. // Args sets custom arguments for model operation.
  275. func (d *BaseUserDao) Args(args ...interface{}) *BaseUserDao {
  276. return &BaseUserDao{M: d.M.Args(args...)}
  277. }
  278. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  279. // The parameter <table> can be joined table and its joined condition,
  280. // and also with its alias name, like:
  281. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  282. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  283. func (d *BaseUserDao) LeftJoin(table ...string) *BaseUserDao {
  284. return &BaseUserDao{M: d.M.LeftJoin(table...)}
  285. }
  286. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  287. // The parameter <table> can be joined table and its joined condition,
  288. // and also with its alias name, like:
  289. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  290. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  291. func (d *BaseUserDao) RightJoin(table ...string) *BaseUserDao {
  292. return &BaseUserDao{M: d.M.RightJoin(table...)}
  293. }
  294. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  295. // The parameter <table> can be joined table and its joined condition,
  296. // and also with its alias name, like:
  297. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  298. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  299. func (d *BaseUserDao) InnerJoin(table ...string) *BaseUserDao {
  300. return &BaseUserDao{M: d.M.InnerJoin(table...)}
  301. }
  302. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  303. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  304. func (d *BaseUserDao) Fields(fieldNamesOrMapStruct ...interface{}) *BaseUserDao {
  305. return &BaseUserDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
  306. }
  307. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  308. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  309. func (d *BaseUserDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *BaseUserDao {
  310. return &BaseUserDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
  311. }
  312. // Option sets the extra operation option for the model.
  313. func (d *BaseUserDao) Option(option int) *BaseUserDao {
  314. return &BaseUserDao{M: d.M.Option(option)}
  315. }
  316. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  317. // the data and where attributes for empty values.
  318. func (d *BaseUserDao) OmitEmpty() *BaseUserDao {
  319. return &BaseUserDao{M: d.M.OmitEmpty()}
  320. }
  321. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  322. func (d *BaseUserDao) Filter() *BaseUserDao {
  323. return &BaseUserDao{M: d.M.Filter()}
  324. }
  325. // Where sets the condition statement for the model. The parameter <where> can be type of
  326. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  327. // multiple conditions will be joined into where statement using "AND".
  328. // Eg:
  329. // Where("uid=10000")
  330. // Where("uid", 10000)
  331. // Where("money>? AND name like ?", 99999, "vip_%")
  332. // Where("uid", 1).Where("name", "john")
  333. // Where("status IN (?)", g.Slice{1,2,3})
  334. // Where("age IN(?,?)", 18, 50)
  335. // Where(User{ Id : 1, UserName : "john"})
  336. func (d *BaseUserDao) Where(where interface{}, args ...interface{}) *BaseUserDao {
  337. return &BaseUserDao{M: d.M.Where(where, args...)}
  338. }
  339. // WherePri does the same logic as M.Where except that if the parameter <where>
  340. // is a single condition like int/string/float/slice, it treats the condition as the primary
  341. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  342. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  343. // as string "123".
  344. func (d *BaseUserDao) WherePri(where interface{}, args ...interface{}) *BaseUserDao {
  345. return &BaseUserDao{M: d.M.WherePri(where, args...)}
  346. }
  347. // And adds "AND" condition to the where statement.
  348. func (d *BaseUserDao) And(where interface{}, args ...interface{}) *BaseUserDao {
  349. return &BaseUserDao{M: d.M.And(where, args...)}
  350. }
  351. // Or adds "OR" condition to the where statement.
  352. func (d *BaseUserDao) Or(where interface{}, args ...interface{}) *BaseUserDao {
  353. return &BaseUserDao{M: d.M.Or(where, args...)}
  354. }
  355. // Group sets the "GROUP BY" statement for the model.
  356. func (d *BaseUserDao) Group(groupBy string) *BaseUserDao {
  357. return &BaseUserDao{M: d.M.Group(groupBy)}
  358. }
  359. // Order sets the "ORDER BY" statement for the model.
  360. func (d *BaseUserDao) Order(orderBy ...string) *BaseUserDao {
  361. return &BaseUserDao{M: d.M.Order(orderBy...)}
  362. }
  363. // Limit sets the "LIMIT" statement for the model.
  364. // The parameter <limit> can be either one or two number, if passed two number is passed,
  365. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  366. // statement.
  367. func (d *BaseUserDao) Limit(limit ...int) *BaseUserDao {
  368. return &BaseUserDao{M: d.M.Limit(limit...)}
  369. }
  370. // Offset sets the "OFFSET" statement for the model.
  371. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  372. func (d *BaseUserDao) Offset(offset int) *BaseUserDao {
  373. return &BaseUserDao{M: d.M.Offset(offset)}
  374. }
  375. // Page sets the paging number for the model.
  376. // The parameter <page> is started from 1 for paging.
  377. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  378. func (d *BaseUserDao) Page(page, limit int) *BaseUserDao {
  379. return &BaseUserDao{M: d.M.Page(page, limit)}
  380. }
  381. // Batch sets the batch operation number for the model.
  382. func (d *BaseUserDao) Batch(batch int) *BaseUserDao {
  383. return &BaseUserDao{M: d.M.Batch(batch)}
  384. }
  385. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  386. // if there's another same sql request, it just reads and returns the result from cache, it
  387. // but not committed and executed into the database.
  388. //
  389. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  390. // If the parameter <duration> = 0, which means it never expires.
  391. // If the parameter <duration> > 0, which means it expires after <duration>.
  392. //
  393. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  394. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  395. //
  396. // Note that, the cache feature is disabled if the model is operating on a transaction.
  397. func (d *BaseUserDao) Cache(duration time.Duration, name ...string) *BaseUserDao {
  398. return &BaseUserDao{M: d.M.Cache(duration, name...)}
  399. }
  400. // Data sets the operation data for the model.
  401. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  402. // Eg:
  403. // Data("uid=10000")
  404. // Data("uid", 10000)
  405. // Data(g.Map{"uid": 10000, "name":"john"})
  406. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  407. func (d *BaseUserDao) Data(data ...interface{}) *BaseUserDao {
  408. return &BaseUserDao{M: d.M.Data(data...)}
  409. }
  410. // All does "SELECT FROM ..." statement for the model.
  411. // It retrieves the records from table and returns the result as []*model.BaseUser.
  412. // It returns nil if there's no record retrieved with the given conditions from table.
  413. //
  414. // The optional parameter <where> is the same as the parameter of M.Where function,
  415. // see M.Where.
  416. func (d *BaseUserDao) All(where ...interface{}) ([]*model2.BaseUser, error) {
  417. all, err := d.M.All(where...)
  418. if err != nil {
  419. return nil, err
  420. }
  421. var entities []*model2.BaseUser
  422. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  423. return nil, err
  424. }
  425. return entities, nil
  426. }
  427. // One retrieves one record from table and returns the result as *model.BaseUser.
  428. // It returns nil if there's no record retrieved with the given conditions from table.
  429. //
  430. // The optional parameter <where> is the same as the parameter of M.Where function,
  431. // see M.Where.
  432. func (d *BaseUserDao) One(where ...interface{}) (*model2.BaseUser, error) {
  433. one, err := d.M.One(where...)
  434. if err != nil {
  435. return nil, err
  436. }
  437. var entity *model2.BaseUser
  438. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  439. return nil, err
  440. }
  441. return entity, nil
  442. }
  443. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  444. // Also see M.WherePri and M.One.
  445. func (d *BaseUserDao) FindOne(where ...interface{}) (*model2.BaseUser, error) {
  446. one, err := d.M.FindOne(where...)
  447. if err != nil {
  448. return nil, err
  449. }
  450. var entity *model2.BaseUser
  451. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  452. return nil, err
  453. }
  454. return entity, nil
  455. }
  456. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  457. // Also see M.WherePri and M.All.
  458. func (d *BaseUserDao) FindAll(where ...interface{}) ([]*model2.BaseUser, error) {
  459. all, err := d.M.FindAll(where...)
  460. if err != nil {
  461. return nil, err
  462. }
  463. var entities []*model2.BaseUser
  464. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  465. return nil, err
  466. }
  467. return entities, nil
  468. }
  469. // Struct retrieves one record from table and converts it into given struct.
  470. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  471. // it can create the struct internally during converting.
  472. //
  473. // The optional parameter <where> is the same as the parameter of Model.Where function,
  474. // see Model.Where.
  475. //
  476. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  477. // from table and <pointer> is not nil.
  478. //
  479. // Eg:
  480. // user := new(User)
  481. // err := dao.User.Where("id", 1).Struct(user)
  482. //
  483. // user := (*User)(nil)
  484. // err := dao.User.Where("id", 1).Struct(&user)
  485. func (d *BaseUserDao) Struct(pointer interface{}, where ...interface{}) error {
  486. return d.M.Struct(pointer, where...)
  487. }
  488. // Structs retrieves records from table and converts them into given struct slice.
  489. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  490. // slice internally during converting.
  491. //
  492. // The optional parameter <where> is the same as the parameter of Model.Where function,
  493. // see Model.Where.
  494. //
  495. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  496. // from table and <pointer> is not empty.
  497. //
  498. // Eg:
  499. // users := ([]User)(nil)
  500. // err := dao.User.Structs(&users)
  501. //
  502. // users := ([]*User)(nil)
  503. // err := dao.User.Structs(&users)
  504. func (d *BaseUserDao) Structs(pointer interface{}, where ...interface{}) error {
  505. return d.M.Structs(pointer, where...)
  506. }
  507. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  508. // It calls function Struct if <pointer> is type of *struct/**struct.
  509. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  510. //
  511. // The optional parameter <where> is the same as the parameter of Model.Where function,
  512. // see Model.Where.
  513. //
  514. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  515. //
  516. // Eg:
  517. // user := new(User)
  518. // err := dao.User.Where("id", 1).Scan(user)
  519. //
  520. // user := (*User)(nil)
  521. // err := dao.User.Where("id", 1).Scan(&user)
  522. //
  523. // users := ([]User)(nil)
  524. // err := dao.User.Scan(&users)
  525. //
  526. // users := ([]*User)(nil)
  527. // err := dao.User.Scan(&users)
  528. func (d *BaseUserDao) Scan(pointer interface{}, where ...interface{}) error {
  529. return d.M.Scan(pointer, where...)
  530. }
  531. // Chunk iterates the table with given size and callback function.
  532. func (d *BaseUserDao) Chunk(limit int, callback func(entities []*model2.BaseUser, err error) bool) {
  533. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  534. var entities []*model2.BaseUser
  535. err = result.Structs(&entities)
  536. if err == sql.ErrNoRows {
  537. return false
  538. }
  539. return callback(entities, err)
  540. })
  541. }
  542. // LockUpdate sets the lock for update for current operation.
  543. func (d *BaseUserDao) LockUpdate() *BaseUserDao {
  544. return &BaseUserDao{M: d.M.LockUpdate()}
  545. }
  546. // LockShared sets the lock in share mode for current operation.
  547. func (d *BaseUserDao) LockShared() *BaseUserDao {
  548. return &BaseUserDao{M: d.M.LockShared()}
  549. }
  550. // Unscoped enables/disables the soft deleting feature.
  551. func (d *BaseUserDao) Unscoped() *BaseUserDao {
  552. return &BaseUserDao{M: d.M.Unscoped()}
  553. }