cust_customer_belong.go 33 KB

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