6
0

settle_account_main.go 18 KB

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