proj_business_file.go 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  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. "github.com/gogf/gf/util/gconv"
  12. "strings"
  13. "time"
  14. model "dashoo.cn/micro/app/model/proj"
  15. )
  16. // ProjBusinessFileDao is the manager for logic model data accessing and custom defined data operations functions management.
  17. type ProjBusinessFileDao struct {
  18. gmvc.M // M is the core and embedded struct that inherits all chaining operations from gdb.Model.
  19. C projBusinessFileColumns // C is the short type for Columns, which contains all the column names of Table for convenient usage.
  20. DB gdb.DB // DB is the raw underlying database management object.
  21. Table string // Table is the underlying table name of the DAO.
  22. }
  23. // ProjBusinessFileColumns defines and stores column names for table proj_business_file.
  24. type projBusinessFileColumns struct {
  25. Id string // 主键
  26. BusId string // 关联项目
  27. FileName string // 附件名称
  28. FileSize string // 附件大小
  29. FileSource string // 来源
  30. FileUrl string // 附件链接
  31. Remark string // 备注
  32. CreatedBy string // 创建者
  33. CreatedName string // 创建人
  34. CreatedTime string // 创建时间
  35. UpdatedBy string // 更新者
  36. UpdatedName string // 更新人
  37. UpdatedTime string // 更新时间
  38. DeletedTime string // 删除时间
  39. }
  40. var (
  41. // ProjBusinessFile is globally public accessible object for table proj_business_file operations.
  42. ProjBusinessFile = ProjBusinessFileDao{
  43. M: g.DB("default").Model("proj_business_file").Safe(),
  44. DB: g.DB("default"),
  45. Table: "proj_business_file",
  46. C: projBusinessFileColumns{
  47. Id: "id",
  48. BusId: "bus_id",
  49. FileName: "file_name",
  50. FileSize: "file_size",
  51. FileSource: "file_source",
  52. FileUrl: "file_url",
  53. Remark: "remark",
  54. CreatedBy: "created_by",
  55. CreatedName: "created_name",
  56. CreatedTime: "created_time",
  57. UpdatedBy: "updated_by",
  58. UpdatedName: "updated_name",
  59. UpdatedTime: "updated_time",
  60. DeletedTime: "deleted_time",
  61. },
  62. }
  63. )
  64. func NewProjBusinessFileDao(tenant string) ProjBusinessFileDao {
  65. var dao ProjBusinessFileDao
  66. dao = ProjBusinessFileDao{
  67. M: g.DB(tenant).Model("proj_business_file").Safe(),
  68. DB: g.DB(tenant),
  69. Table: "proj_business_file",
  70. C: projBusinessFileColumns{
  71. Id: "id",
  72. BusId: "bus_id",
  73. FileName: "file_name",
  74. FileSize: "file_size",
  75. FileSource: "file_source",
  76. FileUrl: "file_url",
  77. Remark: "remark",
  78. CreatedBy: "created_by",
  79. CreatedName: "created_name",
  80. CreatedTime: "created_time",
  81. UpdatedBy: "updated_by",
  82. UpdatedName: "updated_name",
  83. UpdatedTime: "updated_time",
  84. DeletedTime: "deleted_time",
  85. },
  86. }
  87. return dao
  88. }
  89. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  90. // of current DB object and with given context in it.
  91. // Note that this returned DB object can be used only once, so do not assign it to
  92. // a global or package variable for long using.
  93. func (d *ProjBusinessFileDao) Ctx(ctx context.Context) *ProjBusinessFileDao {
  94. return &ProjBusinessFileDao{M: d.M.Ctx(ctx)}
  95. }
  96. // GetCtx returns the context for current Model.
  97. // It returns "context.Background() i"s there's no context previously set.
  98. func (d *ProjBusinessFileDao) GetCtx() context.Context {
  99. return d.M.GetCtx()
  100. }
  101. // As sets an alias name for current table.
  102. func (d *ProjBusinessFileDao) As(as string) *ProjBusinessFileDao {
  103. return &ProjBusinessFileDao{M: d.M.As(as)}
  104. }
  105. // TX sets the transaction for current operation.
  106. func (d *ProjBusinessFileDao) TX(tx *gdb.TX) *ProjBusinessFileDao {
  107. return &ProjBusinessFileDao{M: d.M.TX(tx)}
  108. }
  109. // Master marks the following operation on master node.
  110. func (d *ProjBusinessFileDao) Master() *ProjBusinessFileDao {
  111. return &ProjBusinessFileDao{M: d.M.Master()}
  112. }
  113. // Slave marks the following operation on slave node.
  114. // Note that it makes sense only if there's any slave node configured.
  115. func (d *ProjBusinessFileDao) Slave() *ProjBusinessFileDao {
  116. return &ProjBusinessFileDao{M: d.M.Slave()}
  117. }
  118. // Args sets custom arguments for model operation.
  119. func (d *ProjBusinessFileDao) Args(args ...interface{}) *ProjBusinessFileDao {
  120. return &ProjBusinessFileDao{M: d.M.Args(args...)}
  121. }
  122. // Handler calls each of "handlers" on current Model and returns a new Model.
  123. // ModelHandler is a function that handles given Model and returns a new Model that is custom modified.
  124. func (d *ProjBusinessFileDao) Handler(handlers ...gdb.ModelHandler) *ProjBusinessFileDao {
  125. return &ProjBusinessFileDao{M: d.M.Handler(handlers...)}
  126. }
  127. // LeftJoin does "LEFT 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").LeftJoin("user_detail", "user_detail.uid=user.uid")
  131. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  132. func (d *ProjBusinessFileDao) LeftJoin(table ...string) *ProjBusinessFileDao {
  133. return &ProjBusinessFileDao{M: d.M.LeftJoin(table...)}
  134. }
  135. // RightJoin does "RIGHT 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").RightJoin("user_detail", "user_detail.uid=user.uid")
  139. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  140. func (d *ProjBusinessFileDao) RightJoin(table ...string) *ProjBusinessFileDao {
  141. return &ProjBusinessFileDao{M: d.M.RightJoin(table...)}
  142. }
  143. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  144. // The parameter <table> can be joined table and its joined condition,
  145. // and also with its alias name, like:
  146. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  147. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  148. func (d *ProjBusinessFileDao) InnerJoin(table ...string) *ProjBusinessFileDao {
  149. return &ProjBusinessFileDao{M: d.M.InnerJoin(table...)}
  150. }
  151. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  152. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  153. func (d *ProjBusinessFileDao) Fields(fieldNamesOrMapStruct ...interface{}) *ProjBusinessFileDao {
  154. return &ProjBusinessFileDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
  155. }
  156. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  157. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  158. func (d *ProjBusinessFileDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *ProjBusinessFileDao {
  159. return &ProjBusinessFileDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
  160. }
  161. // FieldCount formats and appends commonly used field "COUNT(column)" to the select fields of model.
  162. func (d *ProjBusinessFileDao) FieldCount(column string, as ...string) *ProjBusinessFileDao {
  163. return &ProjBusinessFileDao{M: d.M.FieldCount(column, as...)}
  164. }
  165. // FieldSum formats and appends commonly used field "SUM(column)" to the select fields of model.
  166. func (d *ProjBusinessFileDao) FieldSum(column string, as ...string) *ProjBusinessFileDao {
  167. return &ProjBusinessFileDao{M: d.M.FieldSum(column, as...)}
  168. }
  169. // FieldMin formats and appends commonly used field "MIN(column)" to the select fields of model.
  170. func (d *ProjBusinessFileDao) FieldMin(column string, as ...string) *ProjBusinessFileDao {
  171. return &ProjBusinessFileDao{M: d.M.FieldMin(column, as...)}
  172. }
  173. // FieldMax formats and appends commonly used field "MAX(column)" to the select fields of model.
  174. func (d *ProjBusinessFileDao) FieldMax(column string, as ...string) *ProjBusinessFileDao {
  175. return &ProjBusinessFileDao{M: d.M.FieldMax(column, as...)}
  176. }
  177. // FieldAvg formats and appends commonly used field "AVG(column)" to the select fields of model.
  178. func (d *ProjBusinessFileDao) FieldAvg(column string, as ...string) *ProjBusinessFileDao {
  179. return &ProjBusinessFileDao{M: d.M.FieldAvg(column, as...)}
  180. }
  181. // Option adds extra operation option for the model.
  182. // Deprecated, use separate operations instead.
  183. func (d *ProjBusinessFileDao) Option(option int) *ProjBusinessFileDao {
  184. return &ProjBusinessFileDao{M: d.M.Option(option)}
  185. }
  186. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  187. // the data and where attributes for empty values.
  188. func (d *ProjBusinessFileDao) OmitEmpty() *ProjBusinessFileDao {
  189. return &ProjBusinessFileDao{M: d.M.OmitEmpty()}
  190. }
  191. // OmitEmptyWhere sets optionOmitEmptyWhere option for the model, which automatically filers
  192. // the Where/Having parameters for "empty" values.
  193. func (d *ProjBusinessFileDao) OmitEmptyWhere() *ProjBusinessFileDao {
  194. return &ProjBusinessFileDao{M: d.M.OmitEmptyWhere()}
  195. }
  196. // OmitEmptyData sets optionOmitEmptyData option for the model, which automatically filers
  197. // the Data parameters for "empty" values.
  198. func (d *ProjBusinessFileDao) OmitEmptyData() *ProjBusinessFileDao {
  199. return &ProjBusinessFileDao{M: d.M.OmitEmptyData()}
  200. }
  201. // OmitNil sets optionOmitNil option for the model, which automatically filers
  202. // the data and where parameters for "nil" values.
  203. func (d *ProjBusinessFileDao) OmitNil() *ProjBusinessFileDao {
  204. return &ProjBusinessFileDao{M: d.M.OmitNil()}
  205. }
  206. // OmitNilWhere sets optionOmitNilWhere option for the model, which automatically filers
  207. // the Where/Having parameters for "nil" values.
  208. func (d *ProjBusinessFileDao) OmitNilWhere() *ProjBusinessFileDao {
  209. return &ProjBusinessFileDao{M: d.M.OmitNilWhere()}
  210. }
  211. // OmitNilData sets optionOmitNilData option for the model, which automatically filers
  212. // the Data parameters for "nil" values.
  213. func (d *ProjBusinessFileDao) OmitNilData() *ProjBusinessFileDao {
  214. return &ProjBusinessFileDao{M: d.M.OmitNilData()}
  215. }
  216. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  217. // Note that this function supports only single table operations.
  218. // Deprecated, filter feature is automatically enabled from GoFrame v1.16.0, it is so no longer used.
  219. func (d *ProjBusinessFileDao) Filter() *ProjBusinessFileDao {
  220. return &ProjBusinessFileDao{M: d.M.Filter()}
  221. }
  222. // Where sets the condition statement for the model. The parameter <where> can be type of
  223. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  224. // multiple conditions will be joined into where statement using "AND".
  225. // Eg:
  226. // Where("uid=10000")
  227. // Where("uid", 10000)
  228. // Where("money>? AND name like ?", 99999, "vip_%")
  229. // Where("uid", 1).Where("name", "john")
  230. // Where("status IN (?)", g.Slice{1,2,3})
  231. // Where("age IN(?,?)", 18, 50)
  232. // Where(User{ Id : 1, UserName : "john"})
  233. func (d *ProjBusinessFileDao) Where(where interface{}, args ...interface{}) *ProjBusinessFileDao {
  234. return &ProjBusinessFileDao{M: d.M.Where(where, args...)}
  235. }
  236. // WherePri does the same logic as M.Where except that if the parameter <where>
  237. // is a single condition like int/string/float/slice, it treats the condition as the primary
  238. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  239. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  240. // as string "123".
  241. func (d *ProjBusinessFileDao) WherePri(where interface{}, args ...interface{}) *ProjBusinessFileDao {
  242. return &ProjBusinessFileDao{M: d.M.WherePri(where, args...)}
  243. }
  244. // Having sets the having statement for the model.
  245. // The parameters of this function usage are as the same as function Where.
  246. // See Where.
  247. func (d *ProjBusinessFileDao) Having(having interface{}, args ...interface{}) *ProjBusinessFileDao {
  248. return &ProjBusinessFileDao{M: d.M.Having(having, args...)}
  249. }
  250. // Wheref builds condition string using fmt.Sprintf and arguments.
  251. // Note that if the number of "args" is more than the place holder in "format",
  252. // the extra "args" will be used as the where condition arguments of the Model.
  253. func (d *ProjBusinessFileDao) Wheref(format string, args ...interface{}) *ProjBusinessFileDao {
  254. return &ProjBusinessFileDao{M: d.M.Wheref(format, args...)}
  255. }
  256. // WhereLT builds "column < value" statement.
  257. func (d *ProjBusinessFileDao) WhereLT(column string, value interface{}) *ProjBusinessFileDao {
  258. return &ProjBusinessFileDao{M: d.M.WhereLT(column, value)}
  259. }
  260. // WhereLTE builds "column <= value" statement.
  261. func (d *ProjBusinessFileDao) WhereLTE(column string, value interface{}) *ProjBusinessFileDao {
  262. return &ProjBusinessFileDao{M: d.M.WhereLTE(column, value)}
  263. }
  264. // WhereGT builds "column > value" statement.
  265. func (d *ProjBusinessFileDao) WhereGT(column string, value interface{}) *ProjBusinessFileDao {
  266. return &ProjBusinessFileDao{M: d.M.WhereGT(column, value)}
  267. }
  268. // WhereGTE builds "column >= value" statement.
  269. func (d *ProjBusinessFileDao) WhereGTE(column string, value interface{}) *ProjBusinessFileDao {
  270. return &ProjBusinessFileDao{M: d.M.WhereGTE(column, value)}
  271. }
  272. // WhereBetween builds "column BETWEEN min AND max" statement.
  273. func (d *ProjBusinessFileDao) WhereBetween(column string, min, max interface{}) *ProjBusinessFileDao {
  274. return &ProjBusinessFileDao{M: d.M.WhereBetween(column, min, max)}
  275. }
  276. // WhereLike builds "column LIKE like" statement.
  277. func (d *ProjBusinessFileDao) WhereLike(column string, like interface{}) *ProjBusinessFileDao {
  278. return &ProjBusinessFileDao{M: d.M.WhereLike(column, like)}
  279. }
  280. // WhereIn builds "column IN (in)" statement.
  281. func (d *ProjBusinessFileDao) WhereIn(column string, in interface{}) *ProjBusinessFileDao {
  282. return &ProjBusinessFileDao{M: d.M.WhereIn(column, in)}
  283. }
  284. // WhereNull builds "columns[0] IS NULL AND columns[1] IS NULL ..." statement.
  285. func (d *ProjBusinessFileDao) WhereNull(columns ...string) *ProjBusinessFileDao {
  286. return &ProjBusinessFileDao{M: d.M.WhereNull(columns...)}
  287. }
  288. // WhereNotBetween builds "column NOT BETWEEN min AND max" statement.
  289. func (d *ProjBusinessFileDao) WhereNotBetween(column string, min, max interface{}) *ProjBusinessFileDao {
  290. return &ProjBusinessFileDao{M: d.M.WhereNotBetween(column, min, max)}
  291. }
  292. // WhereNotLike builds "column NOT LIKE like" statement.
  293. func (d *ProjBusinessFileDao) WhereNotLike(column string, like interface{}) *ProjBusinessFileDao {
  294. return &ProjBusinessFileDao{M: d.M.WhereNotLike(column, like)}
  295. }
  296. // WhereNot builds "column != value" statement.
  297. func (d *ProjBusinessFileDao) WhereNot(column string, value interface{}) *ProjBusinessFileDao {
  298. return &ProjBusinessFileDao{M: d.M.WhereNot(column, value)}
  299. }
  300. // WhereNotIn builds "column NOT IN (in)" statement.
  301. func (d *ProjBusinessFileDao) WhereNotIn(column string, in interface{}) *ProjBusinessFileDao {
  302. return &ProjBusinessFileDao{M: d.M.WhereNotIn(column, in)}
  303. }
  304. // WhereNotNull builds "columns[0] IS NOT NULL AND columns[1] IS NOT NULL ..." statement.
  305. func (d *ProjBusinessFileDao) WhereNotNull(columns ...string) *ProjBusinessFileDao {
  306. return &ProjBusinessFileDao{M: d.M.WhereNotNull(columns...)}
  307. }
  308. // WhereOr adds "OR" condition to the where statement.
  309. func (d *ProjBusinessFileDao) WhereOr(where interface{}, args ...interface{}) *ProjBusinessFileDao {
  310. return &ProjBusinessFileDao{M: d.M.WhereOr(where, args...)}
  311. }
  312. // WhereOrf builds "OR" condition string using fmt.Sprintf and arguments.
  313. func (d *ProjBusinessFileDao) WhereOrf(format string, args ...interface{}) *ProjBusinessFileDao {
  314. return &ProjBusinessFileDao{M: d.M.WhereOrf(format, args...)}
  315. }
  316. // WhereOrLT builds "column < value" statement in "OR" conditions..
  317. func (d *ProjBusinessFileDao) WhereOrLT(column string, value interface{}) *ProjBusinessFileDao {
  318. return &ProjBusinessFileDao{M: d.M.WhereOrLT(column, value)}
  319. }
  320. // WhereOrLTE builds "column <= value" statement in "OR" conditions..
  321. func (d *ProjBusinessFileDao) WhereOrLTE(column string, value interface{}) *ProjBusinessFileDao {
  322. return &ProjBusinessFileDao{M: d.M.WhereOrLTE(column, value)}
  323. }
  324. // WhereOrGT builds "column > value" statement in "OR" conditions..
  325. func (d *ProjBusinessFileDao) WhereOrGT(column string, value interface{}) *ProjBusinessFileDao {
  326. return &ProjBusinessFileDao{M: d.M.WhereOrGT(column, value)}
  327. }
  328. // WhereOrGTE builds "column >= value" statement in "OR" conditions..
  329. func (d *ProjBusinessFileDao) WhereOrGTE(column string, value interface{}) *ProjBusinessFileDao {
  330. return &ProjBusinessFileDao{M: d.M.WhereOrGTE(column, value)}
  331. }
  332. // WhereOrBetween builds "column BETWEEN min AND max" statement in "OR" conditions.
  333. func (d *ProjBusinessFileDao) WhereOrBetween(column string, min, max interface{}) *ProjBusinessFileDao {
  334. return &ProjBusinessFileDao{M: d.M.WhereOrBetween(column, min, max)}
  335. }
  336. // WhereOrLike builds "column LIKE like" statement in "OR" conditions.
  337. func (d *ProjBusinessFileDao) WhereOrLike(column string, like interface{}) *ProjBusinessFileDao {
  338. return &ProjBusinessFileDao{M: d.M.WhereOrLike(column, like)}
  339. }
  340. // WhereOrIn builds "column IN (in)" statement in "OR" conditions.
  341. func (d *ProjBusinessFileDao) WhereOrIn(column string, in interface{}) *ProjBusinessFileDao {
  342. return &ProjBusinessFileDao{M: d.M.WhereOrIn(column, in)}
  343. }
  344. // WhereOrNull builds "columns[0] IS NULL OR columns[1] IS NULL ..." statement in "OR" conditions.
  345. func (d *ProjBusinessFileDao) WhereOrNull(columns ...string) *ProjBusinessFileDao {
  346. return &ProjBusinessFileDao{M: d.M.WhereOrNull(columns...)}
  347. }
  348. // WhereOrNotBetween builds "column NOT BETWEEN min AND max" statement in "OR" conditions.
  349. func (d *ProjBusinessFileDao) WhereOrNotBetween(column string, min, max interface{}) *ProjBusinessFileDao {
  350. return &ProjBusinessFileDao{M: d.M.WhereOrNotBetween(column, min, max)}
  351. }
  352. // WhereOrNotLike builds "column NOT LIKE like" statement in "OR" conditions.
  353. func (d *ProjBusinessFileDao) WhereOrNotLike(column string, like interface{}) *ProjBusinessFileDao {
  354. return &ProjBusinessFileDao{M: d.M.WhereOrNotLike(column, like)}
  355. }
  356. // WhereOrNotIn builds "column NOT IN (in)" statement.
  357. func (d *ProjBusinessFileDao) WhereOrNotIn(column string, in interface{}) *ProjBusinessFileDao {
  358. return &ProjBusinessFileDao{M: d.M.WhereOrNotIn(column, in)}
  359. }
  360. // WhereOrNotNull builds "columns[0] IS NOT NULL OR columns[1] IS NOT NULL ..." statement in "OR" conditions.
  361. func (d *ProjBusinessFileDao) WhereOrNotNull(columns ...string) *ProjBusinessFileDao {
  362. return &ProjBusinessFileDao{M: d.M.WhereOrNotNull(columns...)}
  363. }
  364. // Group sets the "GROUP BY" statement for the model.
  365. func (d *ProjBusinessFileDao) Group(groupBy ...string) *ProjBusinessFileDao {
  366. return &ProjBusinessFileDao{M: d.M.Group(groupBy...)}
  367. }
  368. // And adds "AND" condition to the where statement.
  369. // Deprecated, use Where instead.
  370. func (d *ProjBusinessFileDao) And(where interface{}, args ...interface{}) *ProjBusinessFileDao {
  371. return &ProjBusinessFileDao{M: d.M.And(where, args...)}
  372. }
  373. // Or adds "OR" condition to the where statement.
  374. // Deprecated, use WhereOr instead.
  375. func (d *ProjBusinessFileDao) Or(where interface{}, args ...interface{}) *ProjBusinessFileDao {
  376. return &ProjBusinessFileDao{M: d.M.Or(where, args...)}
  377. }
  378. // GroupBy sets the "GROUP BY" statement for the model.
  379. func (d *ProjBusinessFileDao) GroupBy(groupBy string) *ProjBusinessFileDao {
  380. return &ProjBusinessFileDao{M: d.M.Group(groupBy)}
  381. }
  382. // Order sets the "ORDER BY" statement for the model.
  383. func (d *ProjBusinessFileDao) Order(orderBy ...string) *ProjBusinessFileDao {
  384. return &ProjBusinessFileDao{M: d.M.Order(orderBy...)}
  385. }
  386. // OrderAsc sets the "ORDER BY xxx ASC" statement for the model.
  387. func (d *ProjBusinessFileDao) OrderAsc(column string) *ProjBusinessFileDao {
  388. return &ProjBusinessFileDao{M: d.M.OrderAsc(column)}
  389. }
  390. // OrderDesc sets the "ORDER BY xxx DESC" statement for the model.
  391. func (d *ProjBusinessFileDao) OrderDesc(column string) *ProjBusinessFileDao {
  392. return &ProjBusinessFileDao{M: d.M.OrderDesc(column)}
  393. }
  394. // OrderRandom sets the "ORDER BY RANDOM()" statement for the model.
  395. func (d *ProjBusinessFileDao) OrderRandom() *ProjBusinessFileDao {
  396. return &ProjBusinessFileDao{M: d.M.OrderRandom()}
  397. }
  398. // OrderBy is alias of Model.Order.
  399. // See Model.Order.
  400. // Deprecated, use Order instead.
  401. func (d *ProjBusinessFileDao) OrderBy(orderBy string) *ProjBusinessFileDao {
  402. return &ProjBusinessFileDao{M: d.M.Order(orderBy)}
  403. }
  404. // Limit sets the "LIMIT" statement for the model.
  405. // The parameter <limit> can be either one or two number, if passed two number is passed,
  406. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  407. // statement.
  408. func (d *ProjBusinessFileDao) Limit(limit ...int) *ProjBusinessFileDao {
  409. return &ProjBusinessFileDao{M: d.M.Limit(limit...)}
  410. }
  411. // Offset sets the "OFFSET" statement for the model.
  412. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  413. func (d *ProjBusinessFileDao) Offset(offset int) *ProjBusinessFileDao {
  414. return &ProjBusinessFileDao{M: d.M.Offset(offset)}
  415. }
  416. // Distinct forces the query to only return distinct results.
  417. func (d *ProjBusinessFileDao) Distinct() *ProjBusinessFileDao {
  418. return &ProjBusinessFileDao{M: d.M.Distinct()}
  419. }
  420. // Page sets the paging number for the model.
  421. // The parameter <page> is started from 1 for paging.
  422. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  423. func (d *ProjBusinessFileDao) Page(page, limit int) *ProjBusinessFileDao {
  424. return &ProjBusinessFileDao{M: d.M.Page(page, limit)}
  425. }
  426. // Batch sets the batch operation number for the model.
  427. func (d *ProjBusinessFileDao) Batch(batch int) *ProjBusinessFileDao {
  428. return &ProjBusinessFileDao{M: d.M.Batch(batch)}
  429. }
  430. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  431. // if there's another same sql request, it just reads and returns the result from cache, it
  432. // but not committed and executed into the database.
  433. //
  434. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  435. // If the parameter <duration> = 0, which means it never expires.
  436. // If the parameter <duration> > 0, which means it expires after <duration>.
  437. //
  438. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  439. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  440. //
  441. // Note that, the cache feature is disabled if the model is operating on a transaction.
  442. func (d *ProjBusinessFileDao) Cache(duration time.Duration, name ...string) *ProjBusinessFileDao {
  443. return &ProjBusinessFileDao{M: d.M.Cache(duration, name...)}
  444. }
  445. // Data sets the operation data for the model.
  446. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  447. // Eg:
  448. // Data("uid=10000")
  449. // Data("uid", 10000)
  450. // Data(g.Map{"uid": 10000, "name":"john"})
  451. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  452. func (d *ProjBusinessFileDao) Data(data ...interface{}) *ProjBusinessFileDao {
  453. return &ProjBusinessFileDao{M: d.M.Data(data...)}
  454. }
  455. // All does "SELECT FROM ..." statement for the model.
  456. // It retrieves the records from table and returns the result as []*model.ProjBusinessFile.
  457. // It returns nil if there's no record retrieved with the given conditions from table.
  458. //
  459. // The optional parameter <where> is the same as the parameter of M.Where function,
  460. // see M.Where.
  461. func (d *ProjBusinessFileDao) All(where ...interface{}) ([]*model.ProjBusinessFile, error) {
  462. all, err := d.M.All(where...)
  463. if err != nil {
  464. return nil, err
  465. }
  466. var entities []*model.ProjBusinessFile
  467. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  468. return nil, err
  469. }
  470. return entities, nil
  471. }
  472. // One retrieves one record from table and returns the result as *model.ProjBusinessFile.
  473. // It returns nil if there's no record retrieved with the given conditions from table.
  474. //
  475. // The optional parameter <where> is the same as the parameter of M.Where function,
  476. // see M.Where.
  477. func (d *ProjBusinessFileDao) One(where ...interface{}) (*model.ProjBusinessFile, error) {
  478. one, err := d.M.One(where...)
  479. if err != nil {
  480. return nil, err
  481. }
  482. var entity *model.ProjBusinessFile
  483. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  484. return nil, err
  485. }
  486. return entity, nil
  487. }
  488. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  489. // Also see M.WherePri and M.One.
  490. func (d *ProjBusinessFileDao) FindOne(where ...interface{}) (*model.ProjBusinessFile, error) {
  491. one, err := d.M.FindOne(where...)
  492. if err != nil {
  493. return nil, err
  494. }
  495. var entity *model.ProjBusinessFile
  496. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  497. return nil, err
  498. }
  499. return entity, nil
  500. }
  501. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  502. // Also see M.WherePri and M.All.
  503. func (d *ProjBusinessFileDao) FindAll(where ...interface{}) ([]*model.ProjBusinessFile, error) {
  504. all, err := d.M.FindAll(where...)
  505. if err != nil {
  506. return nil, err
  507. }
  508. var entities []*model.ProjBusinessFile
  509. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  510. return nil, err
  511. }
  512. return entities, nil
  513. }
  514. // Struct retrieves one record from table and converts it into given struct.
  515. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  516. // it can create the struct internally during converting.
  517. //
  518. // The optional parameter <where> is the same as the parameter of Model.Where function,
  519. // see Model.Where.
  520. //
  521. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  522. // from table and <pointer> is not nil.
  523. //
  524. // Eg:
  525. // user := new(User)
  526. // err := dao.User.Where("id", 1).Struct(user)
  527. //
  528. // user := (*User)(nil)
  529. // err := dao.User.Where("id", 1).Struct(&user)
  530. func (d *ProjBusinessFileDao) Struct(pointer interface{}, where ...interface{}) error {
  531. return d.M.Struct(pointer, where...)
  532. }
  533. // Structs retrieves records from table and converts them into given struct slice.
  534. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  535. // slice internally during converting.
  536. //
  537. // The optional parameter <where> is the same as the parameter of Model.Where function,
  538. // see Model.Where.
  539. //
  540. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  541. // from table and <pointer> is not empty.
  542. //
  543. // Eg:
  544. // users := ([]User)(nil)
  545. // err := dao.User.Structs(&users)
  546. //
  547. // users := ([]*User)(nil)
  548. // err := dao.User.Structs(&users)
  549. func (d *ProjBusinessFileDao) Structs(pointer interface{}, where ...interface{}) error {
  550. return d.M.Structs(pointer, where...)
  551. }
  552. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  553. // It calls function Struct if <pointer> is type of *struct/**struct.
  554. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  555. //
  556. // The optional parameter <where> is the same as the parameter of Model.Where function,
  557. // see Model.Where.
  558. //
  559. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  560. //
  561. // Eg:
  562. // user := new(User)
  563. // err := dao.User.Where("id", 1).Scan(user)
  564. //
  565. // user := (*User)(nil)
  566. // err := dao.User.Where("id", 1).Scan(&user)
  567. //
  568. // users := ([]User)(nil)
  569. // err := dao.User.Scan(&users)
  570. //
  571. // users := ([]*User)(nil)
  572. // err := dao.User.Scan(&users)
  573. func (d *ProjBusinessFileDao) Scan(pointer interface{}, where ...interface{}) error {
  574. return d.M.Scan(pointer, where...)
  575. }
  576. // Chunk iterates the table with given size and callback function.
  577. func (d *ProjBusinessFileDao) Chunk(limit int, callback func(entities []*model.ProjBusinessFile, err error) bool) {
  578. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  579. var entities []*model.ProjBusinessFile
  580. err = result.Structs(&entities)
  581. if err == sql.ErrNoRows {
  582. return false
  583. }
  584. return callback(entities, err)
  585. })
  586. }
  587. // LockUpdate sets the lock for update for current operation.
  588. func (d *ProjBusinessFileDao) LockUpdate() *ProjBusinessFileDao {
  589. return &ProjBusinessFileDao{M: d.M.LockUpdate()}
  590. }
  591. // LockShared sets the lock in share mode for current operation.
  592. func (d *ProjBusinessFileDao) LockShared() *ProjBusinessFileDao {
  593. return &ProjBusinessFileDao{M: d.M.LockShared()}
  594. }
  595. // Unscoped enables/disables the soft deleting feature.
  596. func (d *ProjBusinessFileDao) Unscoped() *ProjBusinessFileDao {
  597. return &ProjBusinessFileDao{M: d.M.Unscoped()}
  598. }
  599. // DataScope enables the DataScope feature.
  600. func (d *ProjBusinessFileDao) DataScope(ctx context.Context, userCol ...string) *ProjBusinessFileDao {
  601. cs := ctx.Value("contextService")
  602. dataScope := gconv.Map(cs)["dataScope"].(g.Map)
  603. if dataScope != nil {
  604. userIds, ok := dataScope["userIds"]
  605. delete(dataScope, "userIds")
  606. var columns []string
  607. var values []interface{}
  608. if ok && userIds != "-1" {
  609. column := "created_by"
  610. if len(userCol) == 1 {
  611. column = userCol[0]
  612. }
  613. dataScope[column] = userIds
  614. if d.Table == "sys_user" {
  615. dataScope["id"] = userIds
  616. }
  617. }
  618. for k, v := range dataScope {
  619. if ok, _ := d.M.HasField(k); ok {
  620. columns = append(columns, k+" IN (?) ")
  621. values = append(values, v)
  622. }
  623. }
  624. whereSql := strings.Join(columns, " OR ")
  625. return &ProjBusinessFileDao{M: d.M.Where(whereSql, values).Ctx(ctx)}
  626. }
  627. return d
  628. }