plat_followup.go 35 KB

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