plat_task.go 33 KB

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