plat_followup.go 32 KB

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