plat_task.go 18 KB

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