shop_currency.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package fetdata
  2. import (
  3. "golang-fave/engine/utils"
  4. "golang-fave/engine/wrapper"
  5. )
  6. type ShopCurrency struct {
  7. wrap *wrapper.Wrapper
  8. object *utils.MySql_shop_currency
  9. }
  10. func (this *ShopCurrency) load() *ShopCurrency {
  11. return this
  12. }
  13. func (this *ShopCurrency) loadById(id int) {
  14. if this == nil {
  15. return
  16. }
  17. if this.object != nil {
  18. return
  19. }
  20. this.object = &utils.MySql_shop_currency{}
  21. if err := this.wrap.DB.QueryRow(
  22. this.wrap.R.Context(),
  23. `SELECT
  24. id,
  25. name,
  26. coefficient,
  27. code,
  28. symbol
  29. FROM
  30. fave_shop_currencies
  31. WHERE
  32. id = ?
  33. LIMIT 1;`,
  34. id,
  35. ).Scan(
  36. &this.object.A_id,
  37. &this.object.A_name,
  38. &this.object.A_coefficient,
  39. &this.object.A_code,
  40. &this.object.A_symbol,
  41. ); *this.wrap.LogCpError(&err) != nil {
  42. return
  43. }
  44. }
  45. func (this *ShopCurrency) Id() int {
  46. if this == nil {
  47. return 0
  48. }
  49. return this.object.A_id
  50. }
  51. func (this *ShopCurrency) Name() string {
  52. if this == nil {
  53. return ""
  54. }
  55. return this.object.A_name
  56. }
  57. func (this *ShopCurrency) Coefficient() float64 {
  58. if this == nil {
  59. return 0
  60. }
  61. return this.object.A_coefficient
  62. }
  63. func (this *ShopCurrency) Code() string {
  64. if this == nil {
  65. return ""
  66. }
  67. return this.object.A_code
  68. }
  69. func (this *ShopCurrency) Symbol() string {
  70. if this == nil {
  71. return ""
  72. }
  73. return this.object.A_symbol
  74. }