plat_task_handle.go 32 KB

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