cust_customer_contact.go 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  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. "github.com/gogf/gf/database/gdb"
  9. "github.com/gogf/gf/frame/g"
  10. "github.com/gogf/gf/frame/gmvc"
  11. "github.com/gogf/gf/util/gconv"
  12. "time"
  13. model "dashoo.cn/micro/app/model/cust"
  14. )
  15. // CustCustomerContactDao is the manager for logic model data accessing
  16. // and custom defined data operations functions management.
  17. type CustCustomerContactDao struct {
  18. gmvc.M
  19. DB gdb.DB
  20. Table string
  21. Columns custCustomerContactColumns
  22. }
  23. // CustCustomerContactColumns defines and stores column names for table cust_customer_contact.
  24. type custCustomerContactColumns struct {
  25. Id string // 主键
  26. CustId string // 关联客户
  27. CuctName string // 姓名
  28. CuctGender string // 性别(10男20女)
  29. Telephone string // 电话
  30. Wechat string // 微信
  31. Email string // 邮箱
  32. Dept string // 部门
  33. Postion string // 职位
  34. OfficeLocation string // 办公地点
  35. IsDecision string // 关键决策人(10是20否)
  36. Remark string // 备注
  37. CreatedBy string // 创建者
  38. CreatedName string // 创建人
  39. CreatedTime string // 创建时间
  40. UpdatedBy string // 更新者
  41. UpdatedName string // 更新人
  42. UpdatedTime string // 更新时间
  43. DeletedTime string // 删除时间
  44. }
  45. var (
  46. // CustCustomerContact is globally public accessible object for table cust_customer_contact operations.
  47. CustCustomerContact = CustCustomerContactDao{
  48. M: g.DB("default").Model("cust_customer_contact").Safe(),
  49. DB: g.DB("default"),
  50. Table: "cust_customer_contact",
  51. Columns: custCustomerContactColumns{
  52. Id: "id",
  53. CustId: "cust_id",
  54. CuctName: "cuct_name",
  55. CuctGender: "cuct_gender",
  56. Telephone: "telephone",
  57. Wechat: "wechat",
  58. Email: "email",
  59. Dept: "dept",
  60. Postion: "postion",
  61. OfficeLocation: "office_location",
  62. IsDecision: "is_decision",
  63. Remark: "remark",
  64. CreatedBy: "created_by",
  65. CreatedName: "created_name",
  66. CreatedTime: "created_time",
  67. UpdatedBy: "updated_by",
  68. UpdatedName: "updated_name",
  69. UpdatedTime: "updated_time",
  70. DeletedTime: "deleted_time",
  71. },
  72. }
  73. )
  74. func NewCustCustomerContactDao(tenant string) CustCustomerContactDao {
  75. var dao CustCustomerContactDao
  76. dao = CustCustomerContactDao{
  77. M: g.DB(tenant).Model("cust_customer_contact").Safe(),
  78. DB: g.DB(tenant),
  79. Table: "cust_customer_contact",
  80. Columns: custCustomerContactColumns{
  81. Id: "id",
  82. CustId: "cust_id",
  83. CuctName: "cuct_name",
  84. CuctGender: "cuct_gender",
  85. Telephone: "telephone",
  86. Wechat: "wechat",
  87. Email: "email",
  88. Dept: "dept",
  89. Postion: "postion",
  90. OfficeLocation: "office_location",
  91. IsDecision: "is_decision",
  92. Remark: "remark",
  93. CreatedBy: "created_by",
  94. CreatedName: "created_name",
  95. CreatedTime: "created_time",
  96. UpdatedBy: "updated_by",
  97. UpdatedName: "updated_name",
  98. UpdatedTime: "updated_time",
  99. DeletedTime: "deleted_time",
  100. },
  101. }
  102. return dao
  103. }
  104. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  105. // of current DB object and with given context in it.
  106. // Note that this returned DB object can be used only once, so do not assign it to
  107. // a global or package variable for long using.
  108. func (d *CustCustomerContactDao) Ctx(ctx context.Context) *CustCustomerContactDao {
  109. return &CustCustomerContactDao{M: d.M.Ctx(ctx)}
  110. }
  111. // GetCtx returns the context for current Model.
  112. // It returns "context.Background() i"s there's no context previously set.
  113. func (d *CustCustomerContactDao) GetCtx() context.Context {
  114. return d.M.GetCtx()
  115. }
  116. // As sets an alias name for current table.
  117. func (d *CustCustomerContactDao) As(as string) *CustCustomerContactDao {
  118. return &CustCustomerContactDao{M: d.M.As(as)}
  119. }
  120. // TX sets the transaction for current operation.
  121. func (d *CustCustomerContactDao) TX(tx *gdb.TX) *CustCustomerContactDao {
  122. return &CustCustomerContactDao{M: d.M.TX(tx)}
  123. }
  124. // Master marks the following operation on master node.
  125. func (d *CustCustomerContactDao) Master() *CustCustomerContactDao {
  126. return &CustCustomerContactDao{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 *CustCustomerContactDao) Slave() *CustCustomerContactDao {
  131. return &CustCustomerContactDao{M: d.M.Slave()}
  132. }
  133. // Args sets custom arguments for model operation.
  134. func (d *CustCustomerContactDao) Args(args ...interface{}) *CustCustomerContactDao {
  135. return &CustCustomerContactDao{M: d.M.Args(args...)}
  136. }
  137. // Handler calls each of "handlers" on current Model and returns a new Model.
  138. // ModelHandler is a function that handles given Model and returns a new Model that is custom modified.
  139. func (d *CustCustomerContactDao) Handler(handlers ...gdb.ModelHandler) *CustCustomerContactDao {
  140. return &CustCustomerContactDao{M: d.M.Handler(handlers...)}
  141. }
  142. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  143. // The parameter <table> can be joined table and its joined condition,
  144. // and also with its alias name, like:
  145. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  146. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  147. func (d *CustCustomerContactDao) LeftJoin(table ...string) *CustCustomerContactDao {
  148. return &CustCustomerContactDao{M: d.M.LeftJoin(table...)}
  149. }
  150. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  151. // The parameter <table> can be joined table and its joined condition,
  152. // and also with its alias name, like:
  153. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  154. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  155. func (d *CustCustomerContactDao) RightJoin(table ...string) *CustCustomerContactDao {
  156. return &CustCustomerContactDao{M: d.M.RightJoin(table...)}
  157. }
  158. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  159. // The parameter <table> can be joined table and its joined condition,
  160. // and also with its alias name, like:
  161. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  162. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  163. func (d *CustCustomerContactDao) InnerJoin(table ...string) *CustCustomerContactDao {
  164. return &CustCustomerContactDao{M: d.M.InnerJoin(table...)}
  165. }
  166. // Fields sets the 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 *CustCustomerContactDao) Fields(fieldNamesOrMapStruct ...interface{}) *CustCustomerContactDao {
  169. return &CustCustomerContactDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
  170. }
  171. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  172. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  173. func (d *CustCustomerContactDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *CustCustomerContactDao {
  174. return &CustCustomerContactDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
  175. }
  176. // FieldCount formats and appends commonly used field "COUNT(column)" to the select fields of model.
  177. func (d *CustCustomerContactDao) FieldCount(column string, as ...string) *CustCustomerContactDao {
  178. return &CustCustomerContactDao{M: d.M.FieldCount(column, as...)}
  179. }
  180. // FieldSum formats and appends commonly used field "SUM(column)" to the select fields of model.
  181. func (d *CustCustomerContactDao) FieldSum(column string, as ...string) *CustCustomerContactDao {
  182. return &CustCustomerContactDao{M: d.M.FieldSum(column, as...)}
  183. }
  184. // FieldMin formats and appends commonly used field "MIN(column)" to the select fields of model.
  185. func (d *CustCustomerContactDao) FieldMin(column string, as ...string) *CustCustomerContactDao {
  186. return &CustCustomerContactDao{M: d.M.FieldMin(column, as...)}
  187. }
  188. // FieldMax formats and appends commonly used field "MAX(column)" to the select fields of model.
  189. func (d *CustCustomerContactDao) FieldMax(column string, as ...string) *CustCustomerContactDao {
  190. return &CustCustomerContactDao{M: d.M.FieldMax(column, as...)}
  191. }
  192. // FieldAvg formats and appends commonly used field "AVG(column)" to the select fields of model.
  193. func (d *CustCustomerContactDao) FieldAvg(column string, as ...string) *CustCustomerContactDao {
  194. return &CustCustomerContactDao{M: d.M.FieldAvg(column, as...)}
  195. }
  196. // Option adds extra operation option for the model.
  197. // Deprecated, use separate operations instead.
  198. func (d *CustCustomerContactDao) Option(option int) *CustCustomerContactDao {
  199. return &CustCustomerContactDao{M: d.M.Option(option)}
  200. }
  201. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  202. // the data and where attributes for empty values.
  203. func (d *CustCustomerContactDao) OmitEmpty() *CustCustomerContactDao {
  204. return &CustCustomerContactDao{M: d.M.OmitEmpty()}
  205. }
  206. // OmitEmptyWhere sets optionOmitEmptyWhere option for the model, which automatically filers
  207. // the Where/Having parameters for "empty" values.
  208. func (d *CustCustomerContactDao) OmitEmptyWhere() *CustCustomerContactDao {
  209. return &CustCustomerContactDao{M: d.M.OmitEmptyWhere()}
  210. }
  211. // OmitEmptyData sets optionOmitEmptyData option for the model, which automatically filers
  212. // the Data parameters for "empty" values.
  213. func (d *CustCustomerContactDao) OmitEmptyData() *CustCustomerContactDao {
  214. return &CustCustomerContactDao{M: d.M.OmitEmptyData()}
  215. }
  216. // OmitNil sets optionOmitNil option for the model, which automatically filers
  217. // the data and where parameters for "nil" values.
  218. func (d *CustCustomerContactDao) OmitNil() *CustCustomerContactDao {
  219. return &CustCustomerContactDao{M: d.M.OmitNil()}
  220. }
  221. // OmitNilWhere sets optionOmitNilWhere option for the model, which automatically filers
  222. // the Where/Having parameters for "nil" values.
  223. func (d *CustCustomerContactDao) OmitNilWhere() *CustCustomerContactDao {
  224. return &CustCustomerContactDao{M: d.M.OmitNilWhere()}
  225. }
  226. // OmitNilData sets optionOmitNilData option for the model, which automatically filers
  227. // the Data parameters for "nil" values.
  228. func (d *CustCustomerContactDao) OmitNilData() *CustCustomerContactDao {
  229. return &CustCustomerContactDao{M: d.M.OmitNilData()}
  230. }
  231. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  232. // Note that this function supports only single table operations.
  233. // Deprecated, filter feature is automatically enabled from GoFrame v1.16.0, it is so no longer used.
  234. func (d *CustCustomerContactDao) Filter() *CustCustomerContactDao {
  235. return &CustCustomerContactDao{M: d.M.Filter()}
  236. }
  237. // Where sets the condition statement for the model. The parameter <where> can be type of
  238. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  239. // multiple conditions will be joined into where statement using "AND".
  240. // Eg:
  241. // Where("uid=10000")
  242. // Where("uid", 10000)
  243. // Where("money>? AND name like ?", 99999, "vip_%")
  244. // Where("uid", 1).Where("name", "john")
  245. // Where("status IN (?)", g.Slice{1,2,3})
  246. // Where("age IN(?,?)", 18, 50)
  247. // Where(User{ Id : 1, UserName : "john"})
  248. func (d *CustCustomerContactDao) Where(where interface{}, args ...interface{}) *CustCustomerContactDao {
  249. return &CustCustomerContactDao{M: d.M.Where(where, args...)}
  250. }
  251. // WherePri does the same logic as M.Where except that if the parameter <where>
  252. // is a single condition like int/string/float/slice, it treats the condition as the primary
  253. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  254. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  255. // as string "123".
  256. func (d *CustCustomerContactDao) WherePri(where interface{}, args ...interface{}) *CustCustomerContactDao {
  257. return &CustCustomerContactDao{M: d.M.WherePri(where, args...)}
  258. }
  259. // Having sets the having statement for the model.
  260. // The parameters of this function usage are as the same as function Where.
  261. // See Where.
  262. func (d *CustCustomerContactDao) Having(having interface{}, args ...interface{}) *CustCustomerContactDao {
  263. return &CustCustomerContactDao{M: d.M.Having(having, args...)}
  264. }
  265. // Wheref builds condition string using fmt.Sprintf and arguments.
  266. // Note that if the number of "args" is more than the place holder in "format",
  267. // the extra "args" will be used as the where condition arguments of the Model.
  268. func (d *CustCustomerContactDao) Wheref(format string, args ...interface{}) *CustCustomerContactDao {
  269. return &CustCustomerContactDao{M: d.M.Wheref(format, args...)}
  270. }
  271. // WhereLT builds "column < value" statement.
  272. func (d *CustCustomerContactDao) WhereLT(column string, value interface{}) *CustCustomerContactDao {
  273. return &CustCustomerContactDao{M: d.M.WhereLT(column, value)}
  274. }
  275. // WhereLTE builds "column <= value" statement.
  276. func (d *CustCustomerContactDao) WhereLTE(column string, value interface{}) *CustCustomerContactDao {
  277. return &CustCustomerContactDao{M: d.M.WhereLTE(column, value)}
  278. }
  279. // WhereGT builds "column > value" statement.
  280. func (d *CustCustomerContactDao) WhereGT(column string, value interface{}) *CustCustomerContactDao {
  281. return &CustCustomerContactDao{M: d.M.WhereGT(column, value)}
  282. }
  283. // WhereGTE builds "column >= value" statement.
  284. func (d *CustCustomerContactDao) WhereGTE(column string, value interface{}) *CustCustomerContactDao {
  285. return &CustCustomerContactDao{M: d.M.WhereGTE(column, value)}
  286. }
  287. // WhereBetween builds "column BETWEEN min AND max" statement.
  288. func (d *CustCustomerContactDao) WhereBetween(column string, min, max interface{}) *CustCustomerContactDao {
  289. return &CustCustomerContactDao{M: d.M.WhereBetween(column, min, max)}
  290. }
  291. // WhereLike builds "column LIKE like" statement.
  292. func (d *CustCustomerContactDao) WhereLike(column string, like interface{}) *CustCustomerContactDao {
  293. return &CustCustomerContactDao{M: d.M.WhereLike(column, like)}
  294. }
  295. // WhereIn builds "column IN (in)" statement.
  296. func (d *CustCustomerContactDao) WhereIn(column string, in interface{}) *CustCustomerContactDao {
  297. return &CustCustomerContactDao{M: d.M.WhereIn(column, in)}
  298. }
  299. // WhereNull builds "columns[0] IS NULL AND columns[1] IS NULL ..." statement.
  300. func (d *CustCustomerContactDao) WhereNull(columns ...string) *CustCustomerContactDao {
  301. return &CustCustomerContactDao{M: d.M.WhereNull(columns...)}
  302. }
  303. // WhereNotBetween builds "column NOT BETWEEN min AND max" statement.
  304. func (d *CustCustomerContactDao) WhereNotBetween(column string, min, max interface{}) *CustCustomerContactDao {
  305. return &CustCustomerContactDao{M: d.M.WhereNotBetween(column, min, max)}
  306. }
  307. // WhereNotLike builds "column NOT LIKE like" statement.
  308. func (d *CustCustomerContactDao) WhereNotLike(column string, like interface{}) *CustCustomerContactDao {
  309. return &CustCustomerContactDao{M: d.M.WhereNotLike(column, like)}
  310. }
  311. // WhereNot builds "column != value" statement.
  312. func (d *CustCustomerContactDao) WhereNot(column string, value interface{}) *CustCustomerContactDao {
  313. return &CustCustomerContactDao{M: d.M.WhereNot(column, value)}
  314. }
  315. // WhereNotIn builds "column NOT IN (in)" statement.
  316. func (d *CustCustomerContactDao) WhereNotIn(column string, in interface{}) *CustCustomerContactDao {
  317. return &CustCustomerContactDao{M: d.M.WhereNotIn(column, in)}
  318. }
  319. // WhereNotNull builds "columns[0] IS NOT NULL AND columns[1] IS NOT NULL ..." statement.
  320. func (d *CustCustomerContactDao) WhereNotNull(columns ...string) *CustCustomerContactDao {
  321. return &CustCustomerContactDao{M: d.M.WhereNotNull(columns...)}
  322. }
  323. // WhereOr adds "OR" condition to the where statement.
  324. func (d *CustCustomerContactDao) WhereOr(where interface{}, args ...interface{}) *CustCustomerContactDao {
  325. return &CustCustomerContactDao{M: d.M.WhereOr(where, args...)}
  326. }
  327. // WhereOrf builds "OR" condition string using fmt.Sprintf and arguments.
  328. func (d *CustCustomerContactDao) WhereOrf(format string, args ...interface{}) *CustCustomerContactDao {
  329. return &CustCustomerContactDao{M: d.M.WhereOrf(format, args...)}
  330. }
  331. // WhereOrLT builds "column < value" statement in "OR" conditions..
  332. func (d *CustCustomerContactDao) WhereOrLT(column string, value interface{}) *CustCustomerContactDao {
  333. return &CustCustomerContactDao{M: d.M.WhereOrLT(column, value)}
  334. }
  335. // WhereOrLTE builds "column <= value" statement in "OR" conditions..
  336. func (d *CustCustomerContactDao) WhereOrLTE(column string, value interface{}) *CustCustomerContactDao {
  337. return &CustCustomerContactDao{M: d.M.WhereOrLTE(column, value)}
  338. }
  339. // WhereOrGT builds "column > value" statement in "OR" conditions..
  340. func (d *CustCustomerContactDao) WhereOrGT(column string, value interface{}) *CustCustomerContactDao {
  341. return &CustCustomerContactDao{M: d.M.WhereOrGT(column, value)}
  342. }
  343. // WhereOrGTE builds "column >= value" statement in "OR" conditions..
  344. func (d *CustCustomerContactDao) WhereOrGTE(column string, value interface{}) *CustCustomerContactDao {
  345. return &CustCustomerContactDao{M: d.M.WhereOrGTE(column, value)}
  346. }
  347. // WhereOrBetween builds "column BETWEEN min AND max" statement in "OR" conditions.
  348. func (d *CustCustomerContactDao) WhereOrBetween(column string, min, max interface{}) *CustCustomerContactDao {
  349. return &CustCustomerContactDao{M: d.M.WhereOrBetween(column, min, max)}
  350. }
  351. // WhereOrLike builds "column LIKE like" statement in "OR" conditions.
  352. func (d *CustCustomerContactDao) WhereOrLike(column string, like interface{}) *CustCustomerContactDao {
  353. return &CustCustomerContactDao{M: d.M.WhereOrLike(column, like)}
  354. }
  355. // WhereOrIn builds "column IN (in)" statement in "OR" conditions.
  356. func (d *CustCustomerContactDao) WhereOrIn(column string, in interface{}) *CustCustomerContactDao {
  357. return &CustCustomerContactDao{M: d.M.WhereOrIn(column, in)}
  358. }
  359. // WhereOrNull builds "columns[0] IS NULL OR columns[1] IS NULL ..." statement in "OR" conditions.
  360. func (d *CustCustomerContactDao) WhereOrNull(columns ...string) *CustCustomerContactDao {
  361. return &CustCustomerContactDao{M: d.M.WhereOrNull(columns...)}
  362. }
  363. // WhereOrNotBetween builds "column NOT BETWEEN min AND max" statement in "OR" conditions.
  364. func (d *CustCustomerContactDao) WhereOrNotBetween(column string, min, max interface{}) *CustCustomerContactDao {
  365. return &CustCustomerContactDao{M: d.M.WhereOrNotBetween(column, min, max)}
  366. }
  367. // WhereOrNotLike builds "column NOT LIKE like" statement in "OR" conditions.
  368. func (d *CustCustomerContactDao) WhereOrNotLike(column string, like interface{}) *CustCustomerContactDao {
  369. return &CustCustomerContactDao{M: d.M.WhereOrNotLike(column, like)}
  370. }
  371. // WhereOrNotIn builds "column NOT IN (in)" statement.
  372. func (d *CustCustomerContactDao) WhereOrNotIn(column string, in interface{}) *CustCustomerContactDao {
  373. return &CustCustomerContactDao{M: d.M.WhereOrNotIn(column, in)}
  374. }
  375. // WhereOrNotNull builds "columns[0] IS NOT NULL OR columns[1] IS NOT NULL ..." statement in "OR" conditions.
  376. func (d *CustCustomerContactDao) WhereOrNotNull(columns ...string) *CustCustomerContactDao {
  377. return &CustCustomerContactDao{M: d.M.WhereOrNotNull(columns...)}
  378. }
  379. // Group sets the "GROUP BY" statement for the model.
  380. func (d *CustCustomerContactDao) Group(groupBy ...string) *CustCustomerContactDao {
  381. return &CustCustomerContactDao{M: d.M.Group(groupBy...)}
  382. }
  383. // And adds "AND" condition to the where statement.
  384. // Deprecated, use Where instead.
  385. func (d *CustCustomerContactDao) And(where interface{}, args ...interface{}) *CustCustomerContactDao {
  386. return &CustCustomerContactDao{M: d.M.And(where, args...)}
  387. }
  388. // Or adds "OR" condition to the where statement.
  389. // Deprecated, use WhereOr instead.
  390. func (d *CustCustomerContactDao) Or(where interface{}, args ...interface{}) *CustCustomerContactDao {
  391. return &CustCustomerContactDao{M: d.M.Or(where, args...)}
  392. }
  393. // GroupBy sets the "GROUP BY" statement for the model.
  394. func (d *CustCustomerContactDao) GroupBy(groupBy string) *CustCustomerContactDao {
  395. return &CustCustomerContactDao{M: d.M.Group(groupBy)}
  396. }
  397. // Order sets the "ORDER BY" statement for the model.
  398. func (d *CustCustomerContactDao) Order(orderBy ...string) *CustCustomerContactDao {
  399. return &CustCustomerContactDao{M: d.M.Order(orderBy...)}
  400. }
  401. // OrderAsc sets the "ORDER BY xxx ASC" statement for the model.
  402. func (d *CustCustomerContactDao) OrderAsc(column string) *CustCustomerContactDao {
  403. return &CustCustomerContactDao{M: d.M.OrderAsc(column)}
  404. }
  405. // OrderDesc sets the "ORDER BY xxx DESC" statement for the model.
  406. func (d *CustCustomerContactDao) OrderDesc(column string) *CustCustomerContactDao {
  407. return &CustCustomerContactDao{M: d.M.OrderDesc(column)}
  408. }
  409. // OrderRandom sets the "ORDER BY RANDOM()" statement for the model.
  410. func (d *CustCustomerContactDao) OrderRandom() *CustCustomerContactDao {
  411. return &CustCustomerContactDao{M: d.M.OrderRandom()}
  412. }
  413. // OrderBy is alias of Model.Order.
  414. // See Model.Order.
  415. // Deprecated, use Order instead.
  416. func (d *CustCustomerContactDao) OrderBy(orderBy string) *CustCustomerContactDao {
  417. return &CustCustomerContactDao{M: d.M.Order(orderBy)}
  418. }
  419. // Limit sets the "LIMIT" statement for the model.
  420. // The parameter <limit> can be either one or two number, if passed two number is passed,
  421. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  422. // statement.
  423. func (d *CustCustomerContactDao) Limit(limit ...int) *CustCustomerContactDao {
  424. return &CustCustomerContactDao{M: d.M.Limit(limit...)}
  425. }
  426. // Offset sets the "OFFSET" statement for the model.
  427. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  428. func (d *CustCustomerContactDao) Offset(offset int) *CustCustomerContactDao {
  429. return &CustCustomerContactDao{M: d.M.Offset(offset)}
  430. }
  431. // Distinct forces the query to only return distinct results.
  432. func (d *CustCustomerContactDao) Distinct() *CustCustomerContactDao {
  433. return &CustCustomerContactDao{M: d.M.Distinct()}
  434. }
  435. // Page sets the paging number for the model.
  436. // The parameter <page> is started from 1 for paging.
  437. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  438. func (d *CustCustomerContactDao) Page(page, limit int) *CustCustomerContactDao {
  439. return &CustCustomerContactDao{M: d.M.Page(page, limit)}
  440. }
  441. // Batch sets the batch operation number for the model.
  442. func (d *CustCustomerContactDao) Batch(batch int) *CustCustomerContactDao {
  443. return &CustCustomerContactDao{M: d.M.Batch(batch)}
  444. }
  445. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  446. // if there's another same sql request, it just reads and returns the result from cache, it
  447. // but not committed and executed into the database.
  448. //
  449. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  450. // If the parameter <duration> = 0, which means it never expires.
  451. // If the parameter <duration> > 0, which means it expires after <duration>.
  452. //
  453. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  454. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  455. //
  456. // Note that, the cache feature is disabled if the model is operating on a transaction.
  457. func (d *CustCustomerContactDao) Cache(duration time.Duration, name ...string) *CustCustomerContactDao {
  458. return &CustCustomerContactDao{M: d.M.Cache(duration, name...)}
  459. }
  460. // Data sets the operation data for the model.
  461. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  462. // Eg:
  463. // Data("uid=10000")
  464. // Data("uid", 10000)
  465. // Data(g.Map{"uid": 10000, "name":"john"})
  466. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  467. func (d *CustCustomerContactDao) Data(data ...interface{}) *CustCustomerContactDao {
  468. return &CustCustomerContactDao{M: d.M.Data(data...)}
  469. }
  470. // All does "SELECT FROM ..." statement for the model.
  471. // It retrieves the records from table and returns the result as []*model.CustCustomerContact.
  472. // It returns nil if there's no record retrieved with the given conditions from table.
  473. //
  474. // The optional parameter <where> is the same as the parameter of M.Where function,
  475. // see M.Where.
  476. func (d *CustCustomerContactDao) All(where ...interface{}) ([]*model.CustCustomerContact, error) {
  477. all, err := d.M.All(where...)
  478. if err != nil {
  479. return nil, err
  480. }
  481. var entities []*model.CustCustomerContact
  482. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  483. return nil, err
  484. }
  485. return entities, nil
  486. }
  487. // One retrieves one record from table and returns the result as *model.CustCustomerContact.
  488. // It returns nil if there's no record retrieved with the given conditions from table.
  489. //
  490. // The optional parameter <where> is the same as the parameter of M.Where function,
  491. // see M.Where.
  492. func (d *CustCustomerContactDao) One(where ...interface{}) (*model.CustCustomerContact, error) {
  493. one, err := d.M.One(where...)
  494. if err != nil {
  495. return nil, err
  496. }
  497. var entity *model.CustCustomerContact
  498. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  499. return nil, err
  500. }
  501. return entity, nil
  502. }
  503. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  504. // Also see M.WherePri and M.One.
  505. func (d *CustCustomerContactDao) FindOne(where ...interface{}) (*model.CustCustomerContact, error) {
  506. one, err := d.M.FindOne(where...)
  507. if err != nil {
  508. return nil, err
  509. }
  510. var entity *model.CustCustomerContact
  511. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  512. return nil, err
  513. }
  514. return entity, nil
  515. }
  516. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  517. // Also see M.WherePri and M.All.
  518. func (d *CustCustomerContactDao) FindAll(where ...interface{}) ([]*model.CustCustomerContact, error) {
  519. all, err := d.M.FindAll(where...)
  520. if err != nil {
  521. return nil, err
  522. }
  523. var entities []*model.CustCustomerContact
  524. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  525. return nil, err
  526. }
  527. return entities, nil
  528. }
  529. // Struct retrieves one record from table and converts it into given struct.
  530. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  531. // it can create the struct internally during converting.
  532. //
  533. // The optional parameter <where> is the same as the parameter of Model.Where function,
  534. // see Model.Where.
  535. //
  536. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  537. // from table and <pointer> is not nil.
  538. //
  539. // Eg:
  540. // user := new(User)
  541. // err := dao.User.Where("id", 1).Struct(user)
  542. //
  543. // user := (*User)(nil)
  544. // err := dao.User.Where("id", 1).Struct(&user)
  545. func (d *CustCustomerContactDao) Struct(pointer interface{}, where ...interface{}) error {
  546. return d.M.Struct(pointer, where...)
  547. }
  548. // Structs retrieves records from table and converts them into given struct slice.
  549. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  550. // slice internally during converting.
  551. //
  552. // The optional parameter <where> is the same as the parameter of Model.Where function,
  553. // see Model.Where.
  554. //
  555. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  556. // from table and <pointer> is not empty.
  557. //
  558. // Eg:
  559. // users := ([]User)(nil)
  560. // err := dao.User.Structs(&users)
  561. //
  562. // users := ([]*User)(nil)
  563. // err := dao.User.Structs(&users)
  564. func (d *CustCustomerContactDao) Structs(pointer interface{}, where ...interface{}) error {
  565. return d.M.Structs(pointer, where...)
  566. }
  567. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  568. // It calls function Struct if <pointer> is type of *struct/**struct.
  569. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  570. //
  571. // The optional parameter <where> is the same as the parameter of Model.Where function,
  572. // see Model.Where.
  573. //
  574. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  575. //
  576. // Eg:
  577. // user := new(User)
  578. // err := dao.User.Where("id", 1).Scan(user)
  579. //
  580. // user := (*User)(nil)
  581. // err := dao.User.Where("id", 1).Scan(&user)
  582. //
  583. // users := ([]User)(nil)
  584. // err := dao.User.Scan(&users)
  585. //
  586. // users := ([]*User)(nil)
  587. // err := dao.User.Scan(&users)
  588. func (d *CustCustomerContactDao) Scan(pointer interface{}, where ...interface{}) error {
  589. return d.M.Scan(pointer, where...)
  590. }
  591. // Chunk iterates the table with given size and callback function.
  592. func (d *CustCustomerContactDao) Chunk(limit int, callback func(entities []*model.CustCustomerContact, err error) bool) {
  593. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  594. var entities []*model.CustCustomerContact
  595. err = result.Structs(&entities)
  596. if err == sql.ErrNoRows {
  597. return false
  598. }
  599. return callback(entities, err)
  600. })
  601. }
  602. // LockUpdate sets the lock for update for current operation.
  603. func (d *CustCustomerContactDao) LockUpdate() *CustCustomerContactDao {
  604. return &CustCustomerContactDao{M: d.M.LockUpdate()}
  605. }
  606. // LockShared sets the lock in share mode for current operation.
  607. func (d *CustCustomerContactDao) LockShared() *CustCustomerContactDao {
  608. return &CustCustomerContactDao{M: d.M.LockShared()}
  609. }
  610. // Unscoped enables/disables the soft deleting feature.
  611. func (d *CustCustomerContactDao) Unscoped() *CustCustomerContactDao {
  612. return &CustCustomerContactDao{M: d.M.Unscoped()}
  613. }
  614. // DataScope enables the DataScope feature.
  615. func (d *CustCustomerContactDao) DataScope(userCol ...string) *CustCustomerContactDao {
  616. ctx := d.GetCtx().Value("contextService")
  617. dataScope := gconv.Map(ctx)["dataScope"].(g.Map)
  618. if dataScope != nil {
  619. if userIds, ok := dataScope["userIds"]; ok {
  620. column := "created_by"
  621. if len(userCol) == 1 {
  622. column = userCol[0]
  623. }
  624. delete(dataScope, "userIds")
  625. dataScope[column] = userIds
  626. }
  627. return &CustCustomerContactDao{M: d.M.Where(dataScope)}
  628. }
  629. return d
  630. }