proj_business.go 19 KB

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