settle_account_main.go 20 KB

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