proj_business.go 42 KB

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