learning_skill.go 15 KB

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