sys_user_group.go 30 KB

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