proj_business.go 42 KB

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