settle_account_detail.go 16 KB

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