dingtalk_log.go 31 KB

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