plat_task.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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. "dashoo.cn/micro/app/model/plat"
  8. "database/sql"
  9. "github.com/gogf/gf/database/gdb"
  10. "github.com/gogf/gf/frame/g"
  11. "github.com/gogf/gf/frame/gmvc"
  12. "time"
  13. )
  14. // PlatTaskDao is the manager for logic model data accessing
  15. // and custom defined data operations functions management.
  16. type PlatTaskDao struct {
  17. gmvc.M
  18. DB gdb.DB
  19. Table string
  20. Columns platTaskColumns
  21. }
  22. // PlatTaskColumns defines and stores column names for table plat_task.
  23. type platTaskColumns struct {
  24. Id string // 主键
  25. TaskTitle string // 任务标题
  26. TaskType string // 任务类型
  27. TaskStatus string // 任务状态(10发起 20进行中 30流程完成)
  28. IsOverdue string // 是否超期(10否20是)
  29. TaskStartDate string // 任务开始时间
  30. TaskEndDate string // 任务结束时间
  31. TaskDesc string // 任务说明
  32. MainUserId string // 负责人ID
  33. OwnerUserId string // 团队成员ID
  34. TaskLabel string // 任务标签,号拼接
  35. SupervisorUserId string // 督办人ID
  36. WatchUserId string // 监办人ID
  37. TargetId string // 关联对象ID
  38. TargetType string // 关联对象类型(10客户,20项目,30合同,40回款)
  39. TargetName string // 关联对象
  40. ApproverId string // 审批人ID
  41. ApproDate string // 审批时间
  42. ApproStatus string // 审批结果
  43. ApproDesc string // 审批说明
  44. EvaluatorId string // 评价人ID
  45. EvaluateDate string // 评价时间
  46. EvaluateStatus string // 评价结果
  47. EvaluateDesc string // 评价说明
  48. ReceiveDate string // 接收时间
  49. ActualCloseDate string // 实际完成时间
  50. Remark string // 备注
  51. CreatedBy string // 创建者
  52. CreatedName string // 创建人
  53. CreatedTime string // 创建时间
  54. UpdatedBy string // 更新者
  55. UpdatedName string // 更新人
  56. UpdatedTime string // 更新时间
  57. DeletedTime string // 删除时间
  58. }
  59. var (
  60. // PlatTask is globally public accessible object for table plat_task operations.
  61. PlatTask = PlatTaskDao{
  62. M: g.DB("default").Model("plat_task").Safe(),
  63. DB: g.DB("default"),
  64. Table: "plat_task",
  65. Columns: platTaskColumns{
  66. Id: "id",
  67. TaskTitle: "task_title",
  68. TaskType: "task_type",
  69. TaskStatus: "task_status",
  70. IsOverdue: "is_overdue",
  71. TaskStartDate: "task_start_date",
  72. TaskEndDate: "task_end_date",
  73. TaskDesc: "task_desc",
  74. MainUserId: "main_user_id",
  75. OwnerUserId: "owner_user_id",
  76. TaskLabel: "task_label",
  77. SupervisorUserId: "supervisor_user_id",
  78. WatchUserId: "watch_user_id",
  79. TargetId: "target_id",
  80. TargetType: "target_type",
  81. TargetName: "target_name",
  82. ApproverId: "approver_id",
  83. ApproDate: "appro_date",
  84. ApproStatus: "appro_status",
  85. ApproDesc: "appro_desc",
  86. EvaluatorId: "evaluator_id",
  87. EvaluateDate: "evaluate_date",
  88. EvaluateStatus: "evaluate_status",
  89. EvaluateDesc: "evaluate_desc",
  90. ReceiveDate: "receive_date",
  91. ActualCloseDate: "actual_close_date",
  92. Remark: "remark",
  93. CreatedBy: "created_by",
  94. CreatedName: "created_name",
  95. CreatedTime: "created_time",
  96. UpdatedBy: "updated_by",
  97. UpdatedName: "updated_name",
  98. UpdatedTime: "updated_time",
  99. DeletedTime: "deleted_time",
  100. },
  101. }
  102. )
  103. func NewPlatTaskDao(tenant string) PlatTaskDao {
  104. var dao PlatTaskDao
  105. dao = PlatTaskDao{
  106. M: g.DB(tenant).Model("plat_task").Safe(),
  107. DB: g.DB(tenant),
  108. Table: "plat_task",
  109. Columns: platTaskColumns{
  110. Id: "id",
  111. TaskTitle: "task_title",
  112. TaskType: "task_type",
  113. TaskStatus: "task_status",
  114. IsOverdue: "is_overdue",
  115. TaskStartDate: "task_start_date",
  116. TaskEndDate: "task_end_date",
  117. TaskDesc: "task_desc",
  118. MainUserId: "main_user_id",
  119. OwnerUserId: "owner_user_id",
  120. TaskLabel: "task_label",
  121. SupervisorUserId: "supervisor_user_id",
  122. WatchUserId: "watch_user_id",
  123. TargetId: "target_id",
  124. TargetType: "target_type",
  125. TargetName: "target_name",
  126. ApproverId: "approver_id",
  127. ApproDate: "appro_date",
  128. ApproStatus: "appro_status",
  129. ApproDesc: "appro_desc",
  130. EvaluatorId: "evaluator_id",
  131. EvaluateDate: "evaluate_date",
  132. EvaluateStatus: "evaluate_status",
  133. EvaluateDesc: "evaluate_desc",
  134. ReceiveDate: "receive_date",
  135. ActualCloseDate: "actual_close_date",
  136. Remark: "remark",
  137. CreatedBy: "created_by",
  138. CreatedName: "created_name",
  139. CreatedTime: "created_time",
  140. UpdatedBy: "updated_by",
  141. UpdatedName: "updated_name",
  142. UpdatedTime: "updated_time",
  143. DeletedTime: "deleted_time",
  144. },
  145. }
  146. return dao
  147. }
  148. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  149. // of current DB object and with given context in it.
  150. // Note that this returned DB object can be used only once, so do not assign it to
  151. // a global or package variable for long using.
  152. func (d *PlatTaskDao) Ctx(ctx context.Context) *PlatTaskDao {
  153. return &PlatTaskDao{M: d.M.Ctx(ctx)}
  154. }
  155. // As sets an alias name for current table.
  156. func (d *PlatTaskDao) As(as string) *PlatTaskDao {
  157. return &PlatTaskDao{M: d.M.As(as)}
  158. }
  159. // TX sets the transaction for current operation.
  160. func (d *PlatTaskDao) TX(tx *gdb.TX) *PlatTaskDao {
  161. return &PlatTaskDao{M: d.M.TX(tx)}
  162. }
  163. // Master marks the following operation on master node.
  164. func (d *PlatTaskDao) Master() *PlatTaskDao {
  165. return &PlatTaskDao{M: d.M.Master()}
  166. }
  167. // Slave marks the following operation on slave node.
  168. // Note that it makes sense only if there's any slave node configured.
  169. func (d *PlatTaskDao) Slave() *PlatTaskDao {
  170. return &PlatTaskDao{M: d.M.Slave()}
  171. }
  172. // Args sets custom arguments for model operation.
  173. func (d *PlatTaskDao) Args(args ...interface{}) *PlatTaskDao {
  174. return &PlatTaskDao{M: d.M.Args(args...)}
  175. }
  176. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  177. // The parameter <table> can be joined table and its joined condition,
  178. // and also with its alias name, like:
  179. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  180. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  181. func (d *PlatTaskDao) LeftJoin(table ...string) *PlatTaskDao {
  182. return &PlatTaskDao{M: d.M.LeftJoin(table...)}
  183. }
  184. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  185. // The parameter <table> can be joined table and its joined condition,
  186. // and also with its alias name, like:
  187. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  188. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  189. func (d *PlatTaskDao) RightJoin(table ...string) *PlatTaskDao {
  190. return &PlatTaskDao{M: d.M.RightJoin(table...)}
  191. }
  192. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  193. // The parameter <table> can be joined table and its joined condition,
  194. // and also with its alias name, like:
  195. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  196. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  197. func (d *PlatTaskDao) InnerJoin(table ...string) *PlatTaskDao {
  198. return &PlatTaskDao{M: d.M.InnerJoin(table...)}
  199. }
  200. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  201. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  202. func (d *PlatTaskDao) Fields(fieldNamesOrMapStruct ...interface{}) *PlatTaskDao {
  203. return &PlatTaskDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
  204. }
  205. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  206. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  207. func (d *PlatTaskDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *PlatTaskDao {
  208. return &PlatTaskDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
  209. }
  210. // Option sets the extra operation option for the model.
  211. func (d *PlatTaskDao) Option(option int) *PlatTaskDao {
  212. return &PlatTaskDao{M: d.M.Option(option)}
  213. }
  214. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  215. // the data and where attributes for empty values.
  216. func (d *PlatTaskDao) OmitEmpty() *PlatTaskDao {
  217. return &PlatTaskDao{M: d.M.OmitEmpty()}
  218. }
  219. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  220. func (d *PlatTaskDao) Filter() *PlatTaskDao {
  221. return &PlatTaskDao{M: d.M.Filter()}
  222. }
  223. // Where sets the condition statement for the model. The parameter <where> can be type of
  224. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  225. // multiple conditions will be joined into where statement using "AND".
  226. // Eg:
  227. // Where("uid=10000")
  228. // Where("uid", 10000)
  229. // Where("money>? AND name like ?", 99999, "vip_%")
  230. // Where("uid", 1).Where("name", "john")
  231. // Where("status IN (?)", g.Slice{1,2,3})
  232. // Where("age IN(?,?)", 18, 50)
  233. // Where(User{ Id : 1, UserName : "john"})
  234. func (d *PlatTaskDao) Where(where interface{}, args ...interface{}) *PlatTaskDao {
  235. return &PlatTaskDao{M: d.M.Where(where, args...)}
  236. }
  237. // WherePri does the same logic as M.Where except that if the parameter <where>
  238. // is a single condition like int/string/float/slice, it treats the condition as the primary
  239. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  240. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  241. // as string "123".
  242. func (d *PlatTaskDao) WherePri(where interface{}, args ...interface{}) *PlatTaskDao {
  243. return &PlatTaskDao{M: d.M.WherePri(where, args...)}
  244. }
  245. // And adds "AND" condition to the where statement.
  246. func (d *PlatTaskDao) And(where interface{}, args ...interface{}) *PlatTaskDao {
  247. return &PlatTaskDao{M: d.M.And(where, args...)}
  248. }
  249. // Or adds "OR" condition to the where statement.
  250. func (d *PlatTaskDao) Or(where interface{}, args ...interface{}) *PlatTaskDao {
  251. return &PlatTaskDao{M: d.M.Or(where, args...)}
  252. }
  253. // Group sets the "GROUP BY" statement for the model.
  254. func (d *PlatTaskDao) Group(groupBy string) *PlatTaskDao {
  255. return &PlatTaskDao{M: d.M.Group(groupBy)}
  256. }
  257. // Order sets the "ORDER BY" statement for the model.
  258. func (d *PlatTaskDao) Order(orderBy ...string) *PlatTaskDao {
  259. return &PlatTaskDao{M: d.M.Order(orderBy...)}
  260. }
  261. // Limit sets the "LIMIT" statement for the model.
  262. // The parameter <limit> can be either one or two number, if passed two number is passed,
  263. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  264. // statement.
  265. func (d *PlatTaskDao) Limit(limit ...int) *PlatTaskDao {
  266. return &PlatTaskDao{M: d.M.Limit(limit...)}
  267. }
  268. // Offset sets the "OFFSET" statement for the model.
  269. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  270. func (d *PlatTaskDao) Offset(offset int) *PlatTaskDao {
  271. return &PlatTaskDao{M: d.M.Offset(offset)}
  272. }
  273. // Page sets the paging number for the model.
  274. // The parameter <page> is started from 1 for paging.
  275. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  276. func (d *PlatTaskDao) Page(page, limit int) *PlatTaskDao {
  277. return &PlatTaskDao{M: d.M.Page(page, limit)}
  278. }
  279. // Batch sets the batch operation number for the model.
  280. func (d *PlatTaskDao) Batch(batch int) *PlatTaskDao {
  281. return &PlatTaskDao{M: d.M.Batch(batch)}
  282. }
  283. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  284. // if there's another same sql request, it just reads and returns the result from cache, it
  285. // but not committed and executed into the database.
  286. //
  287. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  288. // If the parameter <duration> = 0, which means it never expires.
  289. // If the parameter <duration> > 0, which means it expires after <duration>.
  290. //
  291. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  292. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  293. //
  294. // Note that, the cache feature is disabled if the model is operating on a transaction.
  295. func (d *PlatTaskDao) Cache(duration time.Duration, name ...string) *PlatTaskDao {
  296. return &PlatTaskDao{M: d.M.Cache(duration, name...)}
  297. }
  298. // Data sets the operation data for the model.
  299. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  300. // Eg:
  301. // Data("uid=10000")
  302. // Data("uid", 10000)
  303. // Data(g.Map{"uid": 10000, "name":"john"})
  304. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  305. func (d *PlatTaskDao) Data(data ...interface{}) *PlatTaskDao {
  306. return &PlatTaskDao{M: d.M.Data(data...)}
  307. }
  308. // All does "SELECT FROM ..." statement for the model.
  309. // It retrieves the records from table and returns the result as []*model.PlatTask.
  310. // It returns nil if there's no record retrieved with the given conditions from table.
  311. //
  312. // The optional parameter <where> is the same as the parameter of M.Where function,
  313. // see M.Where.
  314. func (d *PlatTaskDao) All(where ...interface{}) ([]*plat.PlatTask, error) {
  315. all, err := d.M.All(where...)
  316. if err != nil {
  317. return nil, err
  318. }
  319. var entities []*plat.PlatTask
  320. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  321. return nil, err
  322. }
  323. return entities, nil
  324. }
  325. // One retrieves one record from table and returns the result as *model.PlatTask.
  326. // It returns nil if there's no record retrieved with the given conditions from table.
  327. //
  328. // The optional parameter <where> is the same as the parameter of M.Where function,
  329. // see M.Where.
  330. func (d *PlatTaskDao) One(where ...interface{}) (*plat.PlatTask, error) {
  331. one, err := d.M.One(where...)
  332. if err != nil {
  333. return nil, err
  334. }
  335. var entity *plat.PlatTask
  336. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  337. return nil, err
  338. }
  339. return entity, nil
  340. }
  341. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  342. // Also see M.WherePri and M.One.
  343. func (d *PlatTaskDao) FindOne(where ...interface{}) (*plat.PlatTask, error) {
  344. one, err := d.M.FindOne(where...)
  345. if err != nil {
  346. return nil, err
  347. }
  348. var entity *plat.PlatTask
  349. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  350. return nil, err
  351. }
  352. return entity, nil
  353. }
  354. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  355. // Also see M.WherePri and M.All.
  356. func (d *PlatTaskDao) FindAll(where ...interface{}) ([]*plat.PlatTask, error) {
  357. all, err := d.M.FindAll(where...)
  358. if err != nil {
  359. return nil, err
  360. }
  361. var entities []*plat.PlatTask
  362. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  363. return nil, err
  364. }
  365. return entities, nil
  366. }
  367. // Struct retrieves one record from table and converts it into given struct.
  368. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  369. // it can create the struct internally during converting.
  370. //
  371. // The optional parameter <where> is the same as the parameter of Model.Where function,
  372. // see Model.Where.
  373. //
  374. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  375. // from table and <pointer> is not nil.
  376. //
  377. // Eg:
  378. // user := new(User)
  379. // err := dao.User.Where("id", 1).Struct(user)
  380. //
  381. // user := (*User)(nil)
  382. // err := dao.User.Where("id", 1).Struct(&user)
  383. func (d *PlatTaskDao) Struct(pointer interface{}, where ...interface{}) error {
  384. return d.M.Struct(pointer, where...)
  385. }
  386. // Structs retrieves records from table and converts them into given struct slice.
  387. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  388. // slice internally during converting.
  389. //
  390. // The optional parameter <where> is the same as the parameter of Model.Where function,
  391. // see Model.Where.
  392. //
  393. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  394. // from table and <pointer> is not empty.
  395. //
  396. // Eg:
  397. // users := ([]User)(nil)
  398. // err := dao.User.Structs(&users)
  399. //
  400. // users := ([]*User)(nil)
  401. // err := dao.User.Structs(&users)
  402. func (d *PlatTaskDao) Structs(pointer interface{}, where ...interface{}) error {
  403. return d.M.Structs(pointer, where...)
  404. }
  405. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  406. // It calls function Struct if <pointer> is type of *struct/**struct.
  407. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  408. //
  409. // The optional parameter <where> is the same as the parameter of Model.Where function,
  410. // see Model.Where.
  411. //
  412. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  413. //
  414. // Eg:
  415. // user := new(User)
  416. // err := dao.User.Where("id", 1).Scan(user)
  417. //
  418. // user := (*User)(nil)
  419. // err := dao.User.Where("id", 1).Scan(&user)
  420. //
  421. // users := ([]User)(nil)
  422. // err := dao.User.Scan(&users)
  423. //
  424. // users := ([]*User)(nil)
  425. // err := dao.User.Scan(&users)
  426. func (d *PlatTaskDao) Scan(pointer interface{}, where ...interface{}) error {
  427. return d.M.Scan(pointer, where...)
  428. }
  429. // Chunk iterates the table with given size and callback function.
  430. func (d *PlatTaskDao) Chunk(limit int, callback func(entities []*plat.PlatTask, err error) bool) {
  431. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  432. var entities []*plat.PlatTask
  433. err = result.Structs(&entities)
  434. if err == sql.ErrNoRows {
  435. return false
  436. }
  437. return callback(entities, err)
  438. })
  439. }
  440. // LockUpdate sets the lock for update for current operation.
  441. func (d *PlatTaskDao) LockUpdate() *PlatTaskDao {
  442. return &PlatTaskDao{M: d.M.LockUpdate()}
  443. }
  444. // LockShared sets the lock in share mode for current operation.
  445. func (d *PlatTaskDao) LockShared() *PlatTaskDao {
  446. return &PlatTaskDao{M: d.M.LockShared()}
  447. }
  448. // Unscoped enables/disables the soft deleting feature.
  449. func (d *PlatTaskDao) Unscoped() *PlatTaskDao {
  450. return &PlatTaskDao{M: d.M.Unscoped()}
  451. }