announcementList.go 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package model
  2. import (
  3. "git.getensh.com/common/gopkgsv2/database"
  4. "gorm.io/gorm"
  5. )
  6. type AnnouncementListModel interface {
  7. List(db *gorm.DB, pagination *Pagination) ([]Announcement, error)
  8. Count(db *gorm.DB) (int64, error)
  9. Update(db *gorm.DB, values interface{}) error
  10. Get(db *gorm.DB) (*AnnouncementList, error)
  11. }
  12. type AnnouncementList struct {
  13. Id int64 `gorm:"column:id" json:"id" form:"id"`
  14. ModelNo string `gorm:"column:model_no" json:"model_no" form:"model_no"`
  15. VehicleBatch string `gorm:"column:vehicle_batch" json:"vehicle_batch" form:"vehicle_batch"`
  16. BrandName string `gorm:"column:brand_name" json:"brand_name" form:"brand_name"`
  17. VehicleTypeDetail string `gorm:"column:vehicle_type_detail" json:"vehicle_type_detail" form:"vehicle_type_detail"`
  18. ApprovedLoad string `gorm:"column:approved_load" json:"approved_load" form:"approved_load"`
  19. GrossMass string `gorm:"column:gross_mass" json:"gross_mass" form:"gross_mass"`
  20. UnladenMass string `gorm:"column:unladen_mass" json:"unladen_mass" form:"unladen_mass"`
  21. FuelType string `gorm:"column:fuel_type" json:"fuel_type" form:"fuel_type"`
  22. AxleNumber string `gorm:"column:axle_number" json:"axle_number" form:"axle_number"`
  23. EmissionStandard string `gorm:"column:emission_standard" json:"emission_standard" form:"emission_standard"`
  24. Wheelbase string `gorm:"column:wheelbase" json:"wheelbase" form:"wheelbase"`
  25. AxleWeight string `gorm:"column:axle_weight" json:"axle_weight" form:"axle_weight"`
  26. NumberOfLeafSprings string `gorm:"column:number_of_leaf_springs" json:"number_of_leaf_springs" form:"number_of_leaf_springs"`
  27. TyreNumber string `gorm:"column:tyre_number" json:"tyre_number" form:"tyre_number"`
  28. TyreSize string `gorm:"column:tyre_size" json:"tyre_size" form:"tyre_size"`
  29. ApproachingDepartureAngle string `gorm:"column:approaching_departure_angle" json:"approaching_departure_angle" form:"approaching_departure_angle"`
  30. FrontBackSuspention string `gorm:"column:front_back_suspention" json:"front_back_suspention" form:"front_back_suspention"`
  31. FrontWheelDistance string `gorm:"column:front_wheel_distance" json:"front_wheel_distance" form:"front_wheel_distance"`
  32. BackWheelDistance string `gorm:"column:back_wheel_distance" json:"back_wheel_distance" form:"back_wheel_distance"`
  33. VinRules string `gorm:"column:vin_rules" json:"vin_rules" form:"vin_rules"`
  34. Long string `gorm:"column:long" json:"long" form:"long"`
  35. Wide string `gorm:"column:wide" json:"wide" form:"wide"`
  36. High string `gorm:"column:high" json:"high" form:"high"`
  37. CargoLong string `gorm:"column:cargo_long" json:"cargo_long" form:"cargo_long"`
  38. CargoWide string `gorm:"column:cargo_wide" json:"cargo_wide" form:"cargo_wide"`
  39. CargoHigh string `gorm:"column:cargo_high" json:"cargo_high" form:"cargo_high"`
  40. TopSpeed string `gorm:"column:top_speed" json:"top_speed" form:"top_speed"`
  41. ApprovedNumber string `gorm:"column:approved_number" json:"approved_number" form:"approved_number"`
  42. NumberOfPassengers string `gorm:"column:number_of_passengers" json:"number_of_passengers" form:"number_of_passengers"`
  43. SteeringMode string `gorm:"column:steering_mode" json:"steering_mode" form:"steering_mode"`
  44. TractionMass string `gorm:"column:traction_mass" json:"traction_mass" form:"traction_mass"`
  45. LoadMassCoefficient string `gorm:"column:load_mass_coefficient" json:"load_mass_coefficient" form:"load_mass_coefficient"`
  46. SemitrailerSaddleMaxAllowGrossMass string `gorm:"column:semitrailer_saddle_max_allow_gross_mass" json:"semitrailer_saddle_max_allow_gross_mass" form:"semitrailer_saddle_max_allow_gross_mass"`
  47. CompanyName string `gorm:"column:company_name" json:"company_name" form:"company_name"`
  48. CompanyAddress string `gorm:"column:company_address" json:"company_address" form:"company_address"`
  49. CreatedAt int64 `gorm:"column:created_at" json:"created_at" form:"created_at"`
  50. UpdatedAt int64 `gorm:"column:updated_at" json:"updated_at" form:"updated_at"`
  51. }
  52. type Announcement struct {
  53. Id int32 `gorm:"column:id" json:"id" form:"id"`
  54. VehicleBatch string `gorm:"column:vehicle_batch" json:"vehicle_batch" form:"vehicle_batch"`
  55. VinRules string `gorm:"column:vin_rules" json:"vin_rules" form:"vin_rules"`
  56. ModelNo string `gorm:"column:model_no" json:"model_no" form:"model_no"`
  57. BrandName string `gorm:"column:brand_name" json:"brand_name" form:"brand_name"`
  58. VehicleTypeDetail string `gorm:"column:vehicle_type_detail" json:"vehicle_type_detail" form:"vehicle_type_detail"`
  59. }
  60. type defaultAnnouncementList struct {
  61. tableName string
  62. fields string
  63. }
  64. func NewAnnouncementList() AnnouncementListModel {
  65. return &defaultAnnouncementList{
  66. tableName: "db_adm_dws.t_adm_dws16",
  67. fields: "`id`, `model_no`, `vehicle_batch`, `brand_name`, `vehicle_type_detail`, `approved_load`, `gross_mass`, `unladen_mass`, `fuel_type`, `axle_number`, `emission_standard`, `wheelbase`, `axle_weight`, `number_of_leaf_springs`, `tyre_number`, `tyre_size`, `approaching_departure_angle`, `front_back_suspention`, `front_wheel_distance`, `back_wheel_distance`, `vin_rules`, `long`, `wide`, `high`, `cargo_long`, `cargo_wide`, `cargo_high`, `top_speed`, `approved_number`, `number_of_passengers`, `steering_mode`, `traction_mass`, `load_mass_coefficient`, `semitrailer_saddle_max_allow_gross_mass`, `company_name`, `company_address`, `created_at`, `updated_at`",
  68. }
  69. }
  70. func (d *defaultAnnouncementList) List(db *gorm.DB, pagination *Pagination) ([]Announcement, error) {
  71. var res []Announcement
  72. err := database.List(db, &res, database.Option{
  73. TableName: d.tableName,
  74. Fields: "id, vin_rules, model_no, vehicle_batch, brand_name, vehicle_type_detail",
  75. Limit: pagination.Limit,
  76. OffSet: pagination.Offset,
  77. })
  78. return res, err
  79. }
  80. func (d *defaultAnnouncementList) Count(db *gorm.DB) (int64, error) {
  81. return database.Count(db, database.Option{
  82. TableName: d.tableName,
  83. Fields: "vin_rules, model_no, vehicle_batch, brand_name, vehicle_type_detail",
  84. })
  85. }
  86. func (d *defaultAnnouncementList) Update(db *gorm.DB, values interface{}) error {
  87. return database.Update(db, values, database.Option{
  88. TableName: d.tableName,
  89. })
  90. }
  91. func (d *defaultAnnouncementList) Get(db *gorm.DB) (*AnnouncementList, error) {
  92. var res AnnouncementList
  93. err := database.Get(db, &res, database.Option{
  94. TableName: d.tableName,
  95. Fields: d.fields,
  96. })
  97. return &res, err
  98. }