plat_task.go 17 KB

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