6
0

base_equipment_qualification.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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. "lims_adapter/model/equipment"
  12. "time"
  13. )
  14. // BaseEquipmentQualificationDao is the manager for logic model data accessing
  15. // and custom defined data operations functions management.
  16. type BaseEquipmentQualificationDao struct {
  17. gmvc.M
  18. DB gdb.DB
  19. Table string
  20. Columns baseEquipmentQualificationColumns
  21. }
  22. // BaseEquipmentQualificationColumns defines and stores column names for table base_equipment_qualification.
  23. type baseEquipmentQualificationColumns struct {
  24. Id string // 主键
  25. EquipmentId string // 设备Id
  26. Qualification string // 预约资格:1普通资格,2资深资格
  27. UserId string // 用户Id
  28. AuthorizeTime string // 授权时间
  29. CreateOn string //
  30. CreateUserId string //
  31. CreateBy string //
  32. ModifiedOn string //
  33. ModifiedUserId string //
  34. ModifiedBy string //
  35. }
  36. var (
  37. // BaseEquipmentQualification is globally public accessible object for table base_equipment_qualification operations.
  38. BaseEquipmentQualification = BaseEquipmentQualificationDao{
  39. M: g.DB("default").Model("base_equipment_qualification").Safe(),
  40. DB: g.DB("default"),
  41. Table: "base_equipment_qualification",
  42. Columns: baseEquipmentQualificationColumns{
  43. Id: "Id",
  44. EquipmentId: "EquipmentId",
  45. Qualification: "Qualification",
  46. UserId: "UserId",
  47. AuthorizeTime: "AuthorizeTime",
  48. CreateOn: "CreateOn",
  49. CreateUserId: "CreateUserId",
  50. CreateBy: "CreateBy",
  51. ModifiedOn: "ModifiedOn",
  52. ModifiedUserId: "ModifiedUserId",
  53. ModifiedBy: "ModifiedBy",
  54. },
  55. }
  56. )
  57. func NewBaseEquipmentQualificationDao(tenant string) BaseEquipmentQualificationDao {
  58. var dao BaseEquipmentQualificationDao
  59. dao = BaseEquipmentQualificationDao{
  60. M: g.DB(tenant).Model("base_equipment_qualification").Safe(),
  61. DB: g.DB(tenant),
  62. Table: "base_equipment_qualification",
  63. Columns: baseEquipmentQualificationColumns{
  64. Id: "Id",
  65. EquipmentId: "EquipmentId",
  66. Qualification: "Qualification",
  67. UserId: "UserId",
  68. AuthorizeTime: "AuthorizeTime",
  69. CreateOn: "CreateOn",
  70. CreateUserId: "CreateUserId",
  71. CreateBy: "CreateBy",
  72. ModifiedOn: "ModifiedOn",
  73. ModifiedUserId: "ModifiedUserId",
  74. ModifiedBy: "ModifiedBy",
  75. },
  76. }
  77. return dao
  78. }
  79. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  80. // of current DB object and with given context in it.
  81. // Note that this returned DB object can be used only once, so do not assign it to
  82. // a global or package variable for long using.
  83. func (d *BaseEquipmentQualificationDao) Ctx(ctx context.Context) *BaseEquipmentQualificationDao {
  84. return &BaseEquipmentQualificationDao{M: d.M.Ctx(ctx)}
  85. }
  86. // As sets an alias name for current table.
  87. func (d *BaseEquipmentQualificationDao) As(as string) *BaseEquipmentQualificationDao {
  88. return &BaseEquipmentQualificationDao{M: d.M.As(as)}
  89. }
  90. // TX sets the transaction for current operation.
  91. func (d *BaseEquipmentQualificationDao) TX(tx *gdb.TX) *BaseEquipmentQualificationDao {
  92. return &BaseEquipmentQualificationDao{M: d.M.TX(tx)}
  93. }
  94. // Master marks the following operation on master node.
  95. func (d *BaseEquipmentQualificationDao) Master() *BaseEquipmentQualificationDao {
  96. return &BaseEquipmentQualificationDao{M: d.M.Master()}
  97. }
  98. // Slave marks the following operation on slave node.
  99. // Note that it makes sense only if there's any slave node configured.
  100. func (d *BaseEquipmentQualificationDao) Slave() *BaseEquipmentQualificationDao {
  101. return &BaseEquipmentQualificationDao{M: d.M.Slave()}
  102. }
  103. // Args sets custom arguments for model operation.
  104. func (d *BaseEquipmentQualificationDao) Args(args ...interface{}) *BaseEquipmentQualificationDao {
  105. return &BaseEquipmentQualificationDao{M: d.M.Args(args...)}
  106. }
  107. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  108. // The parameter <table> can be joined table and its joined condition,
  109. // and also with its alias name, like:
  110. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  111. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  112. func (d *BaseEquipmentQualificationDao) LeftJoin(table ...string) *BaseEquipmentQualificationDao {
  113. return &BaseEquipmentQualificationDao{M: d.M.LeftJoin(table...)}
  114. }
  115. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  116. // The parameter <table> can be joined table and its joined condition,
  117. // and also with its alias name, like:
  118. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  119. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  120. func (d *BaseEquipmentQualificationDao) RightJoin(table ...string) *BaseEquipmentQualificationDao {
  121. return &BaseEquipmentQualificationDao{M: d.M.RightJoin(table...)}
  122. }
  123. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  124. // The parameter <table> can be joined table and its joined condition,
  125. // and also with its alias name, like:
  126. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  127. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  128. func (d *BaseEquipmentQualificationDao) InnerJoin(table ...string) *BaseEquipmentQualificationDao {
  129. return &BaseEquipmentQualificationDao{M: d.M.InnerJoin(table...)}
  130. }
  131. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  132. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  133. func (d *BaseEquipmentQualificationDao) Fields(fieldNamesOrMapStruct ...interface{}) *BaseEquipmentQualificationDao {
  134. return &BaseEquipmentQualificationDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
  135. }
  136. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  137. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  138. func (d *BaseEquipmentQualificationDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *BaseEquipmentQualificationDao {
  139. return &BaseEquipmentQualificationDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
  140. }
  141. // Option sets the extra operation option for the model.
  142. func (d *BaseEquipmentQualificationDao) Option(option int) *BaseEquipmentQualificationDao {
  143. return &BaseEquipmentQualificationDao{M: d.M.Option(option)}
  144. }
  145. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  146. // the data and where attributes for empty values.
  147. func (d *BaseEquipmentQualificationDao) OmitEmpty() *BaseEquipmentQualificationDao {
  148. return &BaseEquipmentQualificationDao{M: d.M.OmitEmpty()}
  149. }
  150. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  151. func (d *BaseEquipmentQualificationDao) Filter() *BaseEquipmentQualificationDao {
  152. return &BaseEquipmentQualificationDao{M: d.M.Filter()}
  153. }
  154. // Where sets the condition statement for the model. The parameter <where> can be type of
  155. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  156. // multiple conditions will be joined into where statement using "AND".
  157. // Eg:
  158. // Where("uid=10000")
  159. // Where("uid", 10000)
  160. // Where("money>? AND name like ?", 99999, "vip_%")
  161. // Where("uid", 1).Where("name", "john")
  162. // Where("status IN (?)", g.Slice{1,2,3})
  163. // Where("age IN(?,?)", 18, 50)
  164. // Where(User{ Id : 1, UserName : "john"})
  165. func (d *BaseEquipmentQualificationDao) Where(where interface{}, args ...interface{}) *BaseEquipmentQualificationDao {
  166. return &BaseEquipmentQualificationDao{M: d.M.Where(where, args...)}
  167. }
  168. // WherePri does the same logic as M.Where except that if the parameter <where>
  169. // is a single condition like int/string/float/slice, it treats the condition as the primary
  170. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  171. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  172. // as string "123".
  173. func (d *BaseEquipmentQualificationDao) WherePri(where interface{}, args ...interface{}) *BaseEquipmentQualificationDao {
  174. return &BaseEquipmentQualificationDao{M: d.M.WherePri(where, args...)}
  175. }
  176. // And adds "AND" condition to the where statement.
  177. func (d *BaseEquipmentQualificationDao) And(where interface{}, args ...interface{}) *BaseEquipmentQualificationDao {
  178. return &BaseEquipmentQualificationDao{M: d.M.And(where, args...)}
  179. }
  180. // Or adds "OR" condition to the where statement.
  181. func (d *BaseEquipmentQualificationDao) Or(where interface{}, args ...interface{}) *BaseEquipmentQualificationDao {
  182. return &BaseEquipmentQualificationDao{M: d.M.Or(where, args...)}
  183. }
  184. // Group sets the "GROUP BY" statement for the model.
  185. func (d *BaseEquipmentQualificationDao) Group(groupBy string) *BaseEquipmentQualificationDao {
  186. return &BaseEquipmentQualificationDao{M: d.M.Group(groupBy)}
  187. }
  188. // Order sets the "ORDER BY" statement for the model.
  189. func (d *BaseEquipmentQualificationDao) Order(orderBy ...string) *BaseEquipmentQualificationDao {
  190. return &BaseEquipmentQualificationDao{M: d.M.Order(orderBy...)}
  191. }
  192. // Limit sets the "LIMIT" statement for the model.
  193. // The parameter <limit> can be either one or two number, if passed two number is passed,
  194. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  195. // statement.
  196. func (d *BaseEquipmentQualificationDao) Limit(limit ...int) *BaseEquipmentQualificationDao {
  197. return &BaseEquipmentQualificationDao{M: d.M.Limit(limit...)}
  198. }
  199. // Offset sets the "OFFSET" statement for the model.
  200. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  201. func (d *BaseEquipmentQualificationDao) Offset(offset int) *BaseEquipmentQualificationDao {
  202. return &BaseEquipmentQualificationDao{M: d.M.Offset(offset)}
  203. }
  204. // Page sets the paging number for the model.
  205. // The parameter <page> is started from 1 for paging.
  206. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  207. func (d *BaseEquipmentQualificationDao) Page(page, limit int) *BaseEquipmentQualificationDao {
  208. return &BaseEquipmentQualificationDao{M: d.M.Page(page, limit)}
  209. }
  210. // Batch sets the batch operation number for the model.
  211. func (d *BaseEquipmentQualificationDao) Batch(batch int) *BaseEquipmentQualificationDao {
  212. return &BaseEquipmentQualificationDao{M: d.M.Batch(batch)}
  213. }
  214. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  215. // if there's another same sql request, it just reads and returns the result from cache, it
  216. // but not committed and executed into the database.
  217. //
  218. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  219. // If the parameter <duration> = 0, which means it never expires.
  220. // If the parameter <duration> > 0, which means it expires after <duration>.
  221. //
  222. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  223. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  224. //
  225. // Note that, the cache feature is disabled if the model is operating on a transaction.
  226. func (d *BaseEquipmentQualificationDao) Cache(duration time.Duration, name ...string) *BaseEquipmentQualificationDao {
  227. return &BaseEquipmentQualificationDao{M: d.M.Cache(duration, name...)}
  228. }
  229. // Data sets the operation data for the model.
  230. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  231. // Eg:
  232. // Data("uid=10000")
  233. // Data("uid", 10000)
  234. // Data(g.Map{"uid": 10000, "name":"john"})
  235. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  236. func (d *BaseEquipmentQualificationDao) Data(data ...interface{}) *BaseEquipmentQualificationDao {
  237. return &BaseEquipmentQualificationDao{M: d.M.Data(data...)}
  238. }
  239. // All does "SELECT FROM ..." statement for the model.
  240. // It retrieves the records from table and returns the result as []*model.BaseEquipmentQualification.
  241. // It returns nil if there's no record retrieved with the given conditions from table.
  242. //
  243. // The optional parameter <where> is the same as the parameter of M.Where function,
  244. // see M.Where.
  245. func (d *BaseEquipmentQualificationDao) All(where ...interface{}) ([]*equipment.BaseEquipmentQualification, error) {
  246. all, err := d.M.All(where...)
  247. if err != nil {
  248. return nil, err
  249. }
  250. var entities []*equipment.BaseEquipmentQualification
  251. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  252. return nil, err
  253. }
  254. return entities, nil
  255. }
  256. // One retrieves one record from table and returns the result as *model.BaseEquipmentQualification.
  257. // It returns nil if there's no record retrieved with the given conditions from table.
  258. //
  259. // The optional parameter <where> is the same as the parameter of M.Where function,
  260. // see M.Where.
  261. func (d *BaseEquipmentQualificationDao) One(where ...interface{}) (*equipment.BaseEquipmentQualification, error) {
  262. one, err := d.M.One(where...)
  263. if err != nil {
  264. return nil, err
  265. }
  266. var entity *equipment.BaseEquipmentQualification
  267. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  268. return nil, err
  269. }
  270. return entity, nil
  271. }
  272. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  273. // Also see M.WherePri and M.One.
  274. func (d *BaseEquipmentQualificationDao) FindOne(where ...interface{}) (*equipment.BaseEquipmentQualification, error) {
  275. one, err := d.M.FindOne(where...)
  276. if err != nil {
  277. return nil, err
  278. }
  279. var entity *equipment.BaseEquipmentQualification
  280. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  281. return nil, err
  282. }
  283. return entity, nil
  284. }
  285. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  286. // Also see M.WherePri and M.All.
  287. func (d *BaseEquipmentQualificationDao) FindAll(where ...interface{}) ([]*equipment.BaseEquipmentQualification, error) {
  288. all, err := d.M.FindAll(where...)
  289. if err != nil {
  290. return nil, err
  291. }
  292. var entities []*equipment.BaseEquipmentQualification
  293. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  294. return nil, err
  295. }
  296. return entities, nil
  297. }
  298. // Struct retrieves one record from table and converts it into given struct.
  299. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  300. // it can create the struct internally during converting.
  301. //
  302. // The optional parameter <where> is the same as the parameter of Model.Where function,
  303. // see Model.Where.
  304. //
  305. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  306. // from table and <pointer> is not nil.
  307. //
  308. // Eg:
  309. // user := new(User)
  310. // err := dao.User.Where("id", 1).Struct(user)
  311. //
  312. // user := (*User)(nil)
  313. // err := dao.User.Where("id", 1).Struct(&user)
  314. func (d *BaseEquipmentQualificationDao) Struct(pointer interface{}, where ...interface{}) error {
  315. return d.M.Struct(pointer, where...)
  316. }
  317. // Structs retrieves records from table and converts them into given struct slice.
  318. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  319. // slice internally during converting.
  320. //
  321. // The optional parameter <where> is the same as the parameter of Model.Where function,
  322. // see Model.Where.
  323. //
  324. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  325. // from table and <pointer> is not empty.
  326. //
  327. // Eg:
  328. // users := ([]User)(nil)
  329. // err := dao.User.Structs(&users)
  330. //
  331. // users := ([]*User)(nil)
  332. // err := dao.User.Structs(&users)
  333. func (d *BaseEquipmentQualificationDao) Structs(pointer interface{}, where ...interface{}) error {
  334. return d.M.Structs(pointer, where...)
  335. }
  336. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  337. // It calls function Struct if <pointer> is type of *struct/**struct.
  338. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  339. //
  340. // The optional parameter <where> is the same as the parameter of Model.Where function,
  341. // see Model.Where.
  342. //
  343. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  344. //
  345. // Eg:
  346. // user := new(User)
  347. // err := dao.User.Where("id", 1).Scan(user)
  348. //
  349. // user := (*User)(nil)
  350. // err := dao.User.Where("id", 1).Scan(&user)
  351. //
  352. // users := ([]User)(nil)
  353. // err := dao.User.Scan(&users)
  354. //
  355. // users := ([]*User)(nil)
  356. // err := dao.User.Scan(&users)
  357. func (d *BaseEquipmentQualificationDao) Scan(pointer interface{}, where ...interface{}) error {
  358. return d.M.Scan(pointer, where...)
  359. }
  360. // Chunk iterates the table with given size and callback function.
  361. func (d *BaseEquipmentQualificationDao) Chunk(limit int, callback func(entities []*equipment.BaseEquipmentQualification, err error) bool) {
  362. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  363. var entities []*equipment.BaseEquipmentQualification
  364. err = result.Structs(&entities)
  365. if err == sql.ErrNoRows {
  366. return false
  367. }
  368. return callback(entities, err)
  369. })
  370. }
  371. // LockUpdate sets the lock for update for current operation.
  372. func (d *BaseEquipmentQualificationDao) LockUpdate() *BaseEquipmentQualificationDao {
  373. return &BaseEquipmentQualificationDao{M: d.M.LockUpdate()}
  374. }
  375. // LockShared sets the lock in share mode for current operation.
  376. func (d *BaseEquipmentQualificationDao) LockShared() *BaseEquipmentQualificationDao {
  377. return &BaseEquipmentQualificationDao{M: d.M.LockShared()}
  378. }
  379. // Unscoped enables/disables the soft deleting feature.
  380. func (d *BaseEquipmentQualificationDao) Unscoped() *BaseEquipmentQualificationDao {
  381. return &BaseEquipmentQualificationDao{M: d.M.Unscoped()}
  382. }