5
0

bank_arrange_main_model.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. // ==========================================================================
  2. // This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
  3. // ==========================================================================
  4. package bank_arrange_main
  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. )
  13. // arModel is a active record design model for table bank_arrange_main operations.
  14. type arModel struct {
  15. gmvc.M
  16. }
  17. var (
  18. // Table is the table name of bank_arrange_main.
  19. Table = "bank_arrange_main"
  20. // Model is the model object of bank_arrange_main.
  21. Model = &arModel{g.DB("default").Model(Table).Safe()}
  22. // Columns defines and stores column names for table bank_arrange_main.
  23. Columns = struct {
  24. Id string //
  25. EntryNo string // 申请单号
  26. TaskType string // 入库申请类型: 1.基点自动化设备 2 非基点普通设备
  27. Status string // 0:未提交;1:提交待审核;2:审核通过;3:审核不通过; 4:确认过
  28. OperationBy string // 申请人
  29. Section string // 领用部门
  30. EntryTime string // 申请时间
  31. ConUserId string // 审核人Id
  32. ConUserBy string // 审核人
  33. ConTime string // 审核时间
  34. TaskStatus string // 任务执行状态 0 未执行 1. 任务已发送 2. 任务已接收 3. 任务激活 4. 执行失败 5. 任务成功 6. 执行中 7. 已驳回
  35. Remark string // 备注
  36. Exception string // 异常信息
  37. AuditorRemark string // 审核备注
  38. CreateOn string //
  39. CreateUserId string //
  40. CreateBy string //
  41. ModifiedOn string //
  42. ModifiedUserId string //
  43. ModifiedBy string //
  44. Reason string // 原因,ID是字典明细
  45. EquipmentId string // 设备id
  46. ShelfAndBoxIds string // 选中的架子及盒子id
  47. BoxCount string // 整理盒子数量
  48. SampleCount string // 整理样本数量
  49. }{
  50. Id: "Id",
  51. EntryNo: "EntryNo",
  52. TaskType: "TaskType",
  53. Status: "Status",
  54. OperationBy: "OperationBy",
  55. Section: "Section",
  56. EntryTime: "EntryTime",
  57. ConUserId: "ConUserId",
  58. ConUserBy: "ConUserBy",
  59. ConTime: "ConTime",
  60. TaskStatus: "TaskStatus",
  61. Remark: "Remark",
  62. Exception: "Exception",
  63. AuditorRemark: "AuditorRemark",
  64. CreateOn: "CreateOn",
  65. CreateUserId: "CreateUserId",
  66. CreateBy: "CreateBy",
  67. ModifiedOn: "ModifiedOn",
  68. ModifiedUserId: "ModifiedUserId",
  69. ModifiedBy: "ModifiedBy",
  70. Reason: "Reason",
  71. EquipmentId: "EquipmentId",
  72. ShelfAndBoxIds: "ShelfAndBoxIds",
  73. BoxCount: "BoxCount",
  74. SampleCount: "SampleCount",
  75. }
  76. )
  77. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  78. // of current DB object and with given context in it.
  79. // Note that this returned DB object can be used only once, so do not assign it to
  80. // a global or package variable for long using.
  81. func (m *arModel) Ctx(ctx context.Context) *arModel {
  82. return &arModel{m.M.Ctx(ctx)}
  83. }
  84. // As sets an alias name for current table.
  85. func (m *arModel) As(as string) *arModel {
  86. return &arModel{m.M.As(as)}
  87. }
  88. // TX sets the transaction for current operation.
  89. func (m *arModel) TX(tx *gdb.TX) *arModel {
  90. return &arModel{m.M.TX(tx)}
  91. }
  92. // Master marks the following operation on master node.
  93. func (m *arModel) Master() *arModel {
  94. return &arModel{m.M.Master()}
  95. }
  96. // Slave marks the following operation on slave node.
  97. // Note that it makes sense only if there's any slave node configured.
  98. func (m *arModel) Slave() *arModel {
  99. return &arModel{m.M.Slave()}
  100. }
  101. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  102. // The parameter <table> can be joined table and its joined condition,
  103. // and also with its alias name, like:
  104. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  105. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  106. func (m *arModel) LeftJoin(table ...string) *arModel {
  107. return &arModel{m.M.LeftJoin(table ...)}
  108. }
  109. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  110. // The parameter <table> can be joined table and its joined condition,
  111. // and also with its alias name, like:
  112. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  113. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  114. func (m *arModel) RightJoin(table ...string) *arModel {
  115. return &arModel{m.M.RightJoin(table ...)}
  116. }
  117. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  118. // The parameter <table> can be joined table and its joined condition,
  119. // and also with its alias name, like:
  120. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  121. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  122. func (m *arModel) InnerJoin(table ...string) *arModel {
  123. return &arModel{m.M.InnerJoin(table ...)}
  124. }
  125. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  126. func (m *arModel) Fields(fieldNamesOrMapStruct ...interface{}) *arModel {
  127. return &arModel{m.M.Fields(fieldNamesOrMapStruct...)}
  128. }
  129. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  130. func (m *arModel) FieldsEx(fieldNamesOrMapStruct ...interface{}) *arModel {
  131. return &arModel{m.M.FieldsEx(fieldNamesOrMapStruct...)}
  132. }
  133. // Option sets the extra operation option for the model.
  134. func (m *arModel) Option(option int) *arModel {
  135. return &arModel{m.M.Option(option)}
  136. }
  137. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  138. // the data and where attributes for empty values.
  139. func (m *arModel) OmitEmpty() *arModel {
  140. return &arModel{m.M.OmitEmpty()}
  141. }
  142. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  143. func (m *arModel) Filter() *arModel {
  144. return &arModel{m.M.Filter()}
  145. }
  146. // Where sets the condition statement for the model. The parameter <where> can be type of
  147. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  148. // multiple conditions will be joined into where statement using "AND".
  149. // Eg:
  150. // Where("uid=10000")
  151. // Where("uid", 10000)
  152. // Where("money>? AND name like ?", 99999, "vip_%")
  153. // Where("uid", 1).Where("name", "john")
  154. // Where("status IN (?)", g.Slice{1,2,3})
  155. // Where("age IN(?,?)", 18, 50)
  156. // Where(User{ Id : 1, UserName : "john"})
  157. func (m *arModel) Where(where interface{}, args ...interface{}) *arModel {
  158. return &arModel{m.M.Where(where, args...)}
  159. }
  160. // WherePri does the same logic as Model.Where except that if the parameter <where>
  161. // is a single condition like int/string/float/slice, it treats the condition as the primary
  162. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  163. // WherePri function treats the condition as "id=123", but Model.Where treats the condition
  164. // as string "123".
  165. func (m *arModel) WherePri(where interface{}, args ...interface{}) *arModel {
  166. return &arModel{m.M.WherePri(where, args...)}
  167. }
  168. // And adds "AND" condition to the where statement.
  169. func (m *arModel) And(where interface{}, args ...interface{}) *arModel {
  170. return &arModel{m.M.And(where, args...)}
  171. }
  172. // Or adds "OR" condition to the where statement.
  173. func (m *arModel) Or(where interface{}, args ...interface{}) *arModel {
  174. return &arModel{m.M.Or(where, args...)}
  175. }
  176. // Group sets the "GROUP BY" statement for the model.
  177. func (m *arModel) Group(groupBy string) *arModel {
  178. return &arModel{m.M.Group(groupBy)}
  179. }
  180. // Order sets the "ORDER BY" statement for the model.
  181. func (m *arModel) Order(orderBy ...string) *arModel {
  182. return &arModel{m.M.Order(orderBy...)}
  183. }
  184. // Limit sets the "LIMIT" statement for the model.
  185. // The parameter <limit> can be either one or two number, if passed two number is passed,
  186. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  187. // statement.
  188. func (m *arModel) Limit(limit ...int) *arModel {
  189. return &arModel{m.M.Limit(limit...)}
  190. }
  191. // Offset sets the "OFFSET" statement for the model.
  192. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  193. func (m *arModel) Offset(offset int) *arModel {
  194. return &arModel{m.M.Offset(offset)}
  195. }
  196. // Page sets the paging number for the model.
  197. // The parameter <page> is started from 1 for paging.
  198. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  199. func (m *arModel) Page(page, limit int) *arModel {
  200. return &arModel{m.M.Page(page, limit)}
  201. }
  202. // Batch sets the batch operation number for the model.
  203. func (m *arModel) Batch(batch int) *arModel {
  204. return &arModel{m.M.Batch(batch)}
  205. }
  206. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  207. // if there's another same sql request, it just reads and returns the result from cache, it
  208. // but not committed and executed into the database.
  209. //
  210. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  211. // If the parameter <duration> = 0, which means it never expires.
  212. // If the parameter <duration> > 0, which means it expires after <duration>.
  213. //
  214. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  215. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  216. //
  217. // Note that, the cache feature is disabled if the model is operating on a transaction.
  218. func (m *arModel) Cache(duration time.Duration, name ...string) *arModel {
  219. return &arModel{m.M.Cache(duration, name...)}
  220. }
  221. // Data sets the operation data for the model.
  222. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  223. // Eg:
  224. // Data("uid=10000")
  225. // Data("uid", 10000)
  226. // Data(g.Map{"uid": 10000, "name":"john"})
  227. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  228. func (m *arModel) Data(data ...interface{}) *arModel {
  229. return &arModel{m.M.Data(data...)}
  230. }
  231. // All does "SELECT FROM ..." statement for the model.
  232. // It retrieves the records from table and returns the result as []*Entity.
  233. // It returns nil if there's no record retrieved with the given conditions from table.
  234. //
  235. // The optional parameter <where> is the same as the parameter of Model.Where function,
  236. // see Model.Where.
  237. func (m *arModel) All(where ...interface{}) ([]*Entity, error) {
  238. all, err := m.M.All(where...)
  239. if err != nil {
  240. return nil, err
  241. }
  242. var entities []*Entity
  243. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  244. return nil, err
  245. }
  246. return entities, nil
  247. }
  248. // One retrieves one record from table and returns the result as *Entity.
  249. // It returns nil if there's no record retrieved with the given conditions from table.
  250. //
  251. // The optional parameter <where> is the same as the parameter of Model.Where function,
  252. // see Model.Where.
  253. func (m *arModel) One(where ...interface{}) (*Entity, error) {
  254. one, err := m.M.One(where...)
  255. if err != nil {
  256. return nil, err
  257. }
  258. var entity *Entity
  259. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  260. return nil, err
  261. }
  262. return entity, nil
  263. }
  264. // FindOne retrieves and returns a single Record by Model.WherePri and Model.One.
  265. // Also see Model.WherePri and Model.One.
  266. func (m *arModel) FindOne(where ...interface{}) (*Entity, error) {
  267. one, err := m.M.FindOne(where...)
  268. if err != nil {
  269. return nil, err
  270. }
  271. var entity *Entity
  272. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  273. return nil, err
  274. }
  275. return entity, nil
  276. }
  277. // FindAll retrieves and returns Result by by Model.WherePri and Model.All.
  278. // Also see Model.WherePri and Model.All.
  279. func (m *arModel) FindAll(where ...interface{}) ([]*Entity, error) {
  280. all, err := m.M.FindAll(where...)
  281. if err != nil {
  282. return nil, err
  283. }
  284. var entities []*Entity
  285. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  286. return nil, err
  287. }
  288. return entities, nil
  289. }
  290. // Chunk iterates the table with given size and callback function.
  291. func (m *arModel) Chunk(limit int, callback func(entities []*Entity, err error) bool) {
  292. m.M.Chunk(limit, func(result gdb.Result, err error) bool {
  293. var entities []*Entity
  294. err = result.Structs(&entities)
  295. if err == sql.ErrNoRows {
  296. return false
  297. }
  298. return callback(entities, err)
  299. })
  300. }
  301. // LockUpdate sets the lock for update for current operation.
  302. func (m *arModel) LockUpdate() *arModel {
  303. return &arModel{m.M.LockUpdate()}
  304. }
  305. // LockShared sets the lock in share mode for current operation.
  306. func (m *arModel) LockShared() *arModel {
  307. return &arModel{m.M.LockShared()}
  308. }
  309. // Unscoped enables/disables the soft deleting feature.
  310. func (m *arModel) Unscoped() *arModel {
  311. return &arModel{m.M.Unscoped()}
  312. }