plat_followup.go 34 KB

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