From 649dbb71d6eb6bd64cb1d2f49ed07bace049dac2 Mon Sep 17 00:00:00 2001 From: zimujun20 <1192147078@qq.com> Date: Sat, 17 Sep 2022 23:57:53 +0800 Subject: [PATCH] 2022-9-17 --- application/server/api/android/hands_3d.go | 0 .../server/api/android/hands_recegnation.go | 0 .../server/api/android/hands_translation.go | 0 .../server/api/android/media_camera.go | 0 application/server/api/android/media_pipe.go | 0 application/server/api/android/word_input.go | 0 application/server/api/android/word_recv.go | 0 application/server/api/android/word_send.go | 0 application/server/api/android/word_show.go | 0 application/server/api/pc/load_alancing.go | 0 application/server/api/pc/nginx-rtmp.go | 0 application/server/api/pc/webserver.go | 0 application/server/main.go | 28 +++++++++++++++++++ application/server/pkg/app/response.go | 24 ++++++++++++++++ application/server/routers/router.go | 26 +++++++++++++++++ application/web/src/main.js | 0 zimujun_test.txt | 1 - 17 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 application/server/api/android/hands_3d.go create mode 100644 application/server/api/android/hands_recegnation.go create mode 100644 application/server/api/android/hands_translation.go create mode 100644 application/server/api/android/media_camera.go create mode 100644 application/server/api/android/media_pipe.go create mode 100644 application/server/api/android/word_input.go create mode 100644 application/server/api/android/word_recv.go create mode 100644 application/server/api/android/word_send.go create mode 100644 application/server/api/android/word_show.go create mode 100644 application/server/api/pc/load_alancing.go create mode 100644 application/server/api/pc/nginx-rtmp.go create mode 100644 application/server/api/pc/webserver.go create mode 100644 application/server/main.go create mode 100644 application/server/pkg/app/response.go create mode 100644 application/server/routers/router.go create mode 100644 application/web/src/main.js delete mode 100644 zimujun_test.txt diff --git a/application/server/api/android/hands_3d.go b/application/server/api/android/hands_3d.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/android/hands_recegnation.go b/application/server/api/android/hands_recegnation.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/android/hands_translation.go b/application/server/api/android/hands_translation.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/android/media_camera.go b/application/server/api/android/media_camera.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/android/media_pipe.go b/application/server/api/android/media_pipe.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/android/word_input.go b/application/server/api/android/word_input.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/android/word_recv.go b/application/server/api/android/word_recv.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/android/word_send.go b/application/server/api/android/word_send.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/android/word_show.go b/application/server/api/android/word_show.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/pc/load_alancing.go b/application/server/api/pc/load_alancing.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/pc/nginx-rtmp.go b/application/server/api/pc/nginx-rtmp.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/api/pc/webserver.go b/application/server/api/pc/webserver.go new file mode 100644 index 0000000..e69de29 diff --git a/application/server/main.go b/application/server/main.go new file mode 100644 index 0000000..dee48c7 --- /dev/null +++ b/application/server/main.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "log" + "net/http" + "time" + + "application/routers" +) + +func main() { + timeLocal, err := time.LoadLocation("Asia/Shanghai") + if err != nil { + log.Printf("时区设置失败 %s", err) + } + time.Local = timeLocal + + endPoint := fmt.Sprintf("0.0.0.0:%d", 8000) + server := &http.Server{ + Addr: endPoint, + Handler: routers.InitRouter(), + } + log.Printf("[info] start http server listening %s", endPoint) + if err := server.ListenAndServe(); err != nil { + log.Printf("start http server failed %s", err) + } +} diff --git a/application/server/pkg/app/response.go b/application/server/pkg/app/response.go new file mode 100644 index 0000000..40b8e13 --- /dev/null +++ b/application/server/pkg/app/response.go @@ -0,0 +1,24 @@ +package app + +import ( + "github.com/gin-gonic/gin" +) + +type Gin struct { + C *gin.Context +} + +type Response struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data interface{} `json:"data"` +} + +func (g *Gin) Response(httpCode int, errMsg string, data interface{}) { + g.C.JSON(httpCode, Response{ + Code: httpCode, + Msg: errMsg, + Data: data, + }) + return +} diff --git a/application/server/routers/router.go b/application/server/routers/router.go new file mode 100644 index 0000000..99d640d --- /dev/null +++ b/application/server/routers/router.go @@ -0,0 +1,26 @@ +package routers + +import ( + "net/http" + + android "application/api/android" + pc "application/api/pc" + + "github.com/gin-gonic/gin" +) + +// InitRouter 初始化路由信息 +func InitRouter() *gin.Engine { + r := gin.Default() + + api := r.Group("/api") + { + api.GET("/android/hello", android.Hello) + api.POST("/android/hello", android.Hello) + api.GET("/pc/hello", pc.Hello) + api.POST("/pc/hello", pc.Hello) + } + // 静态文件路由 + r.StaticFS("/web", http.Dir("./dist/")) + return r +} diff --git a/application/web/src/main.js b/application/web/src/main.js new file mode 100644 index 0000000..e69de29 diff --git a/zimujun_test.txt b/zimujun_test.txt deleted file mode 100644 index 6c41c7e..0000000 --- a/zimujun_test.txt +++ /dev/null @@ -1 +0,0 @@ -smjsmjsmj \ No newline at end of file