plat_followup_file.go 32 KB

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