currency.go 1.1 KB

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