plat_schedule.go 32 KB

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