cust_customer_dynamics.go 17 KB

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