vehicle.go 630 B

123456789101112131415161718192021222324252627
  1. package v1
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "lttc-go-adm-znaf/models"
  5. "lttc-go-adm-znaf/pkg/app"
  6. "lttc-go-adm-znaf/pkg/e"
  7. "net/http"
  8. )
  9. // @Summary GetAllVehicles
  10. // @Description 获取所有车辆信息
  11. // @Success 200 {string} json "{ "code": 200, "data": {}, "msg": "ok" }"
  12. // @Router /api/v1/getAllVehicles [get]
  13. func GetAllVehicles(c *gin.Context) {
  14. appG := app.Gin{C: c}
  15. vehicles, err := models.GetAllVehicles()
  16. if err != nil {
  17. appG.Response(http.StatusInternalServerError, e.ERROR, nil)
  18. }
  19. data := make(map[string]interface{})
  20. data["vehicles"] = vehicles
  21. appG.Response(http.StatusOK, e.SUCCESS, data)
  22. }