添加测试环境部署脚本
parent
1be2d54c25
commit
2b7c0450bb
20
main.go
20
main.go
|
@ -45,7 +45,7 @@ func InitLogs() {
|
|||
func CORSMiddleware(c *gin.Context) {
|
||||
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Origin",
|
||||
"http://172.21.102.193:8080")
|
||||
"http://localhost:8080")
|
||||
c.Writer.Header().Set("Access-Control-Max-Age", "86400")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Headers",
|
||||
"X-Requested-With," +
|
||||
|
@ -98,16 +98,18 @@ func main() {
|
|||
/** 修改密码**/
|
||||
api.POST("modify_pass",middle.AuthMiddle,userController.ModifyPasswd)
|
||||
|
||||
api.GET("/article/:id",controller.GetArticle)
|
||||
api.POST("/articles",controller.GetArticles)
|
||||
api.GET("/article/:id",controller.GetArticle) //获取文章
|
||||
api.POST("/articles",controller.GetArticles) // 获取所有文章
|
||||
api.PUT("/article",controller.AddArticle) // 添加文章
|
||||
api.GET("article_type",controller.ArticlesType) //获取所有文章分类
|
||||
api.POST("/article_update",controller.UpdateArtilce)
|
||||
api.GET("/articleCount",controller.GetArticleCount)
|
||||
api.DELETE("/article/:id",controller.DeleteArticle)
|
||||
api.POST("/image_upload",fileController.OnUpload)
|
||||
api.GET("/image_download/:file",fileController.OnDownLoad)
|
||||
api.GET("/doc_types",controller.ArticlesTypes)
|
||||
api.POST("/article_update",controller.UpdateArtilce) //更新文章
|
||||
api.GET("/articleCount",controller.GetArticleCount) //获取所有文章个数
|
||||
api.DELETE("/article/:id",controller.DeleteArticle) ////删除文章
|
||||
api.POST("/image_upload",fileController.OnUpload) // 上传图片
|
||||
api.GET("/image_download/:file",fileController.OnDownLoad) // 下载图片
|
||||
api.GET("/doc_types",controller.ArticlesTypes) // 获取所有的文章类型
|
||||
|
||||
|
||||
}
|
||||
|
||||
e := r.Run(":" + strconv.Itoa(config.GetPort()))
|
||||
|
|
|
@ -33,13 +33,13 @@ func GetArticlesType() []ArticleType {
|
|||
}
|
||||
func CreateDoc(doc Doc) error {
|
||||
sql := fmt.Sprintf(`INSERT INTO doc ( doc.title, doc.content, doc.author, doc.type ) SELECT
|
||||
'%s',
|
||||
'%s',
|
||||
'%s',
|
||||
%d
|
||||
FROM
|
||||
DUAL
|
||||
WHERE
|
||||
'%s',
|
||||
'%s',
|
||||
'%s',
|
||||
%d
|
||||
FROM
|
||||
DUAL
|
||||
WHERE
|
||||
NOT EXISTS ( SELECT * FROM doc WHERE doc.title = '%s' );`, doc.Title, strings.Replace(doc.Content, "'", "\\'", -1), doc.Author, doc.Type,doc.Title)
|
||||
_, e := db.GetMysqlClient().Query(sql)
|
||||
if nil != e {
|
||||
|
|
Loading…
Reference in New Issue