123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- package model
- import (
- "git.getensh.com/common/gopkgsv2/database"
- "gorm.io/gorm"
- )
- type AnnouncementListModel interface {
- List(db *gorm.DB, pagination *Pagination) ([]Announcement, error)
- Count(db *gorm.DB) (int64, error)
- Update(db *gorm.DB, values interface{}) error
- Get(db *gorm.DB) (*AnnouncementList, error)
- }
- type AnnouncementList struct {
- Id int64 `gorm:"column:id" json:"id" form:"id"`
- ModelNo string `gorm:"column:model_no" json:"model_no" form:"model_no"`
- VehicleBatch string `gorm:"column:vehicle_batch" json:"vehicle_batch" form:"vehicle_batch"`
- BrandName string `gorm:"column:brand_name" json:"brand_name" form:"brand_name"`
- VehicleTypeDetail string `gorm:"column:vehicle_type_detail" json:"vehicle_type_detail" form:"vehicle_type_detail"`
- ApprovedLoad string `gorm:"column:approved_load" json:"approved_load" form:"approved_load"`
- GrossMass string `gorm:"column:gross_mass" json:"gross_mass" form:"gross_mass"`
- UnladenMass string `gorm:"column:unladen_mass" json:"unladen_mass" form:"unladen_mass"`
- FuelType string `gorm:"column:fuel_type" json:"fuel_type" form:"fuel_type"`
- AxleNumber string `gorm:"column:axle_number" json:"axle_number" form:"axle_number"`
- EmissionStandard string `gorm:"column:emission_standard" json:"emission_standard" form:"emission_standard"`
- Wheelbase string `gorm:"column:wheelbase" json:"wheelbase" form:"wheelbase"`
- AxleWeight string `gorm:"column:axle_weight" json:"axle_weight" form:"axle_weight"`
- NumberOfLeafSprings string `gorm:"column:number_of_leaf_springs" json:"number_of_leaf_springs" form:"number_of_leaf_springs"`
- TyreNumber string `gorm:"column:tyre_number" json:"tyre_number" form:"tyre_number"`
- TyreSize string `gorm:"column:tyre_size" json:"tyre_size" form:"tyre_size"`
- ApproachingDepartureAngle string `gorm:"column:approaching_departure_angle" json:"approaching_departure_angle" form:"approaching_departure_angle"`
- FrontBackSuspention string `gorm:"column:front_back_suspention" json:"front_back_suspention" form:"front_back_suspention"`
- FrontWheelDistance string `gorm:"column:front_wheel_distance" json:"front_wheel_distance" form:"front_wheel_distance"`
- BackWheelDistance string `gorm:"column:back_wheel_distance" json:"back_wheel_distance" form:"back_wheel_distance"`
- VinRules string `gorm:"column:vin_rules" json:"vin_rules" form:"vin_rules"`
- Long string `gorm:"column:long" json:"long" form:"long"`
- Wide string `gorm:"column:wide" json:"wide" form:"wide"`
- High string `gorm:"column:high" json:"high" form:"high"`
- CargoLong string `gorm:"column:cargo_long" json:"cargo_long" form:"cargo_long"`
- CargoWide string `gorm:"column:cargo_wide" json:"cargo_wide" form:"cargo_wide"`
- CargoHigh string `gorm:"column:cargo_high" json:"cargo_high" form:"cargo_high"`
- TopSpeed string `gorm:"column:top_speed" json:"top_speed" form:"top_speed"`
- ApprovedNumber string `gorm:"column:approved_number" json:"approved_number" form:"approved_number"`
- NumberOfPassengers string `gorm:"column:number_of_passengers" json:"number_of_passengers" form:"number_of_passengers"`
- SteeringMode string `gorm:"column:steering_mode" json:"steering_mode" form:"steering_mode"`
- TractionMass string `gorm:"column:traction_mass" json:"traction_mass" form:"traction_mass"`
- LoadMassCoefficient string `gorm:"column:load_mass_coefficient" json:"load_mass_coefficient" form:"load_mass_coefficient"`
- SemitrailerSaddleMaxAllowGrossMass string `gorm:"column:semitrailer_saddle_max_allow_gross_mass" json:"semitrailer_saddle_max_allow_gross_mass" form:"semitrailer_saddle_max_allow_gross_mass"`
- CompanyName string `gorm:"column:company_name" json:"company_name" form:"company_name"`
- CompanyAddress string `gorm:"column:company_address" json:"company_address" form:"company_address"`
- CreatedAt int64 `gorm:"column:created_at" json:"created_at" form:"created_at"`
- UpdatedAt int64 `gorm:"column:updated_at" json:"updated_at" form:"updated_at"`
- }
- type Announcement struct {
- Id int32 `gorm:"column:id" json:"id" form:"id"`
- VehicleBatch string `gorm:"column:vehicle_batch" json:"vehicle_batch" form:"vehicle_batch"`
- VinRules string `gorm:"column:vin_rules" json:"vin_rules" form:"vin_rules"`
- ModelNo string `gorm:"column:model_no" json:"model_no" form:"model_no"`
- BrandName string `gorm:"column:brand_name" json:"brand_name" form:"brand_name"`
- VehicleTypeDetail string `gorm:"column:vehicle_type_detail" json:"vehicle_type_detail" form:"vehicle_type_detail"`
- }
- type defaultAnnouncementList struct {
- tableName string
- fields string
- }
- func NewAnnouncementList() AnnouncementListModel {
- return &defaultAnnouncementList{
- tableName: "db_adm_dws.t_adm_dws16",
- 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`",
- }
- }
- func (d *defaultAnnouncementList) List(db *gorm.DB, pagination *Pagination) ([]Announcement, error) {
- var res []Announcement
- err := database.List(db, &res, database.Option{
- TableName: d.tableName,
- Fields: "id, vin_rules, model_no, vehicle_batch, brand_name, vehicle_type_detail",
- Limit: pagination.Limit,
- OffSet: pagination.Offset,
- })
- return res, err
- }
- func (d *defaultAnnouncementList) Count(db *gorm.DB) (int64, error) {
- return database.Count(db, database.Option{
- TableName: d.tableName,
- Fields: "vin_rules, model_no, vehicle_batch, brand_name, vehicle_type_detail",
- })
- }
- func (d *defaultAnnouncementList) Update(db *gorm.DB, values interface{}) error {
- return database.Update(db, values, database.Option{
- TableName: d.tableName,
- })
- }
- func (d *defaultAnnouncementList) Get(db *gorm.DB) (*AnnouncementList, error) {
- var res AnnouncementList
- err := database.Get(db, &res, database.Option{
- TableName: d.tableName,
- Fields: d.fields,
- })
- return &res, err
- }
|