announcement_file.go 16 KB

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