plat_followup.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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. "dashoo.cn/micro/app/model/plat"
  8. "database/sql"
  9. "github.com/gogf/gf/database/gdb"
  10. "github.com/gogf/gf/frame/g"
  11. "github.com/gogf/gf/frame/gmvc"
  12. "time"
  13. )
  14. // PlatFollowupDao is the manager for logic model data accessing
  15. // and custom defined data operations functions management.
  16. type PlatFollowupDao struct {
  17. gmvc.M
  18. DB gdb.DB
  19. Table string
  20. Columns platFollowupColumns
  21. }
  22. // PlatFollowupColumns defines and stores column names for table plat_followup.
  23. type platFollowupColumns struct {
  24. Id string // 主键
  25. FollowType string // 跟进类型(10电话20邮件30拜访)
  26. FollowDate string // 跟进时间
  27. FollowContent string // 跟进内容
  28. TargetId string // 跟进对象ID
  29. TargetType string // 跟进对象类型(10客户,20项目,30合同,40回款)
  30. TargetName string // 跟进对象
  31. CustId string // 关联客户
  32. CustName string // 客户名称
  33. ContactsId string // 关联联系人
  34. ContactsName string // 联系人姓名
  35. Reminders string // 提醒对象
  36. NextTime string // 下次联系时间
  37. Remark string // 备注
  38. CreatedBy string // 创建者
  39. CreatedName string // 创建人
  40. CreatedTime string // 创建时间
  41. UpdatedBy string // 更新者
  42. UpdatedName string // 更新人
  43. UpdatedTime string // 更新时间
  44. DeletedTime string // 删除时间
  45. }
  46. var (
  47. // PlatFollowup is globally public accessible object for table plat_followup operations.
  48. PlatFollowup = PlatFollowupDao{
  49. M: g.DB("default").Model("plat_followup").Safe(),
  50. DB: g.DB("default"),
  51. Table: "plat_followup",
  52. Columns: platFollowupColumns{
  53. Id: "id",
  54. FollowType: "follow_type",
  55. FollowDate: "follow_date",
  56. FollowContent: "follow_content",
  57. TargetId: "target_id",
  58. TargetType: "target_type",
  59. TargetName: "target_name",
  60. CustId: "cust_id",
  61. CustName: "cust_name",
  62. ContactsId: "contacts_id",
  63. ContactsName: "contacts_name",
  64. Reminders: "reminders",
  65. NextTime: "next_time",
  66. Remark: "remark",
  67. CreatedBy: "created_by",
  68. CreatedName: "created_name",
  69. CreatedTime: "created_time",
  70. UpdatedBy: "updated_by",
  71. UpdatedName: "updated_name",
  72. UpdatedTime: "updated_time",
  73. DeletedTime: "deleted_time",
  74. },
  75. }
  76. )
  77. func NewPlatFollowupDao(tenant string) PlatFollowupDao {
  78. var dao PlatFollowupDao
  79. dao = PlatFollowupDao{
  80. M: g.DB(tenant).Model("plat_followup").Safe(),
  81. DB: g.DB(tenant),
  82. Table: "plat_followup",
  83. Columns: platFollowupColumns{
  84. Id: "id",
  85. FollowType: "follow_type",
  86. FollowDate: "follow_date",
  87. FollowContent: "follow_content",
  88. TargetId: "target_id",
  89. TargetType: "target_type",
  90. TargetName: "target_name",
  91. CustId: "cust_id",
  92. CustName: "cust_name",
  93. ContactsId: "contacts_id",
  94. ContactsName: "contacts_name",
  95. Reminders: "reminders",
  96. NextTime: "next_time",
  97. Remark: "remark",
  98. CreatedBy: "created_by",
  99. CreatedName: "created_name",
  100. CreatedTime: "created_time",
  101. UpdatedBy: "updated_by",
  102. UpdatedName: "updated_name",
  103. UpdatedTime: "updated_time",
  104. DeletedTime: "deleted_time",
  105. },
  106. }
  107. return dao
  108. }
  109. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  110. // of current DB object and with given context in it.
  111. // Note that this returned DB object can be used only once, so do not assign it to
  112. // a global or package variable for long using.
  113. func (d *PlatFollowupDao) Ctx(ctx context.Context) *PlatFollowupDao {
  114. return &PlatFollowupDao{M: d.M.Ctx(ctx)}
  115. }
  116. // As sets an alias name for current table.
  117. func (d *PlatFollowupDao) As(as string) *PlatFollowupDao {
  118. return &PlatFollowupDao{M: d.M.As(as)}
  119. }
  120. // TX sets the transaction for current operation.
  121. func (d *PlatFollowupDao) TX(tx *gdb.TX) *PlatFollowupDao {
  122. return &PlatFollowupDao{M: d.M.TX(tx)}
  123. }
  124. // Master marks the following operation on master node.
  125. func (d *PlatFollowupDao) Master() *PlatFollowupDao {
  126. return &PlatFollowupDao{M: d.M.Master()}
  127. }
  128. // Slave marks the following operation on slave node.
  129. // Note that it makes sense only if there's any slave node configured.
  130. func (d *PlatFollowupDao) Slave() *PlatFollowupDao {
  131. return &PlatFollowupDao{M: d.M.Slave()}
  132. }
  133. // Args sets custom arguments for model operation.
  134. func (d *PlatFollowupDao) Args(args ...interface{}) *PlatFollowupDao {
  135. return &PlatFollowupDao{M: d.M.Args(args...)}
  136. }
  137. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  138. // The parameter <table> can be joined table and its joined condition,
  139. // and also with its alias name, like:
  140. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  141. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  142. func (d *PlatFollowupDao) LeftJoin(table ...string) *PlatFollowupDao {
  143. return &PlatFollowupDao{M: d.M.LeftJoin(table...)}
  144. }
  145. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  146. // The parameter <table> can be joined table and its joined condition,
  147. // and also with its alias name, like:
  148. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  149. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  150. func (d *PlatFollowupDao) RightJoin(table ...string) *PlatFollowupDao {
  151. return &PlatFollowupDao{M: d.M.RightJoin(table...)}
  152. }
  153. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  154. // The parameter <table> can be joined table and its joined condition,
  155. // and also with its alias name, like:
  156. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  157. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  158. func (d *PlatFollowupDao) InnerJoin(table ...string) *PlatFollowupDao {
  159. return &PlatFollowupDao{M: d.M.InnerJoin(table...)}
  160. }
  161. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  162. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  163. func (d *PlatFollowupDao) Fields(fieldNamesOrMapStruct ...interface{}) *PlatFollowupDao {
  164. return &PlatFollowupDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
  165. }
  166. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  167. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  168. func (d *PlatFollowupDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *PlatFollowupDao {
  169. return &PlatFollowupDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
  170. }
  171. // Option sets the extra operation option for the model.
  172. func (d *PlatFollowupDao) Option(option int) *PlatFollowupDao {
  173. return &PlatFollowupDao{M: d.M.Option(option)}
  174. }
  175. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  176. // the data and where attributes for empty values.
  177. func (d *PlatFollowupDao) OmitEmpty() *PlatFollowupDao {
  178. return &PlatFollowupDao{M: d.M.OmitEmpty()}
  179. }
  180. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  181. func (d *PlatFollowupDao) Filter() *PlatFollowupDao {
  182. return &PlatFollowupDao{M: d.M.Filter()}
  183. }
  184. // Where sets the condition statement for the model. The parameter <where> can be type of
  185. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  186. // multiple conditions will be joined into where statement using "AND".
  187. // Eg:
  188. // Where("uid=10000")
  189. // Where("uid", 10000)
  190. // Where("money>? AND name like ?", 99999, "vip_%")
  191. // Where("uid", 1).Where("name", "john")
  192. // Where("status IN (?)", g.Slice{1,2,3})
  193. // Where("age IN(?,?)", 18, 50)
  194. // Where(User{ Id : 1, UserName : "john"})
  195. func (d *PlatFollowupDao) Where(where interface{}, args ...interface{}) *PlatFollowupDao {
  196. return &PlatFollowupDao{M: d.M.Where(where, args...)}
  197. }
  198. // WherePri does the same logic as M.Where except that if the parameter <where>
  199. // is a single condition like int/string/float/slice, it treats the condition as the primary
  200. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  201. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  202. // as string "123".
  203. func (d *PlatFollowupDao) WherePri(where interface{}, args ...interface{}) *PlatFollowupDao {
  204. return &PlatFollowupDao{M: d.M.WherePri(where, args...)}
  205. }
  206. // And adds "AND" condition to the where statement.
  207. func (d *PlatFollowupDao) And(where interface{}, args ...interface{}) *PlatFollowupDao {
  208. return &PlatFollowupDao{M: d.M.And(where, args...)}
  209. }
  210. // Or adds "OR" condition to the where statement.
  211. func (d *PlatFollowupDao) Or(where interface{}, args ...interface{}) *PlatFollowupDao {
  212. return &PlatFollowupDao{M: d.M.Or(where, args...)}
  213. }
  214. // Group sets the "GROUP BY" statement for the model.
  215. func (d *PlatFollowupDao) Group(groupBy string) *PlatFollowupDao {
  216. return &PlatFollowupDao{M: d.M.Group(groupBy)}
  217. }
  218. // Order sets the "ORDER BY" statement for the model.
  219. func (d *PlatFollowupDao) Order(orderBy ...string) *PlatFollowupDao {
  220. return &PlatFollowupDao{M: d.M.Order(orderBy...)}
  221. }
  222. // Limit sets the "LIMIT" statement for the model.
  223. // The parameter <limit> can be either one or two number, if passed two number is passed,
  224. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  225. // statement.
  226. func (d *PlatFollowupDao) Limit(limit ...int) *PlatFollowupDao {
  227. return &PlatFollowupDao{M: d.M.Limit(limit...)}
  228. }
  229. // Offset sets the "OFFSET" statement for the model.
  230. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  231. func (d *PlatFollowupDao) Offset(offset int) *PlatFollowupDao {
  232. return &PlatFollowupDao{M: d.M.Offset(offset)}
  233. }
  234. // Page sets the paging number for the model.
  235. // The parameter <page> is started from 1 for paging.
  236. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  237. func (d *PlatFollowupDao) Page(page, limit int) *PlatFollowupDao {
  238. return &PlatFollowupDao{M: d.M.Page(page, limit)}
  239. }
  240. // Batch sets the batch operation number for the model.
  241. func (d *PlatFollowupDao) Batch(batch int) *PlatFollowupDao {
  242. return &PlatFollowupDao{M: d.M.Batch(batch)}
  243. }
  244. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  245. // if there's another same sql request, it just reads and returns the result from cache, it
  246. // but not committed and executed into the database.
  247. //
  248. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  249. // If the parameter <duration> = 0, which means it never expires.
  250. // If the parameter <duration> > 0, which means it expires after <duration>.
  251. //
  252. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  253. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  254. //
  255. // Note that, the cache feature is disabled if the model is operating on a transaction.
  256. func (d *PlatFollowupDao) Cache(duration time.Duration, name ...string) *PlatFollowupDao {
  257. return &PlatFollowupDao{M: d.M.Cache(duration, name...)}
  258. }
  259. // Data sets the operation data for the model.
  260. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  261. // Eg:
  262. // Data("uid=10000")
  263. // Data("uid", 10000)
  264. // Data(g.Map{"uid": 10000, "name":"john"})
  265. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  266. func (d *PlatFollowupDao) Data(data ...interface{}) *PlatFollowupDao {
  267. return &PlatFollowupDao{M: d.M.Data(data...)}
  268. }
  269. // All does "SELECT FROM ..." statement for the model.
  270. // It retrieves the records from table and returns the result as []*model.PlatFollowup.
  271. // It returns nil if there's no record retrieved with the given conditions from table.
  272. //
  273. // The optional parameter <where> is the same as the parameter of M.Where function,
  274. // see M.Where.
  275. func (d *PlatFollowupDao) All(where ...interface{}) ([]*plat.PlatFollowup, error) {
  276. all, err := d.M.All(where...)
  277. if err != nil {
  278. return nil, err
  279. }
  280. var entities []*plat.PlatFollowup
  281. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  282. return nil, err
  283. }
  284. return entities, nil
  285. }
  286. // One retrieves one record from table and returns the result as *model.PlatFollowup.
  287. // It returns nil if there's no record retrieved with the given conditions from table.
  288. //
  289. // The optional parameter <where> is the same as the parameter of M.Where function,
  290. // see M.Where.
  291. func (d *PlatFollowupDao) One(where ...interface{}) (*plat.PlatFollowup, error) {
  292. one, err := d.M.One(where...)
  293. if err != nil {
  294. return nil, err
  295. }
  296. var entity *plat.PlatFollowup
  297. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  298. return nil, err
  299. }
  300. return entity, nil
  301. }
  302. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  303. // Also see M.WherePri and M.One.
  304. func (d *PlatFollowupDao) FindOne(where ...interface{}) (*plat.PlatFollowup, error) {
  305. one, err := d.M.FindOne(where...)
  306. if err != nil {
  307. return nil, err
  308. }
  309. var entity *plat.PlatFollowup
  310. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  311. return nil, err
  312. }
  313. return entity, nil
  314. }
  315. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  316. // Also see M.WherePri and M.All.
  317. func (d *PlatFollowupDao) FindAll(where ...interface{}) ([]*plat.PlatFollowup, error) {
  318. all, err := d.M.FindAll(where...)
  319. if err != nil {
  320. return nil, err
  321. }
  322. var entities []*plat.PlatFollowup
  323. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  324. return nil, err
  325. }
  326. return entities, nil
  327. }
  328. // Struct retrieves one record from table and converts it into given struct.
  329. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  330. // it can create the struct internally during converting.
  331. //
  332. // The optional parameter <where> is the same as the parameter of Model.Where function,
  333. // see Model.Where.
  334. //
  335. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  336. // from table and <pointer> is not nil.
  337. //
  338. // Eg:
  339. // user := new(User)
  340. // err := dao.User.Where("id", 1).Struct(user)
  341. //
  342. // user := (*User)(nil)
  343. // err := dao.User.Where("id", 1).Struct(&user)
  344. func (d *PlatFollowupDao) Struct(pointer interface{}, where ...interface{}) error {
  345. return d.M.Struct(pointer, where...)
  346. }
  347. // Structs retrieves records from table and converts them into given struct slice.
  348. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  349. // slice internally during converting.
  350. //
  351. // The optional parameter <where> is the same as the parameter of Model.Where function,
  352. // see Model.Where.
  353. //
  354. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  355. // from table and <pointer> is not empty.
  356. //
  357. // Eg:
  358. // users := ([]User)(nil)
  359. // err := dao.User.Structs(&users)
  360. //
  361. // users := ([]*User)(nil)
  362. // err := dao.User.Structs(&users)
  363. func (d *PlatFollowupDao) Structs(pointer interface{}, where ...interface{}) error {
  364. return d.M.Structs(pointer, where...)
  365. }
  366. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  367. // It calls function Struct if <pointer> is type of *struct/**struct.
  368. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  369. //
  370. // The optional parameter <where> is the same as the parameter of Model.Where function,
  371. // see Model.Where.
  372. //
  373. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  374. //
  375. // Eg:
  376. // user := new(User)
  377. // err := dao.User.Where("id", 1).Scan(user)
  378. //
  379. // user := (*User)(nil)
  380. // err := dao.User.Where("id", 1).Scan(&user)
  381. //
  382. // users := ([]User)(nil)
  383. // err := dao.User.Scan(&users)
  384. //
  385. // users := ([]*User)(nil)
  386. // err := dao.User.Scan(&users)
  387. func (d *PlatFollowupDao) Scan(pointer interface{}, where ...interface{}) error {
  388. return d.M.Scan(pointer, where...)
  389. }
  390. // Chunk iterates the table with given size and callback function.
  391. func (d *PlatFollowupDao) Chunk(limit int, callback func(entities []*plat.PlatFollowup, err error) bool) {
  392. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  393. var entities []*plat.PlatFollowup
  394. err = result.Structs(&entities)
  395. if err == sql.ErrNoRows {
  396. return false
  397. }
  398. return callback(entities, err)
  399. })
  400. }
  401. // LockUpdate sets the lock for update for current operation.
  402. func (d *PlatFollowupDao) LockUpdate() *PlatFollowupDao {
  403. return &PlatFollowupDao{M: d.M.LockUpdate()}
  404. }
  405. // LockShared sets the lock in share mode for current operation.
  406. func (d *PlatFollowupDao) LockShared() *PlatFollowupDao {
  407. return &PlatFollowupDao{M: d.M.LockShared()}
  408. }
  409. // Unscoped enables/disables the soft deleting feature.
  410. func (d *PlatFollowupDao) Unscoped() *PlatFollowupDao {
  411. return &PlatFollowupDao{M: d.M.Unscoped()}
  412. }