plat_task.go 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  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. "github.com/gogf/gf/util/gconv"
  12. "strings"
  13. "time"
  14. model "dashoo.cn/micro/app/model/plat"
  15. )
  16. // PlatTaskDao is the manager for logic model data accessing and custom defined data operations functions management.
  17. type PlatTaskDao struct {
  18. gmvc.M // M is the core and embedded struct that inherits all chaining operations from gdb.Model.
  19. C platTaskColumns // C is the short type for Columns, which contains all the column names of Table for convenient usage.
  20. DB gdb.DB // DB is the raw underlying database management object.
  21. Table string // Table is the underlying table name of the DAO.
  22. TableAs string // TableAs is the underlying table alias name of the DAO.
  23. }
  24. // PlatTaskColumns defines and stores column names for table plat_task.
  25. type platTaskColumns struct {
  26. Id string // 主键
  27. TaskTitle string // 任务标题
  28. TaskType string // 任务类型
  29. TaskStatus string // 任务状态(10发起 20进行中 30流程完成)
  30. Source string // 督办事项来源
  31. IsOverdue string // 是否超期(10否20是)
  32. TaskStartDate string // 发布时间
  33. TaskEndDate string // 要求完成时间
  34. TaskDesc string // 督办内容
  35. MainUserId string // 负责人ID
  36. OwnerUserId string // 协办人ID
  37. TaskLabel string // 任务标签,号拼接
  38. SupervisorUserId string // 督办人ID
  39. WatchUserId string // 监办人ID
  40. TargetId string // 关联对象ID
  41. TargetType string // 关联对象类型(10客户,20项目,30合同,40回款)
  42. TargetName string // 关联对象
  43. ApproverId string // 审批人ID
  44. ApproDate string // 审批时间
  45. ApproStatus string // 审批结果
  46. ApproDesc string // 审批说明
  47. EvaluatorId string // 评价人ID
  48. EvaluateDate string // 评价时间
  49. EvaluateStatus string // 评价结果
  50. EvaluateDesc string // 评价说明
  51. ReceiveDate string // 接收时间
  52. ActualCloseDate string // 实际完成时间
  53. Remark string // 备注
  54. CreatedBy string // 创建者
  55. CreatedName string // 创建人
  56. CreatedTime string // 创建时间
  57. UpdatedBy string // 更新者
  58. UpdatedName string // 更新人
  59. UpdatedTime string // 更新时间
  60. DeletedTime string // 删除时间
  61. }
  62. var (
  63. // PlatTask is globally public accessible object for table plat_task operations.
  64. PlatTask = PlatTaskDao{
  65. M: g.DB("default").Model("plat_task").Safe(),
  66. DB: g.DB("default"),
  67. Table: "plat_task",
  68. C: platTaskColumns{
  69. Id: "id",
  70. TaskTitle: "task_title",
  71. TaskType: "task_type",
  72. TaskStatus: "task_status",
  73. Source: "source",
  74. IsOverdue: "is_overdue",
  75. TaskStartDate: "task_start_date",
  76. TaskEndDate: "task_end_date",
  77. TaskDesc: "task_desc",
  78. MainUserId: "main_user_id",
  79. OwnerUserId: "owner_user_id",
  80. TaskLabel: "task_label",
  81. SupervisorUserId: "supervisor_user_id",
  82. WatchUserId: "watch_user_id",
  83. TargetId: "target_id",
  84. TargetType: "target_type",
  85. TargetName: "target_name",
  86. ApproverId: "approver_id",
  87. ApproDate: "appro_date",
  88. ApproStatus: "appro_status",
  89. ApproDesc: "appro_desc",
  90. EvaluatorId: "evaluator_id",
  91. EvaluateDate: "evaluate_date",
  92. EvaluateStatus: "evaluate_status",
  93. EvaluateDesc: "evaluate_desc",
  94. ReceiveDate: "receive_date",
  95. ActualCloseDate: "actual_close_date",
  96. Remark: "remark",
  97. CreatedBy: "created_by",
  98. CreatedName: "created_name",
  99. CreatedTime: "created_time",
  100. UpdatedBy: "updated_by",
  101. UpdatedName: "updated_name",
  102. UpdatedTime: "updated_time",
  103. DeletedTime: "deleted_time",
  104. },
  105. }
  106. )
  107. func NewPlatTaskDao(tenant string) PlatTaskDao {
  108. var dao PlatTaskDao
  109. dao = PlatTaskDao{
  110. M: g.DB(tenant).Model("plat_task").Safe(),
  111. DB: g.DB(tenant),
  112. Table: "plat_task",
  113. C: platTaskColumns{
  114. Id: "id",
  115. TaskTitle: "task_title",
  116. TaskType: "task_type",
  117. TaskStatus: "task_status",
  118. Source: "source",
  119. IsOverdue: "is_overdue",
  120. TaskStartDate: "task_start_date",
  121. TaskEndDate: "task_end_date",
  122. TaskDesc: "task_desc",
  123. MainUserId: "main_user_id",
  124. OwnerUserId: "owner_user_id",
  125. TaskLabel: "task_label",
  126. SupervisorUserId: "supervisor_user_id",
  127. WatchUserId: "watch_user_id",
  128. TargetId: "target_id",
  129. TargetType: "target_type",
  130. TargetName: "target_name",
  131. ApproverId: "approver_id",
  132. ApproDate: "appro_date",
  133. ApproStatus: "appro_status",
  134. ApproDesc: "appro_desc",
  135. EvaluatorId: "evaluator_id",
  136. EvaluateDate: "evaluate_date",
  137. EvaluateStatus: "evaluate_status",
  138. EvaluateDesc: "evaluate_desc",
  139. ReceiveDate: "receive_date",
  140. ActualCloseDate: "actual_close_date",
  141. Remark: "remark",
  142. CreatedBy: "created_by",
  143. CreatedName: "created_name",
  144. CreatedTime: "created_time",
  145. UpdatedBy: "updated_by",
  146. UpdatedName: "updated_name",
  147. UpdatedTime: "updated_time",
  148. DeletedTime: "deleted_time",
  149. },
  150. }
  151. return dao
  152. }
  153. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  154. // of current DB object and with given context in it.
  155. // Note that this returned DB object can be used only once, so do not assign it to
  156. // a global or package variable for long using.
  157. func (d *PlatTaskDao) Ctx(ctx context.Context) *PlatTaskDao {
  158. return &PlatTaskDao{M: d.M.Ctx(ctx), Table: d.Table, TableAs: d.TableAs}
  159. }
  160. // GetCtx returns the context for current Model.
  161. // It returns "context.Background() i"s there's no context previously set.
  162. func (d *PlatTaskDao) GetCtx() context.Context {
  163. return d.M.GetCtx()
  164. }
  165. // As sets an alias name for current table.
  166. func (d *PlatTaskDao) As(as string) *PlatTaskDao {
  167. return &PlatTaskDao{M: d.M.As(as), Table: d.Table, TableAs: as}
  168. }
  169. // TX sets the transaction for current operation.
  170. func (d *PlatTaskDao) TX(tx *gdb.TX) *PlatTaskDao {
  171. return &PlatTaskDao{M: d.M.TX(tx), Table: d.Table, TableAs: d.TableAs}
  172. }
  173. // Master marks the following operation on master node.
  174. func (d *PlatTaskDao) Master() *PlatTaskDao {
  175. return &PlatTaskDao{M: d.M.Master(), Table: d.Table, TableAs: d.TableAs}
  176. }
  177. // Slave marks the following operation on slave node.
  178. // Note that it makes sense only if there's any slave node configured.
  179. func (d *PlatTaskDao) Slave() *PlatTaskDao {
  180. return &PlatTaskDao{M: d.M.Slave(), Table: d.Table, TableAs: d.TableAs}
  181. }
  182. // Args sets custom arguments for model operation.
  183. func (d *PlatTaskDao) Args(args ...interface{}) *PlatTaskDao {
  184. return &PlatTaskDao{M: d.M.Args(args...), Table: d.Table, TableAs: d.TableAs}
  185. }
  186. // Handler calls each of "handlers" on current Model and returns a new Model.
  187. // ModelHandler is a function that handles given Model and returns a new Model that is custom modified.
  188. func (d *PlatTaskDao) Handler(handlers ...gdb.ModelHandler) *PlatTaskDao {
  189. return &PlatTaskDao{M: d.M.Handler(handlers...), Table: d.Table, TableAs: d.TableAs}
  190. }
  191. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  192. // The parameter <table> can be joined table and its joined condition,
  193. // and also with its alias name, like:
  194. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  195. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  196. func (d *PlatTaskDao) LeftJoin(table ...string) *PlatTaskDao {
  197. return &PlatTaskDao{M: d.M.LeftJoin(table...), Table: d.Table, TableAs: d.TableAs}
  198. }
  199. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  200. // The parameter <table> can be joined table and its joined condition,
  201. // and also with its alias name, like:
  202. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  203. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  204. func (d *PlatTaskDao) RightJoin(table ...string) *PlatTaskDao {
  205. return &PlatTaskDao{M: d.M.RightJoin(table...), Table: d.Table, TableAs: d.TableAs}
  206. }
  207. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  208. // The parameter <table> can be joined table and its joined condition,
  209. // and also with its alias name, like:
  210. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  211. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  212. func (d *PlatTaskDao) InnerJoin(table ...string) *PlatTaskDao {
  213. return &PlatTaskDao{M: d.M.InnerJoin(table...), Table: d.Table, TableAs: d.TableAs}
  214. }
  215. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  216. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  217. func (d *PlatTaskDao) Fields(fieldNamesOrMapStruct ...interface{}) *PlatTaskDao {
  218. return &PlatTaskDao{M: d.M.Fields(fieldNamesOrMapStruct...), Table: d.Table, TableAs: d.TableAs}
  219. }
  220. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  221. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  222. func (d *PlatTaskDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *PlatTaskDao {
  223. return &PlatTaskDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...), Table: d.Table, TableAs: d.TableAs}
  224. }
  225. // FieldCount formats and appends commonly used field "COUNT(column)" to the select fields of model.
  226. func (d *PlatTaskDao) FieldCount(column string, as ...string) *PlatTaskDao {
  227. return &PlatTaskDao{M: d.M.FieldCount(column, as...), Table: d.Table, TableAs: d.TableAs}
  228. }
  229. // FieldSum formats and appends commonly used field "SUM(column)" to the select fields of model.
  230. func (d *PlatTaskDao) FieldSum(column string, as ...string) *PlatTaskDao {
  231. return &PlatTaskDao{M: d.M.FieldSum(column, as...), Table: d.Table, TableAs: d.TableAs}
  232. }
  233. // FieldMin formats and appends commonly used field "MIN(column)" to the select fields of model.
  234. func (d *PlatTaskDao) FieldMin(column string, as ...string) *PlatTaskDao {
  235. return &PlatTaskDao{M: d.M.FieldMin(column, as...), Table: d.Table, TableAs: d.TableAs}
  236. }
  237. // FieldMax formats and appends commonly used field "MAX(column)" to the select fields of model.
  238. func (d *PlatTaskDao) FieldMax(column string, as ...string) *PlatTaskDao {
  239. return &PlatTaskDao{M: d.M.FieldMax(column, as...), Table: d.Table, TableAs: d.TableAs}
  240. }
  241. // FieldAvg formats and appends commonly used field "AVG(column)" to the select fields of model.
  242. func (d *PlatTaskDao) FieldAvg(column string, as ...string) *PlatTaskDao {
  243. return &PlatTaskDao{M: d.M.FieldAvg(column, as...), Table: d.Table, TableAs: d.TableAs}
  244. }
  245. // Option adds extra operation option for the model.
  246. // Deprecated, use separate operations instead.
  247. func (d *PlatTaskDao) Option(option int) *PlatTaskDao {
  248. return &PlatTaskDao{M: d.M.Option(option), Table: d.Table, TableAs: d.TableAs}
  249. }
  250. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  251. // the data and where attributes for empty values.
  252. func (d *PlatTaskDao) OmitEmpty() *PlatTaskDao {
  253. return &PlatTaskDao{M: d.M.OmitEmpty(), Table: d.Table, TableAs: d.TableAs}
  254. }
  255. // OmitEmptyWhere sets optionOmitEmptyWhere option for the model, which automatically filers
  256. // the Where/Having parameters for "empty" values.
  257. func (d *PlatTaskDao) OmitEmptyWhere() *PlatTaskDao {
  258. return &PlatTaskDao{M: d.M.OmitEmptyWhere(), Table: d.Table, TableAs: d.TableAs}
  259. }
  260. // OmitEmptyData sets optionOmitEmptyData option for the model, which automatically filers
  261. // the Data parameters for "empty" values.
  262. func (d *PlatTaskDao) OmitEmptyData() *PlatTaskDao {
  263. return &PlatTaskDao{M: d.M.OmitEmptyData(), Table: d.Table, TableAs: d.TableAs}
  264. }
  265. // OmitNil sets optionOmitNil option for the model, which automatically filers
  266. // the data and where parameters for "nil" values.
  267. func (d *PlatTaskDao) OmitNil() *PlatTaskDao {
  268. return &PlatTaskDao{M: d.M.OmitNil(), Table: d.Table, TableAs: d.TableAs}
  269. }
  270. // OmitNilWhere sets optionOmitNilWhere option for the model, which automatically filers
  271. // the Where/Having parameters for "nil" values.
  272. func (d *PlatTaskDao) OmitNilWhere() *PlatTaskDao {
  273. return &PlatTaskDao{M: d.M.OmitNilWhere(), Table: d.Table, TableAs: d.TableAs}
  274. }
  275. // OmitNilData sets optionOmitNilData option for the model, which automatically filers
  276. // the Data parameters for "nil" values.
  277. func (d *PlatTaskDao) OmitNilData() *PlatTaskDao {
  278. return &PlatTaskDao{M: d.M.OmitNilData(), Table: d.Table, TableAs: d.TableAs}
  279. }
  280. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  281. // Note that this function supports only single table operations.
  282. // Deprecated, filter feature is automatically enabled from GoFrame v1.16.0, it is so no longer used.
  283. func (d *PlatTaskDao) Filter() *PlatTaskDao {
  284. return &PlatTaskDao{M: d.M.Filter(), Table: d.Table, TableAs: d.TableAs}
  285. }
  286. // Where sets the condition statement for the model. The parameter <where> can be type of
  287. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  288. // multiple conditions will be joined into where statement using "AND".
  289. // Eg:
  290. // Where("uid=10000")
  291. // Where("uid", 10000)
  292. // Where("money>? AND name like ?", 99999, "vip_%")
  293. // Where("uid", 1).Where("name", "john")
  294. // Where("status IN (?)", g.Slice{1,2,3})
  295. // Where("age IN(?,?)", 18, 50)
  296. // Where(User{ Id : 1, UserName : "john"})
  297. func (d *PlatTaskDao) Where(where interface{}, args ...interface{}) *PlatTaskDao {
  298. return &PlatTaskDao{M: d.M.Where(where, args...), Table: d.Table, TableAs: d.TableAs}
  299. }
  300. // WherePri does the same logic as M.Where except that if the parameter <where>
  301. // is a single condition like int/string/float/slice, it treats the condition as the primary
  302. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  303. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  304. // as string "123".
  305. func (d *PlatTaskDao) WherePri(where interface{}, args ...interface{}) *PlatTaskDao {
  306. return &PlatTaskDao{M: d.M.WherePri(where, args...), Table: d.Table, TableAs: d.TableAs}
  307. }
  308. // Having sets the having statement for the model.
  309. // The parameters of this function usage are as the same as function Where.
  310. // See Where.
  311. func (d *PlatTaskDao) Having(having interface{}, args ...interface{}) *PlatTaskDao {
  312. return &PlatTaskDao{M: d.M.Having(having, args...), Table: d.Table, TableAs: d.TableAs}
  313. }
  314. // Wheref builds condition string using fmt.Sprintf and arguments.
  315. // Note that if the number of "args" is more than the place holder in "format",
  316. // the extra "args" will be used as the where condition arguments of the Model.
  317. func (d *PlatTaskDao) Wheref(format string, args ...interface{}) *PlatTaskDao {
  318. return &PlatTaskDao{M: d.M.Wheref(format, args...), Table: d.Table, TableAs: d.TableAs}
  319. }
  320. // WhereLT builds "column < value" statement.
  321. func (d *PlatTaskDao) WhereLT(column string, value interface{}) *PlatTaskDao {
  322. return &PlatTaskDao{M: d.M.WhereLT(column, value), Table: d.Table, TableAs: d.TableAs}
  323. }
  324. // WhereLTE builds "column <= value" statement.
  325. func (d *PlatTaskDao) WhereLTE(column string, value interface{}) *PlatTaskDao {
  326. return &PlatTaskDao{M: d.M.WhereLTE(column, value), Table: d.Table, TableAs: d.TableAs}
  327. }
  328. // WhereGT builds "column > value" statement.
  329. func (d *PlatTaskDao) WhereGT(column string, value interface{}) *PlatTaskDao {
  330. return &PlatTaskDao{M: d.M.WhereGT(column, value), Table: d.Table, TableAs: d.TableAs}
  331. }
  332. // WhereGTE builds "column >= value" statement.
  333. func (d *PlatTaskDao) WhereGTE(column string, value interface{}) *PlatTaskDao {
  334. return &PlatTaskDao{M: d.M.WhereGTE(column, value), Table: d.Table, TableAs: d.TableAs}
  335. }
  336. // WhereBetween builds "column BETWEEN min AND max" statement.
  337. func (d *PlatTaskDao) WhereBetween(column string, min, max interface{}) *PlatTaskDao {
  338. return &PlatTaskDao{M: d.M.WhereBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  339. }
  340. // WhereLike builds "column LIKE like" statement.
  341. func (d *PlatTaskDao) WhereLike(column string, like interface{}) *PlatTaskDao {
  342. return &PlatTaskDao{M: d.M.WhereLike(column, like), Table: d.Table, TableAs: d.TableAs}
  343. }
  344. // WhereIn builds "column IN (in)" statement.
  345. func (d *PlatTaskDao) WhereIn(column string, in interface{}) *PlatTaskDao {
  346. return &PlatTaskDao{M: d.M.WhereIn(column, in), Table: d.Table, TableAs: d.TableAs}
  347. }
  348. // WhereNull builds "columns[0] IS NULL AND columns[1] IS NULL ..." statement.
  349. func (d *PlatTaskDao) WhereNull(columns ...string) *PlatTaskDao {
  350. return &PlatTaskDao{M: d.M.WhereNull(columns...), Table: d.Table, TableAs: d.TableAs}
  351. }
  352. // WhereNotBetween builds "column NOT BETWEEN min AND max" statement.
  353. func (d *PlatTaskDao) WhereNotBetween(column string, min, max interface{}) *PlatTaskDao {
  354. return &PlatTaskDao{M: d.M.WhereNotBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  355. }
  356. // WhereNotLike builds "column NOT LIKE like" statement.
  357. func (d *PlatTaskDao) WhereNotLike(column string, like interface{}) *PlatTaskDao {
  358. return &PlatTaskDao{M: d.M.WhereNotLike(column, like), Table: d.Table, TableAs: d.TableAs}
  359. }
  360. // WhereNot builds "column != value" statement.
  361. func (d *PlatTaskDao) WhereNot(column string, value interface{}) *PlatTaskDao {
  362. return &PlatTaskDao{M: d.M.WhereNot(column, value), Table: d.Table, TableAs: d.TableAs}
  363. }
  364. // WhereNotIn builds "column NOT IN (in)" statement.
  365. func (d *PlatTaskDao) WhereNotIn(column string, in interface{}) *PlatTaskDao {
  366. return &PlatTaskDao{M: d.M.WhereNotIn(column, in), Table: d.Table, TableAs: d.TableAs}
  367. }
  368. // WhereNotNull builds "columns[0] IS NOT NULL AND columns[1] IS NOT NULL ..." statement.
  369. func (d *PlatTaskDao) WhereNotNull(columns ...string) *PlatTaskDao {
  370. return &PlatTaskDao{M: d.M.WhereNotNull(columns...), Table: d.Table, TableAs: d.TableAs}
  371. }
  372. // WhereOr adds "OR" condition to the where statement.
  373. func (d *PlatTaskDao) WhereOr(where interface{}, args ...interface{}) *PlatTaskDao {
  374. return &PlatTaskDao{M: d.M.WhereOr(where, args...), Table: d.Table, TableAs: d.TableAs}
  375. }
  376. // WhereOrf builds "OR" condition string using fmt.Sprintf and arguments.
  377. func (d *PlatTaskDao) WhereOrf(format string, args ...interface{}) *PlatTaskDao {
  378. return &PlatTaskDao{M: d.M.WhereOrf(format, args...), Table: d.Table, TableAs: d.TableAs}
  379. }
  380. // WhereOrLT builds "column < value" statement in "OR" conditions..
  381. func (d *PlatTaskDao) WhereOrLT(column string, value interface{}) *PlatTaskDao {
  382. return &PlatTaskDao{M: d.M.WhereOrLT(column, value), Table: d.Table, TableAs: d.TableAs}
  383. }
  384. // WhereOrLTE builds "column <= value" statement in "OR" conditions..
  385. func (d *PlatTaskDao) WhereOrLTE(column string, value interface{}) *PlatTaskDao {
  386. return &PlatTaskDao{M: d.M.WhereOrLTE(column, value), Table: d.Table, TableAs: d.TableAs}
  387. }
  388. // WhereOrGT builds "column > value" statement in "OR" conditions..
  389. func (d *PlatTaskDao) WhereOrGT(column string, value interface{}) *PlatTaskDao {
  390. return &PlatTaskDao{M: d.M.WhereOrGT(column, value), Table: d.Table, TableAs: d.TableAs}
  391. }
  392. // WhereOrGTE builds "column >= value" statement in "OR" conditions..
  393. func (d *PlatTaskDao) WhereOrGTE(column string, value interface{}) *PlatTaskDao {
  394. return &PlatTaskDao{M: d.M.WhereOrGTE(column, value), Table: d.Table, TableAs: d.TableAs}
  395. }
  396. // WhereOrBetween builds "column BETWEEN min AND max" statement in "OR" conditions.
  397. func (d *PlatTaskDao) WhereOrBetween(column string, min, max interface{}) *PlatTaskDao {
  398. return &PlatTaskDao{M: d.M.WhereOrBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  399. }
  400. // WhereOrLike builds "column LIKE like" statement in "OR" conditions.
  401. func (d *PlatTaskDao) WhereOrLike(column string, like interface{}) *PlatTaskDao {
  402. return &PlatTaskDao{M: d.M.WhereOrLike(column, like), Table: d.Table, TableAs: d.TableAs}
  403. }
  404. // WhereOrIn builds "column IN (in)" statement in "OR" conditions.
  405. func (d *PlatTaskDao) WhereOrIn(column string, in interface{}) *PlatTaskDao {
  406. return &PlatTaskDao{M: d.M.WhereOrIn(column, in), Table: d.Table, TableAs: d.TableAs}
  407. }
  408. // WhereOrNull builds "columns[0] IS NULL OR columns[1] IS NULL ..." statement in "OR" conditions.
  409. func (d *PlatTaskDao) WhereOrNull(columns ...string) *PlatTaskDao {
  410. return &PlatTaskDao{M: d.M.WhereOrNull(columns...), Table: d.Table, TableAs: d.TableAs}
  411. }
  412. // WhereOrNotBetween builds "column NOT BETWEEN min AND max" statement in "OR" conditions.
  413. func (d *PlatTaskDao) WhereOrNotBetween(column string, min, max interface{}) *PlatTaskDao {
  414. return &PlatTaskDao{M: d.M.WhereOrNotBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  415. }
  416. // WhereOrNotLike builds "column NOT LIKE like" statement in "OR" conditions.
  417. func (d *PlatTaskDao) WhereOrNotLike(column string, like interface{}) *PlatTaskDao {
  418. return &PlatTaskDao{M: d.M.WhereOrNotLike(column, like), Table: d.Table, TableAs: d.TableAs}
  419. }
  420. // WhereOrNotIn builds "column NOT IN (in)" statement.
  421. func (d *PlatTaskDao) WhereOrNotIn(column string, in interface{}) *PlatTaskDao {
  422. return &PlatTaskDao{M: d.M.WhereOrNotIn(column, in), Table: d.Table, TableAs: d.TableAs}
  423. }
  424. // WhereOrNotNull builds "columns[0] IS NOT NULL OR columns[1] IS NOT NULL ..." statement in "OR" conditions.
  425. func (d *PlatTaskDao) WhereOrNotNull(columns ...string) *PlatTaskDao {
  426. return &PlatTaskDao{M: d.M.WhereOrNotNull(columns...), Table: d.Table, TableAs: d.TableAs}
  427. }
  428. // Group sets the "GROUP BY" statement for the model.
  429. func (d *PlatTaskDao) Group(groupBy ...string) *PlatTaskDao {
  430. return &PlatTaskDao{M: d.M.Group(groupBy...), Table: d.Table, TableAs: d.TableAs}
  431. }
  432. // And adds "AND" condition to the where statement.
  433. // Deprecated, use Where instead.
  434. func (d *PlatTaskDao) And(where interface{}, args ...interface{}) *PlatTaskDao {
  435. return &PlatTaskDao{M: d.M.And(where, args...), Table: d.Table, TableAs: d.TableAs}
  436. }
  437. // Or adds "OR" condition to the where statement.
  438. // Deprecated, use WhereOr instead.
  439. func (d *PlatTaskDao) Or(where interface{}, args ...interface{}) *PlatTaskDao {
  440. return &PlatTaskDao{M: d.M.Or(where, args...), Table: d.Table, TableAs: d.TableAs}
  441. }
  442. // GroupBy sets the "GROUP BY" statement for the model.
  443. func (d *PlatTaskDao) GroupBy(groupBy string) *PlatTaskDao {
  444. return &PlatTaskDao{M: d.M.Group(groupBy), Table: d.Table, TableAs: d.TableAs}
  445. }
  446. // Order sets the "ORDER BY" statement for the model.
  447. func (d *PlatTaskDao) Order(orderBy ...string) *PlatTaskDao {
  448. return &PlatTaskDao{M: d.M.Order(orderBy...), Table: d.Table, TableAs: d.TableAs}
  449. }
  450. // OrderAsc sets the "ORDER BY xxx ASC" statement for the model.
  451. func (d *PlatTaskDao) OrderAsc(column string) *PlatTaskDao {
  452. return &PlatTaskDao{M: d.M.OrderAsc(column), Table: d.Table, TableAs: d.TableAs}
  453. }
  454. // OrderDesc sets the "ORDER BY xxx DESC" statement for the model.
  455. func (d *PlatTaskDao) OrderDesc(column string) *PlatTaskDao {
  456. return &PlatTaskDao{M: d.M.OrderDesc(column), Table: d.Table, TableAs: d.TableAs}
  457. }
  458. // OrderRandom sets the "ORDER BY RANDOM()" statement for the model.
  459. func (d *PlatTaskDao) OrderRandom() *PlatTaskDao {
  460. return &PlatTaskDao{M: d.M.OrderRandom(), Table: d.Table, TableAs: d.TableAs}
  461. }
  462. // OrderBy is alias of Model.Order.
  463. // See Model.Order.
  464. // Deprecated, use Order instead.
  465. func (d *PlatTaskDao) OrderBy(orderBy string) *PlatTaskDao {
  466. return &PlatTaskDao{M: d.M.Order(orderBy), Table: d.Table, TableAs: d.TableAs}
  467. }
  468. // Limit sets the "LIMIT" statement for the model.
  469. // The parameter <limit> can be either one or two number, if passed two number is passed,
  470. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  471. // statement.
  472. func (d *PlatTaskDao) Limit(limit ...int) *PlatTaskDao {
  473. return &PlatTaskDao{M: d.M.Limit(limit...), Table: d.Table, TableAs: d.TableAs}
  474. }
  475. // Offset sets the "OFFSET" statement for the model.
  476. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  477. func (d *PlatTaskDao) Offset(offset int) *PlatTaskDao {
  478. return &PlatTaskDao{M: d.M.Offset(offset), Table: d.Table, TableAs: d.TableAs}
  479. }
  480. // Distinct forces the query to only return distinct results.
  481. func (d *PlatTaskDao) Distinct() *PlatTaskDao {
  482. return &PlatTaskDao{M: d.M.Distinct(), Table: d.Table, TableAs: d.TableAs}
  483. }
  484. // Page sets the paging number for the model.
  485. // The parameter <page> is started from 1 for paging.
  486. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  487. func (d *PlatTaskDao) Page(page, limit int) *PlatTaskDao {
  488. return &PlatTaskDao{M: d.M.Page(page, limit), Table: d.Table, TableAs: d.TableAs}
  489. }
  490. // Batch sets the batch operation number for the model.
  491. func (d *PlatTaskDao) Batch(batch int) *PlatTaskDao {
  492. return &PlatTaskDao{M: d.M.Batch(batch), Table: d.Table, TableAs: d.TableAs}
  493. }
  494. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  495. // if there's another same sql request, it just reads and returns the result from cache, it
  496. // but not committed and executed into the database.
  497. //
  498. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  499. // If the parameter <duration> = 0, which means it never expires.
  500. // If the parameter <duration> > 0, which means it expires after <duration>.
  501. //
  502. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  503. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  504. //
  505. // Note that, the cache feature is disabled if the model is operating on a transaction.
  506. func (d *PlatTaskDao) Cache(duration time.Duration, name ...string) *PlatTaskDao {
  507. return &PlatTaskDao{M: d.M.Cache(duration, name...), Table: d.Table, TableAs: d.TableAs}
  508. }
  509. // Data sets the operation data for the model.
  510. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  511. // Eg:
  512. // Data("uid=10000")
  513. // Data("uid", 10000)
  514. // Data(g.Map{"uid": 10000, "name":"john"})
  515. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  516. func (d *PlatTaskDao) Data(data ...interface{}) *PlatTaskDao {
  517. return &PlatTaskDao{M: d.M.Data(data...), Table: d.Table, TableAs: d.TableAs}
  518. }
  519. // All does "SELECT FROM ..." statement for the model.
  520. // It retrieves the records from table and returns the result as []*model.PlatTask.
  521. // It returns nil if there's no record retrieved with the given conditions from table.
  522. //
  523. // The optional parameter <where> is the same as the parameter of M.Where function,
  524. // see M.Where.
  525. func (d *PlatTaskDao) All(where ...interface{}) ([]*model.PlatTask, error) {
  526. all, err := d.M.All(where...)
  527. if err != nil {
  528. return nil, err
  529. }
  530. var entities []*model.PlatTask
  531. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  532. return nil, err
  533. }
  534. return entities, nil
  535. }
  536. // One retrieves one record from table and returns the result as *model.PlatTask.
  537. // It returns nil if there's no record retrieved with the given conditions from table.
  538. //
  539. // The optional parameter <where> is the same as the parameter of M.Where function,
  540. // see M.Where.
  541. func (d *PlatTaskDao) One(where ...interface{}) (*model.PlatTask, error) {
  542. one, err := d.M.One(where...)
  543. if err != nil {
  544. return nil, err
  545. }
  546. var entity *model.PlatTask
  547. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  548. return nil, err
  549. }
  550. return entity, nil
  551. }
  552. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  553. // Also see M.WherePri and M.One.
  554. func (d *PlatTaskDao) FindOne(where ...interface{}) (*model.PlatTask, error) {
  555. one, err := d.M.FindOne(where...)
  556. if err != nil {
  557. return nil, err
  558. }
  559. var entity *model.PlatTask
  560. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  561. return nil, err
  562. }
  563. return entity, nil
  564. }
  565. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  566. // Also see M.WherePri and M.All.
  567. func (d *PlatTaskDao) FindAll(where ...interface{}) ([]*model.PlatTask, error) {
  568. all, err := d.M.FindAll(where...)
  569. if err != nil {
  570. return nil, err
  571. }
  572. var entities []*model.PlatTask
  573. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  574. return nil, err
  575. }
  576. return entities, nil
  577. }
  578. // Struct retrieves one record from table and converts it into given struct.
  579. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  580. // it can create the struct internally during converting.
  581. //
  582. // The optional parameter <where> is the same as the parameter of Model.Where function,
  583. // see Model.Where.
  584. //
  585. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  586. // from table and <pointer> is not nil.
  587. //
  588. // Eg:
  589. // user := new(User)
  590. // err := dao.User.Where("id", 1).Struct(user)
  591. //
  592. // user := (*User)(nil)
  593. // err := dao.User.Where("id", 1).Struct(&user)
  594. func (d *PlatTaskDao) Struct(pointer interface{}, where ...interface{}) error {
  595. return d.M.Struct(pointer, where...)
  596. }
  597. // Structs retrieves records from table and converts them into given struct slice.
  598. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  599. // slice internally during converting.
  600. //
  601. // The optional parameter <where> is the same as the parameter of Model.Where function,
  602. // see Model.Where.
  603. //
  604. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  605. // from table and <pointer> is not empty.
  606. //
  607. // Eg:
  608. // users := ([]User)(nil)
  609. // err := dao.User.Structs(&users)
  610. //
  611. // users := ([]*User)(nil)
  612. // err := dao.User.Structs(&users)
  613. func (d *PlatTaskDao) Structs(pointer interface{}, where ...interface{}) error {
  614. return d.M.Structs(pointer, where...)
  615. }
  616. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  617. // It calls function Struct if <pointer> is type of *struct/**struct.
  618. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  619. //
  620. // The optional parameter <where> is the same as the parameter of Model.Where function,
  621. // see Model.Where.
  622. //
  623. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  624. //
  625. // Eg:
  626. // user := new(User)
  627. // err := dao.User.Where("id", 1).Scan(user)
  628. //
  629. // user := (*User)(nil)
  630. // err := dao.User.Where("id", 1).Scan(&user)
  631. //
  632. // users := ([]User)(nil)
  633. // err := dao.User.Scan(&users)
  634. //
  635. // users := ([]*User)(nil)
  636. // err := dao.User.Scan(&users)
  637. func (d *PlatTaskDao) Scan(pointer interface{}, where ...interface{}) error {
  638. return d.M.Scan(pointer, where...)
  639. }
  640. // Chunk iterates the table with given size and callback function.
  641. func (d *PlatTaskDao) Chunk(limit int, callback func(entities []*model.PlatTask, err error) bool) {
  642. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  643. var entities []*model.PlatTask
  644. err = result.Structs(&entities)
  645. if err == sql.ErrNoRows {
  646. return false
  647. }
  648. return callback(entities, err)
  649. })
  650. }
  651. // LockUpdate sets the lock for update for current operation.
  652. func (d *PlatTaskDao) LockUpdate() *PlatTaskDao {
  653. return &PlatTaskDao{M: d.M.LockUpdate(), Table: d.Table, TableAs: d.TableAs}
  654. }
  655. // LockShared sets the lock in share mode for current operation.
  656. func (d *PlatTaskDao) LockShared() *PlatTaskDao {
  657. return &PlatTaskDao{M: d.M.LockShared(), Table: d.Table, TableAs: d.TableAs}
  658. }
  659. // Unscoped enables/disables the soft deleting feature.
  660. func (d *PlatTaskDao) Unscoped() *PlatTaskDao {
  661. return &PlatTaskDao{M: d.M.Unscoped(), Table: d.Table, TableAs: d.TableAs}
  662. }
  663. // DataScope enables the DataScope feature.
  664. func (d *PlatTaskDao) DataScope(ctx context.Context, userCol ...string) *PlatTaskDao {
  665. cs := ctx.Value("contextService")
  666. dataScope := gconv.Map(cs)["dataScope"].(g.Map)
  667. if dataScope != nil {
  668. tableAs := d.TableAs
  669. if d.TableAs != "" {
  670. tableAs += "."
  671. }
  672. userIds, ok := dataScope["userIds"]
  673. delete(dataScope, "userIds")
  674. var orColumns []string
  675. var orValues []interface{}
  676. if ok && userIds != "-1" {
  677. column := "created_by"
  678. if len(userCol) == 1 {
  679. column = userCol[0]
  680. }
  681. if ok, _ := d.M.HasField(column); ok {
  682. orColumns = append(orColumns, tableAs+column+" IN (?) ")
  683. orValues = append(orValues, userIds)
  684. }
  685. if d.Table == "sys_user" {
  686. column = "id"
  687. orColumns = append(orColumns, tableAs+column+" IN (?) ")
  688. orValues = append(orValues, userIds)
  689. }
  690. }
  691. bigColumns := "is_big"
  692. if ok, _ := d.M.HasField("is_big"); ok {
  693. if val, ok := dataScope[bigColumns]; ok && val != "" {
  694. orColumns = append(orColumns, tableAs+bigColumns+" = ? ")
  695. orValues = append(orValues, val)
  696. }
  697. delete(dataScope, bigColumns)
  698. }
  699. var andColumns []string
  700. var andValues []interface{}
  701. for k, v := range dataScope {
  702. if ok, _ := d.M.HasField(k); ok {
  703. andColumns = append(andColumns, tableAs+k+" IN (?) ")
  704. andValues = append(andValues, v)
  705. }
  706. }
  707. if len(andColumns) > 0 {
  708. andWhereSql := strings.Join(andColumns, " AND ")
  709. orColumns = append(orColumns, "("+andWhereSql+")")
  710. orValues = append(orValues, andValues...)
  711. }
  712. whereSql := strings.Join(orColumns, " OR ")
  713. return &PlatTaskDao{M: d.M.Where(whereSql, orValues...).Ctx(ctx), Table: d.Table, TableAs: d.TableAs}
  714. }
  715. return d
  716. }