cust_customer_contact.go 34 KB

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