5
0

bank_arrange_detail_model.go 17 KB

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