6
0

instrument_surcharge.go 17 KB

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