You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

34 lines
670 B

package main
import (
web "json-gen/dist"
"net/http"
"github.com/gin-gonic/gin"
"github.com/miaogaolin/gotl/common/sql2gorm/parser"
)
func main() {
r := gin.Default()
r.POST("/sql", func(c *gin.Context) {
var req struct {
Content string `json:"content"`
}
err := c.BindJSON(&req)
if err != nil {
c.String(http.StatusBadRequest, err.Error())
return
}
res, err := parser.ParseSqlFormat(req.Content,
parser.WithGormType(),
parser.WithJsonTag(),
)
if err != nil {
c.String(http.StatusInternalServerError, err.Error())
return
}
c.String(http.StatusOK, string(res))
})
r.StaticFS("/", http.FS(web.Static))
r.Run(":8000")
}