diff --git a/controller/file.go b/controller/file.go index 1c8ad69..6923dee 100644 --- a/controller/file.go +++ b/controller/file.go @@ -25,6 +25,43 @@ import ( type FileController struct { } +func (this *FileController) OnUploadDoc(c *gin.Context) { + // uid, e := uuid.NewV1() + // if nil != e { + // log.Print(e.Error()) + // return + // } + // imgtype := c.Query("type") + // log.Print(imgtype) + // file, _, err := c.Request.FormFile("doc") + // if nil != err || nil == file { + // log.Print(err.Error()) + // return + // } + + // img, name, err := image.Decode(file) + // if nil != err { + // log.Print(err.Error()) + // return + // } + // dx := img.Bounds().Dx() + // // resize to width 1000 using Lanczos resampling + // // and preserve aspect ratio + // if dx > 800 { + // dx = dx / 2 + // } + // m := resize.Resize(uint(dx), 0, img, resize.Lanczos3) + + // datout, err := os.Create("image/" + uid.String() + "." + name) + // defer datout.Close() + // if err != nil { + // log.Fatal(err) + // } + // jpeg.Encode(datout, m, nil) + // c.JSON(200, map[string]interface{}{"url": uid.String() + "." + name}) + +} + func (this *FileController) OnUpload(c *gin.Context) { uid, e := uuid.NewV1() if nil != e { diff --git a/main.go b/main.go index a76dd63..be69166 100644 --- a/main.go +++ b/main.go @@ -38,6 +38,8 @@ func CORSMiddleware(c *gin.Context) { if config.ApiConfig().RunMode == "release" { c.Writer.Header().Set("Access-Control-Allow-Origin", "https://testingcloud.club") } else { + c.Writer.Header().Set("Access-Control-Allow-Origin", "https://testingcloud.club") + c.Writer.Header().Set("Access-Control-Allow-Origin", "http://127.0.0.1:8080") } c.Writer.Header().Set("Access-Control-Max-Age", "86400") @@ -162,7 +164,9 @@ func main() { api.POST("/articles", controller.GetArticles) // 获取所有文章 api.GET("/articles_tree", controller.GetArticlesTree) // 获取所有文章 - api.PUT("/article", controller.AddArticle) // 添加文章 + api.PUT("/article", controller.AddArticle) // 添加文章 + api.PUT("/article_file", controller.AddArticle) // 添加文章 + api.PUT("/article_tree", controller.AddArticleTree) // 添加文章 api.PUT("/article_tree_history", controller.AddArticleHistory) // 添加文章 @@ -190,6 +194,8 @@ func main() { api.GET("/hardware", controller.ReadHardWare) // 读取硬件 api.DELETE("/hardware", controller.DeleteHardWare) // 读取硬件 + api.POST("/file", fileController.OnFileUploadFile) // 上传文件 + api.PUT("/file", fileController.OnFileUploadFile) // 上传文件 api.GET("/file", fileController.DownloadFile) // 下载 文件 api.GET("/filelist", fileController.FileList) // 文件列表 diff --git a/test/utils_test.go b/test/utils_test.go index 71a651c..5c147d5 100644 --- a/test/utils_test.go +++ b/test/utils_test.go @@ -29,45 +29,45 @@ func TestDDL2ORM(t *testing.T) { ` tbname, fields := utils.DDL2Field(ddl) log.Print(tbname, fields) - gocode := utils.CreateGoStruct(tbname,fields) + gocode := utils.CreateGoStruct(tbname, fields) log.Print(gocode) } -func TestVariableNameChange(t *testing.T){ +func TestVariableNameChange(t *testing.T) { t.Log(utils.ToSnakeString("CaTest")) } -func TestSpeed(t *testing.T){ - var tcpAddr *net.TCPAddr - tcpAddr,_ = net.ResolveTCPAddr("tcp","192.168.6.103:6500") +func TestSpeed(t *testing.T) { + var tcpAddr *net.TCPAddr + tcpAddr, _ = net.ResolveTCPAddr("tcp", "192.168.6.103:6500") - conn,err := net.DialTCP("tcp",nil,tcpAddr) + conn, err := net.DialTCP("tcp", nil, tcpAddr) - if err!=nil { - fmt.Println("Client connect error ! " + err.Error()) - return - } - - defer conn.Close() - recv := make([]byte,128) - i := int32(0) - for ;i < 128;i++ { - recv[i] = byte(i&0xff) + if err != nil { + fmt.Println("Client connect error ! " + err.Error()) + return } - fmt.Println(conn.LocalAddr().String() + " : Client connected!") + + defer conn.Close() + recv := make([]byte, 128) + i := int32(0) + for ; i < 128; i++ { + recv[i] = byte(i & 0xff) + } + fmt.Println(conn.LocalAddr().String() + " : Client connected!") reportTime := time.Now() - speed := 0; + speed := 0 for { - cnt,_ := conn.Write(recv) + cnt, _ := conn.Write(recv) speed += cnt // cnt,e = conn.Read(recv) // if nil != e{ // log.Print(e.Error()) // } // speed += cnt - if(reportTime.Add(time.Second).Before(time.Now())){ + if reportTime.Add(time.Second).Before(time.Now()) { reportTime = time.Now() - t.Log("speed ",speed," B/S") + t.Log("speed ", speed, " B/S") speed = 0 } } -} \ No newline at end of file +} diff --git a/漂移动画.html b/漂移动画.html new file mode 100644 index 0000000..e367716 --- /dev/null +++ b/漂移动画.html @@ -0,0 +1,85 @@ + + + + + Title + + + + + + \ No newline at end of file diff --git a/画线矩形.html b/画线矩形.html new file mode 100644 index 0000000..22dd591 --- /dev/null +++ b/画线矩形.html @@ -0,0 +1,88 @@ + + + + + 使用WebGL绘制一个点 + + + + + + + + + + + + \ No newline at end of file