sys_message_log.go 26 KB

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