proj_business.go 40 KB

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