shop_currency.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package fetdata
  2. import (
  3. "golang-fave/engine/wrapper"
  4. "golang-fave/utils"
  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. SELECT
  23. id,
  24. name,
  25. coefficient,
  26. code,
  27. symbol
  28. FROM
  29. shop_currencies
  30. WHERE
  31. id = ?
  32. LIMIT 1;`,
  33. id,
  34. ).Scan(
  35. &this.object.A_id,
  36. &this.object.A_name,
  37. &this.object.A_coefficient,
  38. &this.object.A_code,
  39. &this.object.A_symbol,
  40. ); err != nil {
  41. return
  42. }
  43. }
  44. func (this *ShopCurrency) Id() int {
  45. if this == nil {
  46. return 0
  47. }
  48. return this.object.A_id
  49. }
  50. func (this *ShopCurrency) Name() string {
  51. if this == nil {
  52. return ""
  53. }
  54. return this.object.A_name
  55. }
  56. func (this *ShopCurrency) Coefficient() float64 {
  57. if this == nil {
  58. return 0
  59. }
  60. return this.object.A_coefficient
  61. }
  62. func (this *ShopCurrency) Code() string {
  63. if this == nil {
  64. return ""
  65. }
  66. return this.object.A_code
  67. }
  68. func (this *ShopCurrency) Symbol() string {
  69. if this == nil {
  70. return ""
  71. }
  72. return this.object.A_symbol
  73. }