proj_business_file.go 16 KB

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