proj_business.go 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  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. // ProjBusinessDao is the manager for logic model data accessing and custom defined data operations functions management.
  18. type ProjBusinessDao struct {
  19. gmvc.M // M is the core and embedded struct that inherits all chaining operations from gdb.Model.
  20. C projBusinessColumns // 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. // ProjBusinessColumns defines and stores column names for table proj_business.
  26. type projBusinessColumns struct {
  27. Id string // 主键
  28. NboCode string // 项目编码
  29. NboName string // 项目名称
  30. NboStatus string // 项目状态
  31. CustId string // 关联客户
  32. CustName string // 客户名称
  33. CustProvinceId string // 所在省ID
  34. CustProvince string // 所在省
  35. CustCityId string // 所在市ID
  36. CustCity string // 所在市
  37. CustRegionId string // 所在区县ID
  38. CustRegion string // 所在区县
  39. ProductLine string // 产品线
  40. NboType string // 项目级别(A 、B 、C 、成交、储备)
  41. NboPhase string // 项目阶段(暂不起用)
  42. NboSource string // 项目来源
  43. NboBudget string // 项目预算
  44. ApproStatus string // 审批状态(10待提交20审批中30审批通过40审批退回60审批拒绝)
  45. ContactId string // 关联联系人
  46. ContactName string // 联系人姓名
  47. ContactPostion string // 联系人岗位
  48. ContactTelephone string // 联系人电话
  49. MakerId string // 关联决策人
  50. MakerName string // 决策人姓名
  51. MakerDept string // 决策人部门
  52. MakerPost string // 决策人岗位
  53. MakerTelephone string // 决策人电话
  54. SalesModel string // 销售模式(10直销20经销30代理)
  55. SaleId string // 归属销售
  56. SaleName string // 销售姓名
  57. DistributorId string // 经销商/代理商ID
  58. DistributorName string // 经销商/代理商名称
  59. BidId string // 客户招标ID
  60. BidInfo string // 招标信息
  61. FilingTime string // 项目备案时间
  62. FinalFollowId string // 最新跟进人
  63. FinalFollowName string // 最新跟进人名称
  64. FinalFollowTime string // 最后跟进时间
  65. NextFollowTime string // 下次跟进时间
  66. PlanPurchaseTime string // 计划采购时间
  67. EstTransTime string // 预计成交时间
  68. EstTransPrice string // 预计成交价格
  69. RiskProfile string // 风险情况
  70. Difficulty string // 困难点
  71. Competitor string // 竞争公司
  72. Intervention string // 介入情况
  73. DeptId string // 所属部门ID
  74. DeptName string // 所属部门
  75. IsBig string // 是否为大项目
  76. TechnicalSupportName string // 技术支持人员
  77. TechnicalSupportContent string // 技术支持内容
  78. TechnicalSupportTime string // 技术支持时间
  79. CustomerSatisfaction string // 客户满意度 (10很满意、20满意、30较满意、40一般、50不满意)
  80. ParentReceiver string // 总部对接人
  81. NboBudgetTime string // 项目预算期限
  82. CapitalSource string // 资金来源
  83. ProductSatisfaction string // 产品/方案满足情况
  84. PurchasingWay string // 采购方式
  85. PurchasingTime string // 采购时间
  86. IsAdoptDashoo string // 是否采纳大数技术参数(上传附件)
  87. HistoricalTransactionInfo string // 经销商与客户历史成交信息
  88. DealerSalesId string // 关联经销商销售
  89. DealerSalesName string // 经销商销售人员
  90. DealerSalesContact string // 经销商销售电话/微信
  91. Accendant string // 维护部门及人员
  92. CustomerIntentionFactory string // 客户倾向厂家
  93. ProjConversionTime string // 项目转化时间
  94. ProjConversionReason string // 项目转化原因
  95. Remark string // 备注
  96. CreatedBy string // 创建者
  97. CreatedName string // 创建人
  98. CreatedTime string // 创建时间
  99. UpdatedBy string // 更新者
  100. UpdatedName string // 更新人
  101. UpdatedTime string // 更新时间
  102. DeletedTime string // 删除时间
  103. }
  104. var (
  105. // ProjBusiness is globally public accessible object for table proj_business operations.
  106. ProjBusiness = ProjBusinessDao{
  107. M: g.DB("default").Model("proj_business").Safe(),
  108. DB: g.DB("default"),
  109. Table: "proj_business",
  110. C: projBusinessColumns{
  111. Id: "id",
  112. NboCode: "nbo_code",
  113. NboName: "nbo_name",
  114. NboStatus: "nbo_status",
  115. CustId: "cust_id",
  116. CustName: "cust_name",
  117. CustProvinceId: "cust_province_id",
  118. CustProvince: "cust_province",
  119. CustCityId: "cust_city_id",
  120. CustCity: "cust_city",
  121. CustRegionId: "cust_region_id",
  122. CustRegion: "cust_region",
  123. ProductLine: "product_line",
  124. NboType: "nbo_type",
  125. NboPhase: "nbo_phase",
  126. NboSource: "nbo_source",
  127. NboBudget: "nbo_budget",
  128. ApproStatus: "appro_status",
  129. ContactId: "contact_id",
  130. ContactName: "contact_name",
  131. ContactPostion: "contact_postion",
  132. ContactTelephone: "contact_telephone",
  133. MakerId: "maker_id",
  134. MakerName: "maker_name",
  135. MakerDept: "maker_dept",
  136. MakerPost: "maker_post",
  137. MakerTelephone: "maker_telephone",
  138. SalesModel: "sales_model",
  139. SaleId: "sale_id",
  140. SaleName: "sale_name",
  141. DistributorId: "distributor_id",
  142. DistributorName: "distributor_name",
  143. BidId: "bid_id",
  144. BidInfo: "bid_info",
  145. FilingTime: "filing_time",
  146. FinalFollowId: "final_follow_id",
  147. FinalFollowName: "final_follow_name",
  148. FinalFollowTime: "final_follow_time",
  149. NextFollowTime: "next_follow_time",
  150. PlanPurchaseTime: "plan_purchase_time",
  151. EstTransTime: "est_trans_time",
  152. EstTransPrice: "est_trans_price",
  153. RiskProfile: "risk_profile",
  154. Difficulty: "difficulty",
  155. Competitor: "competitor",
  156. Intervention: "Intervention",
  157. DeptId: "dept_id",
  158. DeptName: "dept_name",
  159. IsBig: "is_big",
  160. TechnicalSupportName: "technical_support_name",
  161. TechnicalSupportContent: "technical_support_content",
  162. TechnicalSupportTime: "technical_support_time",
  163. CustomerSatisfaction: "customer_satisfaction",
  164. ParentReceiver: "parent_receiver",
  165. NboBudgetTime: "nbo_budget_time",
  166. CapitalSource: "capital_source",
  167. ProductSatisfaction: "product_satisfaction",
  168. PurchasingWay: "purchasing_way",
  169. PurchasingTime: "purchasing_time",
  170. IsAdoptDashoo: "is_adopt_dashoo",
  171. HistoricalTransactionInfo: "historical_transaction_info",
  172. DealerSalesId: "dealer_sales_id",
  173. DealerSalesName: "dealer_sales_name",
  174. DealerSalesContact: "dealer_sales_contact",
  175. Accendant: "accendant",
  176. CustomerIntentionFactory: "customer_intention_factory",
  177. ProjConversionTime: "proj_conversion_time",
  178. ProjConversionReason: "proj_conversion_reason",
  179. Remark: "remark",
  180. CreatedBy: "created_by",
  181. CreatedName: "created_name",
  182. CreatedTime: "created_time",
  183. UpdatedBy: "updated_by",
  184. UpdatedName: "updated_name",
  185. UpdatedTime: "updated_time",
  186. DeletedTime: "deleted_time",
  187. },
  188. }
  189. )
  190. func NewProjBusinessDao(tenant string) ProjBusinessDao {
  191. var dao ProjBusinessDao
  192. dao = ProjBusinessDao{
  193. M: g.DB(tenant).Model("proj_business").Safe(),
  194. DB: g.DB(tenant),
  195. Table: "proj_business",
  196. C: projBusinessColumns{
  197. Id: "id",
  198. NboCode: "nbo_code",
  199. NboName: "nbo_name",
  200. NboStatus: "nbo_status",
  201. CustId: "cust_id",
  202. CustName: "cust_name",
  203. CustProvinceId: "cust_province_id",
  204. CustProvince: "cust_province",
  205. CustCityId: "cust_city_id",
  206. CustCity: "cust_city",
  207. CustRegionId: "cust_region_id",
  208. CustRegion: "cust_region",
  209. ProductLine: "product_line",
  210. NboType: "nbo_type",
  211. NboPhase: "nbo_phase",
  212. NboSource: "nbo_source",
  213. NboBudget: "nbo_budget",
  214. ApproStatus: "appro_status",
  215. ContactId: "contact_id",
  216. ContactName: "contact_name",
  217. ContactPostion: "contact_postion",
  218. ContactTelephone: "contact_telephone",
  219. MakerId: "maker_id",
  220. MakerName: "maker_name",
  221. MakerDept: "maker_dept",
  222. MakerPost: "maker_post",
  223. MakerTelephone: "maker_telephone",
  224. SalesModel: "sales_model",
  225. SaleId: "sale_id",
  226. SaleName: "sale_name",
  227. DistributorId: "distributor_id",
  228. DistributorName: "distributor_name",
  229. BidId: "bid_id",
  230. BidInfo: "bid_info",
  231. FilingTime: "filing_time",
  232. FinalFollowId: "final_follow_id",
  233. FinalFollowName: "final_follow_name",
  234. FinalFollowTime: "final_follow_time",
  235. NextFollowTime: "next_follow_time",
  236. PlanPurchaseTime: "plan_purchase_time",
  237. EstTransTime: "est_trans_time",
  238. EstTransPrice: "est_trans_price",
  239. RiskProfile: "risk_profile",
  240. Difficulty: "difficulty",
  241. Competitor: "competitor",
  242. Intervention: "Intervention",
  243. DeptId: "dept_id",
  244. DeptName: "dept_name",
  245. IsBig: "is_big",
  246. TechnicalSupportName: "technical_support_name",
  247. TechnicalSupportContent: "technical_support_content",
  248. TechnicalSupportTime: "technical_support_time",
  249. CustomerSatisfaction: "customer_satisfaction",
  250. ParentReceiver: "parent_receiver",
  251. NboBudgetTime: "nbo_budget_time",
  252. CapitalSource: "capital_source",
  253. ProductSatisfaction: "product_satisfaction",
  254. PurchasingWay: "purchasing_way",
  255. PurchasingTime: "purchasing_time",
  256. IsAdoptDashoo: "is_adopt_dashoo",
  257. HistoricalTransactionInfo: "historical_transaction_info",
  258. DealerSalesId: "dealer_sales_id",
  259. DealerSalesName: "dealer_sales_name",
  260. DealerSalesContact: "dealer_sales_contact",
  261. Accendant: "accendant",
  262. CustomerIntentionFactory: "customer_intention_factory",
  263. ProjConversionTime: "proj_conversion_time",
  264. ProjConversionReason: "proj_conversion_reason",
  265. Remark: "remark",
  266. CreatedBy: "created_by",
  267. CreatedName: "created_name",
  268. CreatedTime: "created_time",
  269. UpdatedBy: "updated_by",
  270. UpdatedName: "updated_name",
  271. UpdatedTime: "updated_time",
  272. DeletedTime: "deleted_time",
  273. },
  274. }
  275. return dao
  276. }
  277. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  278. // of current DB object and with given context in it.
  279. // Note that this returned DB object can be used only once, so do not assign it to
  280. // a global or package variable for long using.
  281. func (d *ProjBusinessDao) Ctx(ctx context.Context) *ProjBusinessDao {
  282. return &ProjBusinessDao{M: d.M.Ctx(ctx), Table: d.Table, TableAs: d.TableAs}
  283. }
  284. // GetCtx returns the context for current Model.
  285. // It returns "context.Background() i"s there's no context previously set.
  286. func (d *ProjBusinessDao) GetCtx() context.Context {
  287. return d.M.GetCtx()
  288. }
  289. // As sets an alias name for current table.
  290. func (d *ProjBusinessDao) As(as string) *ProjBusinessDao {
  291. return &ProjBusinessDao{M: d.M.As(as), Table: d.Table, TableAs: as}
  292. }
  293. // TX sets the transaction for current operation.
  294. func (d *ProjBusinessDao) TX(tx *gdb.TX) *ProjBusinessDao {
  295. return &ProjBusinessDao{M: d.M.TX(tx), Table: d.Table, TableAs: d.TableAs}
  296. }
  297. // Master marks the following operation on master node.
  298. func (d *ProjBusinessDao) Master() *ProjBusinessDao {
  299. return &ProjBusinessDao{M: d.M.Master(), Table: d.Table, TableAs: d.TableAs}
  300. }
  301. // Slave marks the following operation on slave node.
  302. // Note that it makes sense only if there's any slave node configured.
  303. func (d *ProjBusinessDao) Slave() *ProjBusinessDao {
  304. return &ProjBusinessDao{M: d.M.Slave(), Table: d.Table, TableAs: d.TableAs}
  305. }
  306. // Args sets custom arguments for model operation.
  307. func (d *ProjBusinessDao) Args(args ...interface{}) *ProjBusinessDao {
  308. return &ProjBusinessDao{M: d.M.Args(args...), Table: d.Table, TableAs: d.TableAs}
  309. }
  310. // Handler calls each of "handlers" on current Model and returns a new Model.
  311. // ModelHandler is a function that handles given Model and returns a new Model that is custom modified.
  312. func (d *ProjBusinessDao) Handler(handlers ...gdb.ModelHandler) *ProjBusinessDao {
  313. return &ProjBusinessDao{M: d.M.Handler(handlers...), Table: d.Table, TableAs: d.TableAs}
  314. }
  315. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  316. // The parameter <table> can be joined table and its joined condition,
  317. // and also with its alias name, like:
  318. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  319. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  320. func (d *ProjBusinessDao) LeftJoin(table ...string) *ProjBusinessDao {
  321. return &ProjBusinessDao{M: d.M.LeftJoin(table...), Table: d.Table, TableAs: d.TableAs}
  322. }
  323. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  324. // The parameter <table> can be joined table and its joined condition,
  325. // and also with its alias name, like:
  326. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  327. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  328. func (d *ProjBusinessDao) RightJoin(table ...string) *ProjBusinessDao {
  329. return &ProjBusinessDao{M: d.M.RightJoin(table...), Table: d.Table, TableAs: d.TableAs}
  330. }
  331. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  332. // The parameter <table> can be joined table and its joined condition,
  333. // and also with its alias name, like:
  334. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  335. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  336. func (d *ProjBusinessDao) InnerJoin(table ...string) *ProjBusinessDao {
  337. return &ProjBusinessDao{M: d.M.InnerJoin(table...), Table: d.Table, TableAs: d.TableAs}
  338. }
  339. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  340. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  341. func (d *ProjBusinessDao) Fields(fieldNamesOrMapStruct ...interface{}) *ProjBusinessDao {
  342. return &ProjBusinessDao{M: d.M.Fields(fieldNamesOrMapStruct...), Table: d.Table, TableAs: d.TableAs}
  343. }
  344. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  345. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  346. func (d *ProjBusinessDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *ProjBusinessDao {
  347. return &ProjBusinessDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...), Table: d.Table, TableAs: d.TableAs}
  348. }
  349. // FieldCount formats and appends commonly used field "COUNT(column)" to the select fields of model.
  350. func (d *ProjBusinessDao) FieldCount(column string, as ...string) *ProjBusinessDao {
  351. return &ProjBusinessDao{M: d.M.FieldCount(column, as...), Table: d.Table, TableAs: d.TableAs}
  352. }
  353. // FieldSum formats and appends commonly used field "SUM(column)" to the select fields of model.
  354. func (d *ProjBusinessDao) FieldSum(column string, as ...string) *ProjBusinessDao {
  355. return &ProjBusinessDao{M: d.M.FieldSum(column, as...), Table: d.Table, TableAs: d.TableAs}
  356. }
  357. // FieldMin formats and appends commonly used field "MIN(column)" to the select fields of model.
  358. func (d *ProjBusinessDao) FieldMin(column string, as ...string) *ProjBusinessDao {
  359. return &ProjBusinessDao{M: d.M.FieldMin(column, as...), Table: d.Table, TableAs: d.TableAs}
  360. }
  361. // FieldMax formats and appends commonly used field "MAX(column)" to the select fields of model.
  362. func (d *ProjBusinessDao) FieldMax(column string, as ...string) *ProjBusinessDao {
  363. return &ProjBusinessDao{M: d.M.FieldMax(column, as...), Table: d.Table, TableAs: d.TableAs}
  364. }
  365. // FieldAvg formats and appends commonly used field "AVG(column)" to the select fields of model.
  366. func (d *ProjBusinessDao) FieldAvg(column string, as ...string) *ProjBusinessDao {
  367. return &ProjBusinessDao{M: d.M.FieldAvg(column, as...), Table: d.Table, TableAs: d.TableAs}
  368. }
  369. // Option adds extra operation option for the model.
  370. // Deprecated, use separate operations instead.
  371. func (d *ProjBusinessDao) Option(option int) *ProjBusinessDao {
  372. return &ProjBusinessDao{M: d.M.Option(option), Table: d.Table, TableAs: d.TableAs}
  373. }
  374. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  375. // the data and where attributes for empty values.
  376. func (d *ProjBusinessDao) OmitEmpty() *ProjBusinessDao {
  377. return &ProjBusinessDao{M: d.M.OmitEmpty(), Table: d.Table, TableAs: d.TableAs}
  378. }
  379. // OmitEmptyWhere sets optionOmitEmptyWhere option for the model, which automatically filers
  380. // the Where/Having parameters for "empty" values.
  381. func (d *ProjBusinessDao) OmitEmptyWhere() *ProjBusinessDao {
  382. return &ProjBusinessDao{M: d.M.OmitEmptyWhere(), Table: d.Table, TableAs: d.TableAs}
  383. }
  384. // OmitEmptyData sets optionOmitEmptyData option for the model, which automatically filers
  385. // the Data parameters for "empty" values.
  386. func (d *ProjBusinessDao) OmitEmptyData() *ProjBusinessDao {
  387. return &ProjBusinessDao{M: d.M.OmitEmptyData(), Table: d.Table, TableAs: d.TableAs}
  388. }
  389. // OmitNil sets optionOmitNil option for the model, which automatically filers
  390. // the data and where parameters for "nil" values.
  391. func (d *ProjBusinessDao) OmitNil() *ProjBusinessDao {
  392. return &ProjBusinessDao{M: d.M.OmitNil(), Table: d.Table, TableAs: d.TableAs}
  393. }
  394. // OmitNilWhere sets optionOmitNilWhere option for the model, which automatically filers
  395. // the Where/Having parameters for "nil" values.
  396. func (d *ProjBusinessDao) OmitNilWhere() *ProjBusinessDao {
  397. return &ProjBusinessDao{M: d.M.OmitNilWhere(), Table: d.Table, TableAs: d.TableAs}
  398. }
  399. // OmitNilData sets optionOmitNilData option for the model, which automatically filers
  400. // the Data parameters for "nil" values.
  401. func (d *ProjBusinessDao) OmitNilData() *ProjBusinessDao {
  402. return &ProjBusinessDao{M: d.M.OmitNilData(), Table: d.Table, TableAs: d.TableAs}
  403. }
  404. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  405. // Note that this function supports only single table operations.
  406. // Deprecated, filter feature is automatically enabled from GoFrame v1.16.0, it is so no longer used.
  407. func (d *ProjBusinessDao) Filter() *ProjBusinessDao {
  408. return &ProjBusinessDao{M: d.M.Filter(), Table: d.Table, TableAs: d.TableAs}
  409. }
  410. // Where sets the condition statement for the model. The parameter <where> can be type of
  411. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  412. // multiple conditions will be joined into where statement using "AND".
  413. // Eg:
  414. // Where("uid=10000")
  415. // Where("uid", 10000)
  416. // Where("money>? AND name like ?", 99999, "vip_%")
  417. // Where("uid", 1).Where("name", "john")
  418. // Where("status IN (?)", g.Slice{1,2,3})
  419. // Where("age IN(?,?)", 18, 50)
  420. // Where(User{ Id : 1, UserName : "john"})
  421. func (d *ProjBusinessDao) Where(where interface{}, args ...interface{}) *ProjBusinessDao {
  422. return &ProjBusinessDao{M: d.M.Where(where, args...), Table: d.Table, TableAs: d.TableAs}
  423. }
  424. // WherePri does the same logic as M.Where except that if the parameter <where>
  425. // is a single condition like int/string/float/slice, it treats the condition as the primary
  426. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  427. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  428. // as string "123".
  429. func (d *ProjBusinessDao) WherePri(where interface{}, args ...interface{}) *ProjBusinessDao {
  430. return &ProjBusinessDao{M: d.M.WherePri(where, args...), Table: d.Table, TableAs: d.TableAs}
  431. }
  432. // Having sets the having statement for the model.
  433. // The parameters of this function usage are as the same as function Where.
  434. // See Where.
  435. func (d *ProjBusinessDao) Having(having interface{}, args ...interface{}) *ProjBusinessDao {
  436. return &ProjBusinessDao{M: d.M.Having(having, args...), Table: d.Table, TableAs: d.TableAs}
  437. }
  438. // Wheref builds condition string using fmt.Sprintf and arguments.
  439. // Note that if the number of "args" is more than the place holder in "format",
  440. // the extra "args" will be used as the where condition arguments of the Model.
  441. func (d *ProjBusinessDao) Wheref(format string, args ...interface{}) *ProjBusinessDao {
  442. return &ProjBusinessDao{M: d.M.Wheref(format, args...), Table: d.Table, TableAs: d.TableAs}
  443. }
  444. // WhereLT builds "column < value" statement.
  445. func (d *ProjBusinessDao) WhereLT(column string, value interface{}) *ProjBusinessDao {
  446. return &ProjBusinessDao{M: d.M.WhereLT(column, value), Table: d.Table, TableAs: d.TableAs}
  447. }
  448. // WhereLTE builds "column <= value" statement.
  449. func (d *ProjBusinessDao) WhereLTE(column string, value interface{}) *ProjBusinessDao {
  450. return &ProjBusinessDao{M: d.M.WhereLTE(column, value), Table: d.Table, TableAs: d.TableAs}
  451. }
  452. // WhereGT builds "column > value" statement.
  453. func (d *ProjBusinessDao) WhereGT(column string, value interface{}) *ProjBusinessDao {
  454. return &ProjBusinessDao{M: d.M.WhereGT(column, value), Table: d.Table, TableAs: d.TableAs}
  455. }
  456. // WhereGTE builds "column >= value" statement.
  457. func (d *ProjBusinessDao) WhereGTE(column string, value interface{}) *ProjBusinessDao {
  458. return &ProjBusinessDao{M: d.M.WhereGTE(column, value), Table: d.Table, TableAs: d.TableAs}
  459. }
  460. // WhereBetween builds "column BETWEEN min AND max" statement.
  461. func (d *ProjBusinessDao) WhereBetween(column string, min, max interface{}) *ProjBusinessDao {
  462. return &ProjBusinessDao{M: d.M.WhereBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  463. }
  464. // WhereLike builds "column LIKE like" statement.
  465. func (d *ProjBusinessDao) WhereLike(column string, like interface{}) *ProjBusinessDao {
  466. return &ProjBusinessDao{M: d.M.WhereLike(column, like), Table: d.Table, TableAs: d.TableAs}
  467. }
  468. // WhereIn builds "column IN (in)" statement.
  469. func (d *ProjBusinessDao) WhereIn(column string, in interface{}) *ProjBusinessDao {
  470. return &ProjBusinessDao{M: d.M.WhereIn(column, in), Table: d.Table, TableAs: d.TableAs}
  471. }
  472. // WhereNull builds "columns[0] IS NULL AND columns[1] IS NULL ..." statement.
  473. func (d *ProjBusinessDao) WhereNull(columns ...string) *ProjBusinessDao {
  474. return &ProjBusinessDao{M: d.M.WhereNull(columns...), Table: d.Table, TableAs: d.TableAs}
  475. }
  476. // WhereNotBetween builds "column NOT BETWEEN min AND max" statement.
  477. func (d *ProjBusinessDao) WhereNotBetween(column string, min, max interface{}) *ProjBusinessDao {
  478. return &ProjBusinessDao{M: d.M.WhereNotBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  479. }
  480. // WhereNotLike builds "column NOT LIKE like" statement.
  481. func (d *ProjBusinessDao) WhereNotLike(column string, like interface{}) *ProjBusinessDao {
  482. return &ProjBusinessDao{M: d.M.WhereNotLike(column, like), Table: d.Table, TableAs: d.TableAs}
  483. }
  484. // WhereNot builds "column != value" statement.
  485. func (d *ProjBusinessDao) WhereNot(column string, value interface{}) *ProjBusinessDao {
  486. return &ProjBusinessDao{M: d.M.WhereNot(column, value), Table: d.Table, TableAs: d.TableAs}
  487. }
  488. // WhereNotIn builds "column NOT IN (in)" statement.
  489. func (d *ProjBusinessDao) WhereNotIn(column string, in interface{}) *ProjBusinessDao {
  490. return &ProjBusinessDao{M: d.M.WhereNotIn(column, in), Table: d.Table, TableAs: d.TableAs}
  491. }
  492. // WhereNotNull builds "columns[0] IS NOT NULL AND columns[1] IS NOT NULL ..." statement.
  493. func (d *ProjBusinessDao) WhereNotNull(columns ...string) *ProjBusinessDao {
  494. return &ProjBusinessDao{M: d.M.WhereNotNull(columns...), Table: d.Table, TableAs: d.TableAs}
  495. }
  496. // WhereOr adds "OR" condition to the where statement.
  497. func (d *ProjBusinessDao) WhereOr(where interface{}, args ...interface{}) *ProjBusinessDao {
  498. return &ProjBusinessDao{M: d.M.WhereOr(where, args...), Table: d.Table, TableAs: d.TableAs}
  499. }
  500. // WhereOrf builds "OR" condition string using fmt.Sprintf and arguments.
  501. func (d *ProjBusinessDao) WhereOrf(format string, args ...interface{}) *ProjBusinessDao {
  502. return &ProjBusinessDao{M: d.M.WhereOrf(format, args...), Table: d.Table, TableAs: d.TableAs}
  503. }
  504. // WhereOrLT builds "column < value" statement in "OR" conditions..
  505. func (d *ProjBusinessDao) WhereOrLT(column string, value interface{}) *ProjBusinessDao {
  506. return &ProjBusinessDao{M: d.M.WhereOrLT(column, value), Table: d.Table, TableAs: d.TableAs}
  507. }
  508. // WhereOrLTE builds "column <= value" statement in "OR" conditions..
  509. func (d *ProjBusinessDao) WhereOrLTE(column string, value interface{}) *ProjBusinessDao {
  510. return &ProjBusinessDao{M: d.M.WhereOrLTE(column, value), Table: d.Table, TableAs: d.TableAs}
  511. }
  512. // WhereOrGT builds "column > value" statement in "OR" conditions..
  513. func (d *ProjBusinessDao) WhereOrGT(column string, value interface{}) *ProjBusinessDao {
  514. return &ProjBusinessDao{M: d.M.WhereOrGT(column, value), Table: d.Table, TableAs: d.TableAs}
  515. }
  516. // WhereOrGTE builds "column >= value" statement in "OR" conditions..
  517. func (d *ProjBusinessDao) WhereOrGTE(column string, value interface{}) *ProjBusinessDao {
  518. return &ProjBusinessDao{M: d.M.WhereOrGTE(column, value), Table: d.Table, TableAs: d.TableAs}
  519. }
  520. // WhereOrBetween builds "column BETWEEN min AND max" statement in "OR" conditions.
  521. func (d *ProjBusinessDao) WhereOrBetween(column string, min, max interface{}) *ProjBusinessDao {
  522. return &ProjBusinessDao{M: d.M.WhereOrBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  523. }
  524. // WhereOrLike builds "column LIKE like" statement in "OR" conditions.
  525. func (d *ProjBusinessDao) WhereOrLike(column string, like interface{}) *ProjBusinessDao {
  526. return &ProjBusinessDao{M: d.M.WhereOrLike(column, like), Table: d.Table, TableAs: d.TableAs}
  527. }
  528. // WhereOrIn builds "column IN (in)" statement in "OR" conditions.
  529. func (d *ProjBusinessDao) WhereOrIn(column string, in interface{}) *ProjBusinessDao {
  530. return &ProjBusinessDao{M: d.M.WhereOrIn(column, in), Table: d.Table, TableAs: d.TableAs}
  531. }
  532. // WhereOrNull builds "columns[0] IS NULL OR columns[1] IS NULL ..." statement in "OR" conditions.
  533. func (d *ProjBusinessDao) WhereOrNull(columns ...string) *ProjBusinessDao {
  534. return &ProjBusinessDao{M: d.M.WhereOrNull(columns...), Table: d.Table, TableAs: d.TableAs}
  535. }
  536. // WhereOrNotBetween builds "column NOT BETWEEN min AND max" statement in "OR" conditions.
  537. func (d *ProjBusinessDao) WhereOrNotBetween(column string, min, max interface{}) *ProjBusinessDao {
  538. return &ProjBusinessDao{M: d.M.WhereOrNotBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  539. }
  540. // WhereOrNotLike builds "column NOT LIKE like" statement in "OR" conditions.
  541. func (d *ProjBusinessDao) WhereOrNotLike(column string, like interface{}) *ProjBusinessDao {
  542. return &ProjBusinessDao{M: d.M.WhereOrNotLike(column, like), Table: d.Table, TableAs: d.TableAs}
  543. }
  544. // WhereOrNotIn builds "column NOT IN (in)" statement.
  545. func (d *ProjBusinessDao) WhereOrNotIn(column string, in interface{}) *ProjBusinessDao {
  546. return &ProjBusinessDao{M: d.M.WhereOrNotIn(column, in), Table: d.Table, TableAs: d.TableAs}
  547. }
  548. // WhereOrNotNull builds "columns[0] IS NOT NULL OR columns[1] IS NOT NULL ..." statement in "OR" conditions.
  549. func (d *ProjBusinessDao) WhereOrNotNull(columns ...string) *ProjBusinessDao {
  550. return &ProjBusinessDao{M: d.M.WhereOrNotNull(columns...), Table: d.Table, TableAs: d.TableAs}
  551. }
  552. // Group sets the "GROUP BY" statement for the model.
  553. func (d *ProjBusinessDao) Group(groupBy ...string) *ProjBusinessDao {
  554. return &ProjBusinessDao{M: d.M.Group(groupBy...), Table: d.Table, TableAs: d.TableAs}
  555. }
  556. // And adds "AND" condition to the where statement.
  557. // Deprecated, use Where instead.
  558. func (d *ProjBusinessDao) And(where interface{}, args ...interface{}) *ProjBusinessDao {
  559. return &ProjBusinessDao{M: d.M.And(where, args...), Table: d.Table, TableAs: d.TableAs}
  560. }
  561. // Or adds "OR" condition to the where statement.
  562. // Deprecated, use WhereOr instead.
  563. func (d *ProjBusinessDao) Or(where interface{}, args ...interface{}) *ProjBusinessDao {
  564. return &ProjBusinessDao{M: d.M.Or(where, args...), Table: d.Table, TableAs: d.TableAs}
  565. }
  566. // GroupBy sets the "GROUP BY" statement for the model.
  567. func (d *ProjBusinessDao) GroupBy(groupBy string) *ProjBusinessDao {
  568. return &ProjBusinessDao{M: d.M.Group(groupBy), Table: d.Table, TableAs: d.TableAs}
  569. }
  570. // Order sets the "ORDER BY" statement for the model.
  571. func (d *ProjBusinessDao) Order(orderBy ...string) *ProjBusinessDao {
  572. return &ProjBusinessDao{M: d.M.Order(orderBy...), Table: d.Table, TableAs: d.TableAs}
  573. }
  574. // OrderAsc sets the "ORDER BY xxx ASC" statement for the model.
  575. func (d *ProjBusinessDao) OrderAsc(column string) *ProjBusinessDao {
  576. return &ProjBusinessDao{M: d.M.OrderAsc(column), Table: d.Table, TableAs: d.TableAs}
  577. }
  578. // OrderDesc sets the "ORDER BY xxx DESC" statement for the model.
  579. func (d *ProjBusinessDao) OrderDesc(column string) *ProjBusinessDao {
  580. return &ProjBusinessDao{M: d.M.OrderDesc(column), Table: d.Table, TableAs: d.TableAs}
  581. }
  582. // OrderRandom sets the "ORDER BY RANDOM()" statement for the model.
  583. func (d *ProjBusinessDao) OrderRandom() *ProjBusinessDao {
  584. return &ProjBusinessDao{M: d.M.OrderRandom(), Table: d.Table, TableAs: d.TableAs}
  585. }
  586. // OrderBy is alias of Model.Order.
  587. // See Model.Order.
  588. // Deprecated, use Order instead.
  589. func (d *ProjBusinessDao) OrderBy(orderBy string) *ProjBusinessDao {
  590. return &ProjBusinessDao{M: d.M.Order(orderBy), Table: d.Table, TableAs: d.TableAs}
  591. }
  592. // Limit sets the "LIMIT" statement for the model.
  593. // The parameter <limit> can be either one or two number, if passed two number is passed,
  594. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  595. // statement.
  596. func (d *ProjBusinessDao) Limit(limit ...int) *ProjBusinessDao {
  597. return &ProjBusinessDao{M: d.M.Limit(limit...), Table: d.Table, TableAs: d.TableAs}
  598. }
  599. // Offset sets the "OFFSET" statement for the model.
  600. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  601. func (d *ProjBusinessDao) Offset(offset int) *ProjBusinessDao {
  602. return &ProjBusinessDao{M: d.M.Offset(offset), Table: d.Table, TableAs: d.TableAs}
  603. }
  604. // Distinct forces the query to only return distinct results.
  605. func (d *ProjBusinessDao) Distinct() *ProjBusinessDao {
  606. return &ProjBusinessDao{M: d.M.Distinct(), Table: d.Table, TableAs: d.TableAs}
  607. }
  608. // Page sets the paging number for the model.
  609. // The parameter <page> is started from 1 for paging.
  610. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  611. func (d *ProjBusinessDao) Page(page, limit int) *ProjBusinessDao {
  612. return &ProjBusinessDao{M: d.M.Page(page, limit), Table: d.Table, TableAs: d.TableAs}
  613. }
  614. // Batch sets the batch operation number for the model.
  615. func (d *ProjBusinessDao) Batch(batch int) *ProjBusinessDao {
  616. return &ProjBusinessDao{M: d.M.Batch(batch), Table: d.Table, TableAs: d.TableAs}
  617. }
  618. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  619. // if there's another same sql request, it just reads and returns the result from cache, it
  620. // but not committed and executed into the database.
  621. //
  622. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  623. // If the parameter <duration> = 0, which means it never expires.
  624. // If the parameter <duration> > 0, which means it expires after <duration>.
  625. //
  626. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  627. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  628. //
  629. // Note that, the cache feature is disabled if the model is operating on a transaction.
  630. func (d *ProjBusinessDao) Cache(duration time.Duration, name ...string) *ProjBusinessDao {
  631. return &ProjBusinessDao{M: d.M.Cache(duration, name...), Table: d.Table, TableAs: d.TableAs}
  632. }
  633. // Data sets the operation data for the model.
  634. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  635. // Eg:
  636. // Data("uid=10000")
  637. // Data("uid", 10000)
  638. // Data(g.Map{"uid": 10000, "name":"john"})
  639. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  640. func (d *ProjBusinessDao) Data(data ...interface{}) *ProjBusinessDao {
  641. return &ProjBusinessDao{M: d.M.Data(data...), Table: d.Table, TableAs: d.TableAs}
  642. }
  643. // All does "SELECT FROM ..." statement for the model.
  644. // It retrieves the records from table and returns the result as []*model.ProjBusiness.
  645. // It returns nil if there's no record retrieved with the given conditions from table.
  646. //
  647. // The optional parameter <where> is the same as the parameter of M.Where function,
  648. // see M.Where.
  649. func (d *ProjBusinessDao) All(where ...interface{}) ([]*model.ProjBusiness, error) {
  650. all, err := d.M.All(where...)
  651. if err != nil {
  652. return nil, err
  653. }
  654. var entities []*model.ProjBusiness
  655. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  656. return nil, err
  657. }
  658. return entities, nil
  659. }
  660. // One retrieves one record from table and returns the result as *model.ProjBusiness.
  661. // It returns nil if there's no record retrieved with the given conditions from table.
  662. //
  663. // The optional parameter <where> is the same as the parameter of M.Where function,
  664. // see M.Where.
  665. func (d *ProjBusinessDao) One(where ...interface{}) (*model.ProjBusiness, error) {
  666. one, err := d.M.One(where...)
  667. if err != nil {
  668. return nil, err
  669. }
  670. var entity *model.ProjBusiness
  671. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  672. return nil, err
  673. }
  674. return entity, nil
  675. }
  676. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  677. // Also see M.WherePri and M.One.
  678. func (d *ProjBusinessDao) FindOne(where ...interface{}) (*model.ProjBusiness, error) {
  679. one, err := d.M.FindOne(where...)
  680. if err != nil {
  681. return nil, err
  682. }
  683. var entity *model.ProjBusiness
  684. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  685. return nil, err
  686. }
  687. return entity, nil
  688. }
  689. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  690. // Also see M.WherePri and M.All.
  691. func (d *ProjBusinessDao) FindAll(where ...interface{}) ([]*model.ProjBusiness, error) {
  692. all, err := d.M.FindAll(where...)
  693. if err != nil {
  694. return nil, err
  695. }
  696. var entities []*model.ProjBusiness
  697. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  698. return nil, err
  699. }
  700. return entities, nil
  701. }
  702. // Struct retrieves one record from table and converts it into given struct.
  703. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  704. // it can create the struct internally during converting.
  705. //
  706. // The optional parameter <where> is the same as the parameter of Model.Where function,
  707. // see Model.Where.
  708. //
  709. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  710. // from table and <pointer> is not nil.
  711. //
  712. // Eg:
  713. // user := new(User)
  714. // err := dao.User.Where("id", 1).Struct(user)
  715. //
  716. // user := (*User)(nil)
  717. // err := dao.User.Where("id", 1).Struct(&user)
  718. func (d *ProjBusinessDao) Struct(pointer interface{}, where ...interface{}) error {
  719. return d.M.Struct(pointer, where...)
  720. }
  721. // Structs retrieves records from table and converts them into given struct slice.
  722. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  723. // slice internally during converting.
  724. //
  725. // The optional parameter <where> is the same as the parameter of Model.Where function,
  726. // see Model.Where.
  727. //
  728. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  729. // from table and <pointer> is not empty.
  730. //
  731. // Eg:
  732. // users := ([]User)(nil)
  733. // err := dao.User.Structs(&users)
  734. //
  735. // users := ([]*User)(nil)
  736. // err := dao.User.Structs(&users)
  737. func (d *ProjBusinessDao) Structs(pointer interface{}, where ...interface{}) error {
  738. return d.M.Structs(pointer, where...)
  739. }
  740. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  741. // It calls function Struct if <pointer> is type of *struct/**struct.
  742. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  743. //
  744. // The optional parameter <where> is the same as the parameter of Model.Where function,
  745. // see Model.Where.
  746. //
  747. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  748. //
  749. // Eg:
  750. // user := new(User)
  751. // err := dao.User.Where("id", 1).Scan(user)
  752. //
  753. // user := (*User)(nil)
  754. // err := dao.User.Where("id", 1).Scan(&user)
  755. //
  756. // users := ([]User)(nil)
  757. // err := dao.User.Scan(&users)
  758. //
  759. // users := ([]*User)(nil)
  760. // err := dao.User.Scan(&users)
  761. func (d *ProjBusinessDao) Scan(pointer interface{}, where ...interface{}) error {
  762. return d.M.Scan(pointer, where...)
  763. }
  764. // Chunk iterates the table with given size and callback function.
  765. func (d *ProjBusinessDao) Chunk(limit int, callback func(entities []*model.ProjBusiness, err error) bool) {
  766. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  767. var entities []*model.ProjBusiness
  768. err = result.Structs(&entities)
  769. if err == sql.ErrNoRows {
  770. return false
  771. }
  772. return callback(entities, err)
  773. })
  774. }
  775. // LockUpdate sets the lock for update for current operation.
  776. func (d *ProjBusinessDao) LockUpdate() *ProjBusinessDao {
  777. return &ProjBusinessDao{M: d.M.LockUpdate(), Table: d.Table, TableAs: d.TableAs}
  778. }
  779. // LockShared sets the lock in share mode for current operation.
  780. func (d *ProjBusinessDao) LockShared() *ProjBusinessDao {
  781. return &ProjBusinessDao{M: d.M.LockShared(), Table: d.Table, TableAs: d.TableAs}
  782. }
  783. // Unscoped enables/disables the soft deleting feature.
  784. func (d *ProjBusinessDao) Unscoped() *ProjBusinessDao {
  785. return &ProjBusinessDao{M: d.M.Unscoped(), Table: d.Table, TableAs: d.TableAs}
  786. }
  787. // DataScope enables the DataScope feature.
  788. func (d *ProjBusinessDao) DataScope(ctx context.Context, userCol ...string) *ProjBusinessDao {
  789. cs := ctx.Value("contextService")
  790. dataScope := gconv.Map(gconv.String(gconv.Map(cs)["dataScope"]))
  791. if dataScope != nil {
  792. tableAs := d.TableAs
  793. if d.TableAs != "" {
  794. tableAs += "."
  795. }
  796. userIds, ok := dataScope["userIds"]
  797. delete(dataScope, "userIds")
  798. var orColumns []string
  799. var orValues []interface{}
  800. if ok && userIds != "-1" {
  801. column := "created_by"
  802. if len(userCol) == 1 {
  803. column = userCol[0]
  804. }
  805. if ok, _ := d.M.HasField(column); ok {
  806. orColumns = append(orColumns, tableAs+column+" IN (?) ")
  807. orValues = append(orValues, userIds)
  808. }
  809. }
  810. // 销售工程师判断
  811. var salesEngineerFlag bool
  812. if roles, ok := dataScope["roles"]; ok {
  813. arr := garray.NewArrayFrom(roles.([]interface{}), true)
  814. if arr.Len() == 1 && arr.Contains("SalesEngineer") {
  815. salesEngineerFlag = true
  816. }
  817. }
  818. // 非销售工程师权限加成
  819. if !salesEngineerFlag {
  820. bigColumns := "is_big"
  821. if ok, _ := d.M.HasField("is_big"); ok {
  822. if val, ok := dataScope[bigColumns]; ok && val != "" {
  823. orColumns = append(orColumns, tableAs+bigColumns+" = ? ")
  824. orValues = append(orValues, val)
  825. }
  826. delete(dataScope, bigColumns)
  827. }
  828. var andColumns []string
  829. var andValues []interface{}
  830. for k, v := range dataScope {
  831. if ok, _ := d.M.HasField(k); ok {
  832. andColumns = append(andColumns, tableAs+k+" IN (?) ")
  833. andValues = append(andValues, v)
  834. }
  835. }
  836. if len(andColumns) > 0 {
  837. andWhereSql := strings.Join(andColumns, " AND ")
  838. orColumns = append(orColumns, "("+andWhereSql+")")
  839. orValues = append(orValues, andValues...)
  840. }
  841. }
  842. whereSql := strings.Join(orColumns, " OR ")
  843. return &ProjBusinessDao{M: d.M.Where(whereSql, orValues...).Ctx(ctx), Table: d.Table, TableAs: d.TableAs}
  844. }
  845. return d
  846. }