proj_business.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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. "time"
  12. model "dashoo.cn/micro/app/model/proj"
  13. )
  14. // ProjBusinessDao is the manager for logic model data accessing
  15. // and custom defined data operations functions management.
  16. type ProjBusinessDao struct {
  17. gmvc.M
  18. DB gdb.DB
  19. Table string
  20. Columns projBusinessColumns
  21. }
  22. // ProjBusinessColumns defines and stores column names for table proj_business.
  23. type projBusinessColumns struct {
  24. Id string // 主键
  25. NboName string // 项目名称
  26. CustId string // 关联客户
  27. CustName string // 客户名称
  28. NboType string // 项目类别(A类B类C类)
  29. NboPhase string // 项目阶段(暂不起用)
  30. NboSource string // 项目来源
  31. NboBudget string // 项目预算
  32. ApproStatus string // 审批状态(10待提交20审批中30审批通过40审批退回60审批拒绝)
  33. ContactId string // 关联联系人
  34. ContactName string // 联系人姓名
  35. ContactPostion string // 联系人岗位
  36. ContactTelephone string // 联系人电话
  37. MakerId string // 关联决策人
  38. MakerName string // 决策人姓名
  39. MakerPost string // 决策人岗位
  40. MakerTelephone string // 决策人电话
  41. SalesModel string // 销售模式(10直销20经销30代理)
  42. SaleId string // 归属销售
  43. SaleName string // 销售姓名
  44. DistributorId string // 经销商/代理商ID
  45. DistributorName string // 经销商/代理商名称
  46. ObtainTime string // 获取时间
  47. FinalFollowTime string // 最后跟进时间
  48. NextFollowTime string // 下次跟进时间
  49. PlanPurchaseTime string // 计划采购时间
  50. EstTransTime string // 预计成交时间
  51. EstTransPrice string // 预计成交价格
  52. RiskProfile string // 风险情况
  53. Difficulty string // 困难点
  54. Competitor string // 竞争公司
  55. Intervention string // 介入情况
  56. DeptId string // 所属部门ID
  57. DeptName string // 所属部门
  58. Remark string // 备注
  59. CreatedBy string // 创建者
  60. CreatedName string // 创建人
  61. CreatedTime string // 创建时间
  62. UpdatedBy string // 更新者
  63. UpdatedName string // 更新人
  64. UpdatedTime string // 更新时间
  65. DeletedTime string // 删除时间
  66. }
  67. var (
  68. // ProjBusiness is globally public accessible object for table proj_business operations.
  69. ProjBusiness = ProjBusinessDao{
  70. M: g.DB("default").Model("proj_business").Safe(),
  71. DB: g.DB("default"),
  72. Table: "proj_business",
  73. Columns: projBusinessColumns{
  74. Id: "id",
  75. NboName: "nbo_name",
  76. CustId: "cust_id",
  77. CustName: "cust_name",
  78. NboType: "nbo_type",
  79. NboPhase: "nbo_phase",
  80. NboSource: "nbo_source",
  81. NboBudget: "nbo_budget",
  82. ApproStatus: "appro_status",
  83. ContactId: "contact_id",
  84. ContactName: "contact_name",
  85. ContactPostion: "contact_postion",
  86. ContactTelephone: "contact_telephone",
  87. MakerId: "maker_id",
  88. MakerName: "maker_name",
  89. MakerPost: "maker_post",
  90. MakerTelephone: "maker_telephone",
  91. SalesModel: "sales_model",
  92. SaleId: "sale_id",
  93. SaleName: "sale_name",
  94. DistributorId: "distributor_id",
  95. DistributorName: "distributor_name",
  96. ObtainTime: "obtain_time",
  97. FinalFollowTime: "final_follow_time",
  98. NextFollowTime: "next_follow_time",
  99. PlanPurchaseTime: "plan_purchase_time",
  100. EstTransTime: "est_trans_time",
  101. EstTransPrice: "est_trans_price",
  102. RiskProfile: "risk_profile",
  103. Difficulty: "difficulty",
  104. Competitor: "competitor",
  105. Intervention: "Intervention",
  106. DeptId: "dept_id",
  107. DeptName: "dept_name",
  108. Remark: "remark",
  109. CreatedBy: "created_by",
  110. CreatedName: "created_name",
  111. CreatedTime: "created_time",
  112. UpdatedBy: "updated_by",
  113. UpdatedName: "updated_name",
  114. UpdatedTime: "updated_time",
  115. DeletedTime: "deleted_time",
  116. },
  117. }
  118. )
  119. func NewProjBusinessDao(tenant string) ProjBusinessDao {
  120. var dao ProjBusinessDao
  121. dao = ProjBusinessDao{
  122. M: g.DB(tenant).Model("proj_business").Safe(),
  123. DB: g.DB(tenant),
  124. Table: "proj_business",
  125. Columns: projBusinessColumns{
  126. Id: "id",
  127. NboName: "nbo_name",
  128. CustId: "cust_id",
  129. CustName: "cust_name",
  130. NboType: "nbo_type",
  131. NboPhase: "nbo_phase",
  132. NboSource: "nbo_source",
  133. NboBudget: "nbo_budget",
  134. ApproStatus: "appro_status",
  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. MakerPost: "maker_post",
  142. MakerTelephone: "maker_telephone",
  143. SalesModel: "sales_model",
  144. SaleId: "sale_id",
  145. SaleName: "sale_name",
  146. DistributorId: "distributor_id",
  147. DistributorName: "distributor_name",
  148. ObtainTime: "obtain_time",
  149. FinalFollowTime: "final_follow_time",
  150. NextFollowTime: "next_follow_time",
  151. PlanPurchaseTime: "plan_purchase_time",
  152. EstTransTime: "est_trans_time",
  153. EstTransPrice: "est_trans_price",
  154. RiskProfile: "risk_profile",
  155. Difficulty: "difficulty",
  156. Competitor: "competitor",
  157. Intervention: "Intervention",
  158. DeptId: "dept_id",
  159. DeptName: "dept_name",
  160. Remark: "remark",
  161. CreatedBy: "created_by",
  162. CreatedName: "created_name",
  163. CreatedTime: "created_time",
  164. UpdatedBy: "updated_by",
  165. UpdatedName: "updated_name",
  166. UpdatedTime: "updated_time",
  167. DeletedTime: "deleted_time",
  168. },
  169. }
  170. return dao
  171. }
  172. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  173. // of current DB object and with given context in it.
  174. // Note that this returned DB object can be used only once, so do not assign it to
  175. // a global or package variable for long using.
  176. func (d *ProjBusinessDao) Ctx(ctx context.Context) *ProjBusinessDao {
  177. return &ProjBusinessDao{M: d.M.Ctx(ctx)}
  178. }
  179. // As sets an alias name for current table.
  180. func (d *ProjBusinessDao) As(as string) *ProjBusinessDao {
  181. return &ProjBusinessDao{M: d.M.As(as)}
  182. }
  183. // TX sets the transaction for current operation.
  184. func (d *ProjBusinessDao) TX(tx *gdb.TX) *ProjBusinessDao {
  185. return &ProjBusinessDao{M: d.M.TX(tx)}
  186. }
  187. // Master marks the following operation on master node.
  188. func (d *ProjBusinessDao) Master() *ProjBusinessDao {
  189. return &ProjBusinessDao{M: d.M.Master()}
  190. }
  191. // Slave marks the following operation on slave node.
  192. // Note that it makes sense only if there's any slave node configured.
  193. func (d *ProjBusinessDao) Slave() *ProjBusinessDao {
  194. return &ProjBusinessDao{M: d.M.Slave()}
  195. }
  196. // Args sets custom arguments for model operation.
  197. func (d *ProjBusinessDao) Args(args ...interface{}) *ProjBusinessDao {
  198. return &ProjBusinessDao{M: d.M.Args(args...)}
  199. }
  200. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  201. // The parameter <table> can be joined table and its joined condition,
  202. // and also with its alias name, like:
  203. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  204. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  205. func (d *ProjBusinessDao) LeftJoin(table ...string) *ProjBusinessDao {
  206. return &ProjBusinessDao{M: d.M.LeftJoin(table...)}
  207. }
  208. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  209. // The parameter <table> can be joined table and its joined condition,
  210. // and also with its alias name, like:
  211. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  212. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  213. func (d *ProjBusinessDao) RightJoin(table ...string) *ProjBusinessDao {
  214. return &ProjBusinessDao{M: d.M.RightJoin(table...)}
  215. }
  216. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  217. // The parameter <table> can be joined table and its joined condition,
  218. // and also with its alias name, like:
  219. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  220. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  221. func (d *ProjBusinessDao) InnerJoin(table ...string) *ProjBusinessDao {
  222. return &ProjBusinessDao{M: d.M.InnerJoin(table...)}
  223. }
  224. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  225. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  226. func (d *ProjBusinessDao) Fields(fieldNamesOrMapStruct ...interface{}) *ProjBusinessDao {
  227. return &ProjBusinessDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
  228. }
  229. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  230. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  231. func (d *ProjBusinessDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *ProjBusinessDao {
  232. return &ProjBusinessDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
  233. }
  234. // Option sets the extra operation option for the model.
  235. func (d *ProjBusinessDao) Option(option int) *ProjBusinessDao {
  236. return &ProjBusinessDao{M: d.M.Option(option)}
  237. }
  238. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  239. // the data and where attributes for empty values.
  240. func (d *ProjBusinessDao) OmitEmpty() *ProjBusinessDao {
  241. return &ProjBusinessDao{M: d.M.OmitEmpty()}
  242. }
  243. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  244. func (d *ProjBusinessDao) Filter() *ProjBusinessDao {
  245. return &ProjBusinessDao{M: d.M.Filter()}
  246. }
  247. // Where sets the condition statement for the model. The parameter <where> can be type of
  248. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  249. // multiple conditions will be joined into where statement using "AND".
  250. // Eg:
  251. // Where("uid=10000")
  252. // Where("uid", 10000)
  253. // Where("money>? AND name like ?", 99999, "vip_%")
  254. // Where("uid", 1).Where("name", "john")
  255. // Where("status IN (?)", g.Slice{1,2,3})
  256. // Where("age IN(?,?)", 18, 50)
  257. // Where(User{ Id : 1, UserName : "john"})
  258. func (d *ProjBusinessDao) Where(where interface{}, args ...interface{}) *ProjBusinessDao {
  259. return &ProjBusinessDao{M: d.M.Where(where, args...)}
  260. }
  261. // WherePri does the same logic as M.Where except that if the parameter <where>
  262. // is a single condition like int/string/float/slice, it treats the condition as the primary
  263. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  264. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  265. // as string "123".
  266. func (d *ProjBusinessDao) WherePri(where interface{}, args ...interface{}) *ProjBusinessDao {
  267. return &ProjBusinessDao{M: d.M.WherePri(where, args...)}
  268. }
  269. // And adds "AND" condition to the where statement.
  270. func (d *ProjBusinessDao) And(where interface{}, args ...interface{}) *ProjBusinessDao {
  271. return &ProjBusinessDao{M: d.M.And(where, args...)}
  272. }
  273. // Or adds "OR" condition to the where statement.
  274. func (d *ProjBusinessDao) Or(where interface{}, args ...interface{}) *ProjBusinessDao {
  275. return &ProjBusinessDao{M: d.M.Or(where, args...)}
  276. }
  277. // Group sets the "GROUP BY" statement for the model.
  278. func (d *ProjBusinessDao) Group(groupBy string) *ProjBusinessDao {
  279. return &ProjBusinessDao{M: d.M.Group(groupBy)}
  280. }
  281. // Order sets the "ORDER BY" statement for the model.
  282. func (d *ProjBusinessDao) Order(orderBy ...string) *ProjBusinessDao {
  283. return &ProjBusinessDao{M: d.M.Order(orderBy...)}
  284. }
  285. // Limit sets the "LIMIT" statement for the model.
  286. // The parameter <limit> can be either one or two number, if passed two number is passed,
  287. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  288. // statement.
  289. func (d *ProjBusinessDao) Limit(limit ...int) *ProjBusinessDao {
  290. return &ProjBusinessDao{M: d.M.Limit(limit...)}
  291. }
  292. // Offset sets the "OFFSET" statement for the model.
  293. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  294. func (d *ProjBusinessDao) Offset(offset int) *ProjBusinessDao {
  295. return &ProjBusinessDao{M: d.M.Offset(offset)}
  296. }
  297. // Page sets the paging number for the model.
  298. // The parameter <page> is started from 1 for paging.
  299. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  300. func (d *ProjBusinessDao) Page(page, limit int) *ProjBusinessDao {
  301. return &ProjBusinessDao{M: d.M.Page(page, limit)}
  302. }
  303. // Batch sets the batch operation number for the model.
  304. func (d *ProjBusinessDao) Batch(batch int) *ProjBusinessDao {
  305. return &ProjBusinessDao{M: d.M.Batch(batch)}
  306. }
  307. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  308. // if there's another same sql request, it just reads and returns the result from cache, it
  309. // but not committed and executed into the database.
  310. //
  311. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  312. // If the parameter <duration> = 0, which means it never expires.
  313. // If the parameter <duration> > 0, which means it expires after <duration>.
  314. //
  315. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  316. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  317. //
  318. // Note that, the cache feature is disabled if the model is operating on a transaction.
  319. func (d *ProjBusinessDao) Cache(duration time.Duration, name ...string) *ProjBusinessDao {
  320. return &ProjBusinessDao{M: d.M.Cache(duration, name...)}
  321. }
  322. // Data sets the operation data for the model.
  323. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  324. // Eg:
  325. // Data("uid=10000")
  326. // Data("uid", 10000)
  327. // Data(g.Map{"uid": 10000, "name":"john"})
  328. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  329. func (d *ProjBusinessDao) Data(data ...interface{}) *ProjBusinessDao {
  330. return &ProjBusinessDao{M: d.M.Data(data...)}
  331. }
  332. // All does "SELECT FROM ..." statement for the model.
  333. // It retrieves the records from table and returns the result as []*model.ProjBusiness.
  334. // It returns nil if there's no record retrieved with the given conditions from table.
  335. //
  336. // The optional parameter <where> is the same as the parameter of M.Where function,
  337. // see M.Where.
  338. func (d *ProjBusinessDao) All(where ...interface{}) ([]*model.ProjBusiness, error) {
  339. all, err := d.M.All(where...)
  340. if err != nil {
  341. return nil, err
  342. }
  343. var entities []*model.ProjBusiness
  344. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  345. return nil, err
  346. }
  347. return entities, nil
  348. }
  349. // One retrieves one record from table and returns the result as *model.ProjBusiness.
  350. // It returns nil if there's no record retrieved with the given conditions from table.
  351. //
  352. // The optional parameter <where> is the same as the parameter of M.Where function,
  353. // see M.Where.
  354. func (d *ProjBusinessDao) One(where ...interface{}) (*model.ProjBusiness, error) {
  355. one, err := d.M.One(where...)
  356. if err != nil {
  357. return nil, err
  358. }
  359. var entity *model.ProjBusiness
  360. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  361. return nil, err
  362. }
  363. return entity, nil
  364. }
  365. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  366. // Also see M.WherePri and M.One.
  367. func (d *ProjBusinessDao) FindOne(where ...interface{}) (*model.ProjBusiness, error) {
  368. one, err := d.M.FindOne(where...)
  369. if err != nil {
  370. return nil, err
  371. }
  372. var entity *model.ProjBusiness
  373. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  374. return nil, err
  375. }
  376. return entity, nil
  377. }
  378. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  379. // Also see M.WherePri and M.All.
  380. func (d *ProjBusinessDao) FindAll(where ...interface{}) ([]*model.ProjBusiness, error) {
  381. all, err := d.M.FindAll(where...)
  382. if err != nil {
  383. return nil, err
  384. }
  385. var entities []*model.ProjBusiness
  386. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  387. return nil, err
  388. }
  389. return entities, nil
  390. }
  391. // Struct retrieves one record from table and converts it into given struct.
  392. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  393. // it can create the struct internally during converting.
  394. //
  395. // The optional parameter <where> is the same as the parameter of Model.Where function,
  396. // see Model.Where.
  397. //
  398. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  399. // from table and <pointer> is not nil.
  400. //
  401. // Eg:
  402. // user := new(User)
  403. // err := dao.User.Where("id", 1).Struct(user)
  404. //
  405. // user := (*User)(nil)
  406. // err := dao.User.Where("id", 1).Struct(&user)
  407. func (d *ProjBusinessDao) Struct(pointer interface{}, where ...interface{}) error {
  408. return d.M.Struct(pointer, where...)
  409. }
  410. // Structs retrieves records from table and converts them into given struct slice.
  411. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  412. // slice internally during converting.
  413. //
  414. // The optional parameter <where> is the same as the parameter of Model.Where function,
  415. // see Model.Where.
  416. //
  417. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  418. // from table and <pointer> is not empty.
  419. //
  420. // Eg:
  421. // users := ([]User)(nil)
  422. // err := dao.User.Structs(&users)
  423. //
  424. // users := ([]*User)(nil)
  425. // err := dao.User.Structs(&users)
  426. func (d *ProjBusinessDao) Structs(pointer interface{}, where ...interface{}) error {
  427. return d.M.Structs(pointer, where...)
  428. }
  429. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  430. // It calls function Struct if <pointer> is type of *struct/**struct.
  431. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  432. //
  433. // The optional parameter <where> is the same as the parameter of Model.Where function,
  434. // see Model.Where.
  435. //
  436. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  437. //
  438. // Eg:
  439. // user := new(User)
  440. // err := dao.User.Where("id", 1).Scan(user)
  441. //
  442. // user := (*User)(nil)
  443. // err := dao.User.Where("id", 1).Scan(&user)
  444. //
  445. // users := ([]User)(nil)
  446. // err := dao.User.Scan(&users)
  447. //
  448. // users := ([]*User)(nil)
  449. // err := dao.User.Scan(&users)
  450. func (d *ProjBusinessDao) Scan(pointer interface{}, where ...interface{}) error {
  451. return d.M.Scan(pointer, where...)
  452. }
  453. // Chunk iterates the table with given size and callback function.
  454. func (d *ProjBusinessDao) Chunk(limit int, callback func(entities []*model.ProjBusiness, err error) bool) {
  455. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  456. var entities []*model.ProjBusiness
  457. err = result.Structs(&entities)
  458. if err == sql.ErrNoRows {
  459. return false
  460. }
  461. return callback(entities, err)
  462. })
  463. }
  464. // LockUpdate sets the lock for update for current operation.
  465. func (d *ProjBusinessDao) LockUpdate() *ProjBusinessDao {
  466. return &ProjBusinessDao{M: d.M.LockUpdate()}
  467. }
  468. // LockShared sets the lock in share mode for current operation.
  469. func (d *ProjBusinessDao) LockShared() *ProjBusinessDao {
  470. return &ProjBusinessDao{M: d.M.LockShared()}
  471. }
  472. // Unscoped enables/disables the soft deleting feature.
  473. func (d *ProjBusinessDao) Unscoped() *ProjBusinessDao {
  474. return &ProjBusinessDao{M: d.M.Unscoped()}
  475. }