meeting.go 15 KB

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