6
0

settle_account_detail.go 18 KB

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