proj_business_contact.go 33 KB

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