proj_business_file.go 32 KB

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