github.com/qiuhoude/go-web@v0.0.0-20220223060959-ab545e78f20d/blogweb_gin/controllers/delete_article_controller.go (about)

     1  package controllers
     2  
     3  import (
     4  	"github.com/gin-gonic/gin"
     5  	"github.com/qiuhoude/go-web/blogweb_gin/logs"
     6  	"github.com/qiuhoude/go-web/blogweb_gin/models"
     7  	"log"
     8  	"net/http"
     9  	"strconv"
    10  )
    11  
    12  func DeleteArticleGet(c *gin.Context) {
    13  	idstr := c.Query("id")
    14  	id, _ := strconv.Atoi(idstr)
    15  	logs.Info.Println("删除 id:", id)
    16  
    17  	_, err := models.DeleteArticle(id)
    18  	if err != nil {
    19  		log.Println(err)
    20  	}
    21  	//c.JSON(http.StatusOK, gin.H{"IsLogin": islogin})
    22  	c.Redirect(http.StatusMovedPermanently, "/")
    23  }