plat_followup.go 35 KB

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