proj_business.go 20 KB

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