cust_customer_contact.go 34 KB

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