sys_user_online.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. "time"
  12. "gfast/app/system/model"
  13. )
  14. // SysUserOnlineDao is the manager for logic model data accessing
  15. // and custom defined data operations functions management.
  16. type SysUserOnlineDao struct {
  17. gmvc.M
  18. DB gdb.DB
  19. Table string
  20. Columns sysUserOnlineColumns
  21. }
  22. // SysUserOnlineColumns defines and stores column names for table sys_user_online.
  23. type sysUserOnlineColumns struct {
  24. Id string //
  25. Uuid string // 用户标识
  26. Token string // 用户token
  27. CreateTime string // 登录时间
  28. UserName string // 用户名
  29. Ip string // 登录ip
  30. Explorer string // 浏览器
  31. Os string // 操作系统
  32. }
  33. var (
  34. // SysUserOnline is globally public accessible object for table sys_user_online operations.
  35. SysUserOnline = SysUserOnlineDao{
  36. M: g.DB("default").Model("sys_user_online").Safe(),
  37. DB: g.DB("default"),
  38. Table: "sys_user_online",
  39. Columns: sysUserOnlineColumns{
  40. Id: "id",
  41. Uuid: "uuid",
  42. Token: "token",
  43. CreateTime: "create_time",
  44. UserName: "user_name",
  45. Ip: "ip",
  46. Explorer: "explorer",
  47. Os: "os",
  48. },
  49. }
  50. )
  51. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  52. // of current DB object and with given context in it.
  53. // Note that this returned DB object can be used only once, so do not assign it to
  54. // a global or package variable for long using.
  55. func (d *SysUserOnlineDao) Ctx(ctx context.Context) *SysUserOnlineDao {
  56. return &SysUserOnlineDao{M: d.M.Ctx(ctx)}
  57. }
  58. // As sets an alias name for current table.
  59. func (d *SysUserOnlineDao) As(as string) *SysUserOnlineDao {
  60. return &SysUserOnlineDao{M: d.M.As(as)}
  61. }
  62. // TX sets the transaction for current operation.
  63. func (d *SysUserOnlineDao) TX(tx *gdb.TX) *SysUserOnlineDao {
  64. return &SysUserOnlineDao{M: d.M.TX(tx)}
  65. }
  66. // Master marks the following operation on master node.
  67. func (d *SysUserOnlineDao) Master() *SysUserOnlineDao {
  68. return &SysUserOnlineDao{M: d.M.Master()}
  69. }
  70. // Slave marks the following operation on slave node.
  71. // Note that it makes sense only if there's any slave node configured.
  72. func (d *SysUserOnlineDao) Slave() *SysUserOnlineDao {
  73. return &SysUserOnlineDao{M: d.M.Slave()}
  74. }
  75. // Args sets custom arguments for model operation.
  76. func (d *SysUserOnlineDao) Args(args ...interface{}) *SysUserOnlineDao {
  77. return &SysUserOnlineDao{M: d.M.Args(args...)}
  78. }
  79. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  80. // The parameter <table> can be joined table and its joined condition,
  81. // and also with its alias name, like:
  82. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  83. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  84. func (d *SysUserOnlineDao) LeftJoin(table ...string) *SysUserOnlineDao {
  85. return &SysUserOnlineDao{M: d.M.LeftJoin(table...)}
  86. }
  87. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  88. // The parameter <table> can be joined table and its joined condition,
  89. // and also with its alias name, like:
  90. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  91. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  92. func (d *SysUserOnlineDao) RightJoin(table ...string) *SysUserOnlineDao {
  93. return &SysUserOnlineDao{M: d.M.RightJoin(table...)}
  94. }
  95. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  96. // The parameter <table> can be joined table and its joined condition,
  97. // and also with its alias name, like:
  98. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  99. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  100. func (d *SysUserOnlineDao) InnerJoin(table ...string) *SysUserOnlineDao {
  101. return &SysUserOnlineDao{M: d.M.InnerJoin(table...)}
  102. }
  103. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  104. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  105. func (d *SysUserOnlineDao) Fields(fieldNamesOrMapStruct ...interface{}) *SysUserOnlineDao {
  106. return &SysUserOnlineDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
  107. }
  108. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  109. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  110. func (d *SysUserOnlineDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *SysUserOnlineDao {
  111. return &SysUserOnlineDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
  112. }
  113. // Option sets the extra operation option for the model.
  114. func (d *SysUserOnlineDao) Option(option int) *SysUserOnlineDao {
  115. return &SysUserOnlineDao{M: d.M.Option(option)}
  116. }
  117. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  118. // the data and where attributes for empty values.
  119. func (d *SysUserOnlineDao) OmitEmpty() *SysUserOnlineDao {
  120. return &SysUserOnlineDao{M: d.M.OmitEmpty()}
  121. }
  122. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  123. func (d *SysUserOnlineDao) Filter() *SysUserOnlineDao {
  124. return &SysUserOnlineDao{M: d.M.Filter()}
  125. }
  126. // Where sets the condition statement for the model. The parameter <where> can be type of
  127. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  128. // multiple conditions will be joined into where statement using "AND".
  129. // Eg:
  130. // Where("uid=10000")
  131. // Where("uid", 10000)
  132. // Where("money>? AND name like ?", 99999, "vip_%")
  133. // Where("uid", 1).Where("name", "john")
  134. // Where("status IN (?)", g.Slice{1,2,3})
  135. // Where("age IN(?,?)", 18, 50)
  136. // Where(User{ Id : 1, UserName : "john"})
  137. func (d *SysUserOnlineDao) Where(where interface{}, args ...interface{}) *SysUserOnlineDao {
  138. return &SysUserOnlineDao{M: d.M.Where(where, args...)}
  139. }
  140. // WherePri does the same logic as M.Where except that if the parameter <where>
  141. // is a single condition like int/string/float/slice, it treats the condition as the primary
  142. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  143. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  144. // as string "123".
  145. func (d *SysUserOnlineDao) WherePri(where interface{}, args ...interface{}) *SysUserOnlineDao {
  146. return &SysUserOnlineDao{M: d.M.WherePri(where, args...)}
  147. }
  148. // And adds "AND" condition to the where statement.
  149. func (d *SysUserOnlineDao) And(where interface{}, args ...interface{}) *SysUserOnlineDao {
  150. return &SysUserOnlineDao{M: d.M.And(where, args...)}
  151. }
  152. // Or adds "OR" condition to the where statement.
  153. func (d *SysUserOnlineDao) Or(where interface{}, args ...interface{}) *SysUserOnlineDao {
  154. return &SysUserOnlineDao{M: d.M.Or(where, args...)}
  155. }
  156. // Group sets the "GROUP BY" statement for the model.
  157. func (d *SysUserOnlineDao) Group(groupBy string) *SysUserOnlineDao {
  158. return &SysUserOnlineDao{M: d.M.Group(groupBy)}
  159. }
  160. // Order sets the "ORDER BY" statement for the model.
  161. func (d *SysUserOnlineDao) Order(orderBy ...string) *SysUserOnlineDao {
  162. return &SysUserOnlineDao{M: d.M.Order(orderBy...)}
  163. }
  164. // Limit sets the "LIMIT" statement for the model.
  165. // The parameter <limit> can be either one or two number, if passed two number is passed,
  166. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  167. // statement.
  168. func (d *SysUserOnlineDao) Limit(limit ...int) *SysUserOnlineDao {
  169. return &SysUserOnlineDao{M: d.M.Limit(limit...)}
  170. }
  171. // Offset sets the "OFFSET" statement for the model.
  172. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  173. func (d *SysUserOnlineDao) Offset(offset int) *SysUserOnlineDao {
  174. return &SysUserOnlineDao{M: d.M.Offset(offset)}
  175. }
  176. // Page sets the paging number for the model.
  177. // The parameter <page> is started from 1 for paging.
  178. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  179. func (d *SysUserOnlineDao) Page(page, limit int) *SysUserOnlineDao {
  180. return &SysUserOnlineDao{M: d.M.Page(page, limit)}
  181. }
  182. // Batch sets the batch operation number for the model.
  183. func (d *SysUserOnlineDao) Batch(batch int) *SysUserOnlineDao {
  184. return &SysUserOnlineDao{M: d.M.Batch(batch)}
  185. }
  186. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  187. // if there's another same sql request, it just reads and returns the result from cache, it
  188. // but not committed and executed into the database.
  189. //
  190. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  191. // If the parameter <duration> = 0, which means it never expires.
  192. // If the parameter <duration> > 0, which means it expires after <duration>.
  193. //
  194. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  195. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  196. //
  197. // Note that, the cache feature is disabled if the model is operating on a transaction.
  198. func (d *SysUserOnlineDao) Cache(duration time.Duration, name ...string) *SysUserOnlineDao {
  199. return &SysUserOnlineDao{M: d.M.Cache(duration, name...)}
  200. }
  201. // Data sets the operation data for the model.
  202. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  203. // Eg:
  204. // Data("uid=10000")
  205. // Data("uid", 10000)
  206. // Data(g.Map{"uid": 10000, "name":"john"})
  207. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  208. func (d *SysUserOnlineDao) Data(data ...interface{}) *SysUserOnlineDao {
  209. return &SysUserOnlineDao{M: d.M.Data(data...)}
  210. }
  211. // All does "SELECT FROM ..." statement for the model.
  212. // It retrieves the records from table and returns the result as []*model.SysUserOnline.
  213. // It returns nil if there's no record retrieved with the given conditions from table.
  214. //
  215. // The optional parameter <where> is the same as the parameter of M.Where function,
  216. // see M.Where.
  217. func (d *SysUserOnlineDao) All(where ...interface{}) ([]*model.SysUserOnline, error) {
  218. all, err := d.M.All(where...)
  219. if err != nil {
  220. return nil, err
  221. }
  222. var entities []*model.SysUserOnline
  223. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  224. return nil, err
  225. }
  226. return entities, nil
  227. }
  228. // One retrieves one record from table and returns the result as *model.SysUserOnline.
  229. // It returns nil if there's no record retrieved with the given conditions from table.
  230. //
  231. // The optional parameter <where> is the same as the parameter of M.Where function,
  232. // see M.Where.
  233. func (d *SysUserOnlineDao) One(where ...interface{}) (*model.SysUserOnline, error) {
  234. one, err := d.M.One(where...)
  235. if err != nil {
  236. return nil, err
  237. }
  238. var entity *model.SysUserOnline
  239. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  240. return nil, err
  241. }
  242. return entity, nil
  243. }
  244. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  245. // Also see M.WherePri and M.One.
  246. func (d *SysUserOnlineDao) FindOne(where ...interface{}) (*model.SysUserOnline, error) {
  247. one, err := d.M.FindOne(where...)
  248. if err != nil {
  249. return nil, err
  250. }
  251. var entity *model.SysUserOnline
  252. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  253. return nil, err
  254. }
  255. return entity, nil
  256. }
  257. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  258. // Also see M.WherePri and M.All.
  259. func (d *SysUserOnlineDao) FindAll(where ...interface{}) ([]*model.SysUserOnline, error) {
  260. all, err := d.M.FindAll(where...)
  261. if err != nil {
  262. return nil, err
  263. }
  264. var entities []*model.SysUserOnline
  265. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  266. return nil, err
  267. }
  268. return entities, nil
  269. }
  270. // Struct retrieves one record from table and converts it into given struct.
  271. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  272. // it can create the struct internally during converting.
  273. //
  274. // The optional parameter <where> is the same as the parameter of Model.Where function,
  275. // see Model.Where.
  276. //
  277. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  278. // from table and <pointer> is not nil.
  279. //
  280. // Eg:
  281. // user := new(User)
  282. // err := dao.User.Where("id", 1).Struct(user)
  283. //
  284. // user := (*User)(nil)
  285. // err := dao.User.Where("id", 1).Struct(&user)
  286. func (d *SysUserOnlineDao) Struct(pointer interface{}, where ...interface{}) error {
  287. return d.M.Struct(pointer, where...)
  288. }
  289. // Structs retrieves records from table and converts them into given struct slice.
  290. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  291. // slice internally during converting.
  292. //
  293. // The optional parameter <where> is the same as the parameter of Model.Where function,
  294. // see Model.Where.
  295. //
  296. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  297. // from table and <pointer> is not empty.
  298. //
  299. // Eg:
  300. // users := ([]User)(nil)
  301. // err := dao.User.Structs(&users)
  302. //
  303. // users := ([]*User)(nil)
  304. // err := dao.User.Structs(&users)
  305. func (d *SysUserOnlineDao) Structs(pointer interface{}, where ...interface{}) error {
  306. return d.M.Structs(pointer, where...)
  307. }
  308. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  309. // It calls function Struct if <pointer> is type of *struct/**struct.
  310. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  311. //
  312. // The optional parameter <where> is the same as the parameter of Model.Where function,
  313. // see Model.Where.
  314. //
  315. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  316. //
  317. // Eg:
  318. // user := new(User)
  319. // err := dao.User.Where("id", 1).Scan(user)
  320. //
  321. // user := (*User)(nil)
  322. // err := dao.User.Where("id", 1).Scan(&user)
  323. //
  324. // users := ([]User)(nil)
  325. // err := dao.User.Scan(&users)
  326. //
  327. // users := ([]*User)(nil)
  328. // err := dao.User.Scan(&users)
  329. func (d *SysUserOnlineDao) Scan(pointer interface{}, where ...interface{}) error {
  330. return d.M.Scan(pointer, where...)
  331. }
  332. // Chunk iterates the table with given size and callback function.
  333. func (d *SysUserOnlineDao) Chunk(limit int, callback func(entities []*model.SysUserOnline, err error) bool) {
  334. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  335. var entities []*model.SysUserOnline
  336. err = result.Structs(&entities)
  337. if err == sql.ErrNoRows {
  338. return false
  339. }
  340. return callback(entities, err)
  341. })
  342. }
  343. // LockUpdate sets the lock for update for current operation.
  344. func (d *SysUserOnlineDao) LockUpdate() *SysUserOnlineDao {
  345. return &SysUserOnlineDao{M: d.M.LockUpdate()}
  346. }
  347. // LockShared sets the lock in share mode for current operation.
  348. func (d *SysUserOnlineDao) LockShared() *SysUserOnlineDao {
  349. return &SysUserOnlineDao{M: d.M.LockShared()}
  350. }
  351. // Unscoped enables/disables the soft deleting feature.
  352. func (d *SysUserOnlineDao) Unscoped() *SysUserOnlineDao {
  353. return &SysUserOnlineDao{M: d.M.Unscoped()}
  354. }