diff --git a/app/controller/admin/article.go b/app/controller/admin/article.go index 3caa2b0796773863643ecafaeea47a3bce1d9a78..02f2f9d51c4e2b0fa0d69caea0e30c70299fdb7b 100644 --- a/app/controller/admin/article.go +++ b/app/controller/admin/article.go @@ -87,11 +87,13 @@ func (b *Article) EditMd(c *gin.Context) { response.HTML(c, "article/md", nil) } +// Insert 新增保存 // Insert 新增保存 func (b *Article) Insert(c *gin.Context) { Article := &model.Article{} Article.Username = c.GetString("current_user_name") + // Bind the incoming request data to the Article struct if err := c.ShouldBind(&Article); err != nil { c.JSON(400, gin.H{ "err": err.Error(), @@ -99,15 +101,17 @@ func (b *Article) Insert(c *gin.Context) { return } - // Article.Content = utils.RepImages(Article.Content) - err := service.Article.Create(Article) + // Extract all image URLs from the content and store them in smallimg, separated by "|" + // Create the article in the database + err := service.Article.Create(Article) if err != nil { logrus.Error("新增失败", err) response.Fail(c, e.ErrorUpdate) return } + // Return the success response with the created article data response.Success(c, Article) } @@ -134,6 +138,8 @@ func (b *Article) Update(c *gin.Context) { response.Success(c, Article) } + + // Destroy 删除 func (b *Article) Destroy(c *gin.Context) { id := c.PostForm("id") diff --git a/app/controller/admin/upload.go b/app/controller/admin/upload.go index 5120369612170022ed88a03a4aabe6b9a34e7aab..dffe7661d1ab842ded4acec6b1dd02605d490bb3 100644 --- a/app/controller/admin/upload.go +++ b/app/controller/admin/upload.go @@ -78,7 +78,7 @@ func uploadLocal(c *gin.Context, file *multipart.FileHeader) (string, error) { if err != nil { return "", err } - return filePath, nil + return "\\"+filePath, nil } func uploadOss(file *multipart.FileHeader) (bool, string) { diff --git a/views/admin/banner/index.html b/views/admin/banner/index.html index 3ee726e2991fd12162d28367c3e16ab29da1afb2..dc178268a752b280f8b3fe387328c48c43d824f1 100644 --- a/views/admin/banner/index.html +++ b/views/admin/banner/index.html @@ -230,8 +230,8 @@ handleRemove (file, fileList) { }, handleUploadSuccess (response, file, fileList) { - if (response && response.data) { - this.modelForm.smallimg = '/' + response.data.path + if (response && response.location) { + this.modelForm.smallimg = '/' + response.location } }, handleImgPreview (file) {