plat_task.go 33 KB

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