vehicle.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package models
  2. import (
  3. "database/sql"
  4. "lttc-go-adm-znaf/orm"
  5. )
  6. type Vehicle struct {
  7. Guid sql.NullString `json:"guid"`
  8. InfoNO sql.NullString `json:"info_no"`
  9. LicensePlateNO sql.NullString `json:"license_plate_no"`
  10. Brand sql.NullString `json:"brand"`
  11. Model sql.NullString `json:"model"`
  12. Type sql.NullString `json:"type"`
  13. Color sql.NullString `json:"color"`
  14. PurDate sql.NullTime `json:"pur_date"`
  15. OtherInfo sql.NullString `json:"other_info"`
  16. EmployeeNO sql.NullString `json:"employee_no"`
  17. EmployeeName sql.NullString `json:"employee_name"`
  18. DeptName sql.NullString `json:"dept_name"`
  19. FactoryArea sql.NullString `json:"factory_area"`
  20. PhoneNumber sql.NullString `json:"phone_number"`
  21. JobPositions sql.NullString `json:"job_positions"`
  22. ClassSystem sql.NullString `json:"class_system"`
  23. ClassType sql.NullString `json:"class_type"`
  24. DimissionDate sql.NullTime `json:"dimission_date"`
  25. ParkLocale sql.NullString `json:"park_locale"`
  26. ParkCertName sql.NullString `json:"park_cert_name"`
  27. SubmitDate sql.NullTime `json:"submit_date"`
  28. GrantDate sql.NullTime `json:"grant_date"`
  29. IsOftenDrive sql.NullString `json:"is_often_drive"`
  30. Note sql.NullString `json:"note"`
  31. EditUser sql.NullString `json:"edit_user"`
  32. EditTime sql.NullTime `json:"edit_time"`
  33. SealUser sql.NullString `json:"seal_user"`
  34. SealTime sql.NullTime `json:"seal_time"`
  35. }
  36. func GetAllVehicles() ([]Vehicle, error) {
  37. var (
  38. vehicles []Vehicle
  39. err error
  40. )
  41. err = orm.DB.Select(&vehicles, "select top 1 guid, infono, licenseplateno, brand, model, type, color, purdate, otherinfo, employeeno, employeename, deptname, factoryarea, phonenumber, jobpositions, classsystem, classtype, dimissiondate, parklocale, parkcertname, submitdate, grantdate, isoftendrive, note, edituser, edittime, sealuser, sealtime from dbo.ADM_ZNAF_VehicleMng_VehicleInfo order by EditTime desc ")
  42. if err != nil {
  43. return nil, err
  44. }
  45. return vehicles, nil
  46. }