ginBlog

基于gin开发的博客API接口,使用jwt进行验证和登陆

使用方法

  • git clone https://github.com/ganganlee/ginBlog.git
  • go mod tidy
  • 修改/config/config.json里面的配置文件
  • 直接运行或者编译(编译参考:https://blog.csdn.net/weixin_44540711/article/details/109682597)

项目地址

https://github.com/ganganlee/ginBlog

基于此项目搭建的博客(vue)

http://gin.zozoo.net/login

vue模板框架参考

https://blog.csdn.net/weixin_44540711/article/details/107238369

目录结构参考

/-config #配置文件
/-controller #控制器
/-dao #数据库操作层
/-decorator #装饰器层(还没实现)
/-middle #中间件
/-route #路由
/-service #逻辑层
/-tool #公共函数层
main.go 入口文件

路由地址参考

	//用户模块
	userGrout := gin.Group("/user")
	userGrout.POST("/register", userController.Register)
	userGrout.POST("/login", userController.Login)

	//文章模块
	article := new(controller.ArticleController)
	gin.GET("/article/:id", article.Info)                         //获取文章详情
	gin.POST("/article/:id", article.DelArticle)                  //删除文章
	gin.POST("/articles", article.List)                           //获取文章列表
	gin.POST("/articles/month", article.ListByMonth)              //根据月份获取文章详情
	articleGroup := gin.Group("/article", middle.LoginMiddleWare) //注册登陆中间件
	articleGroup.POST("/", article.CreateArticle)                 //创建文章

	//tag模块
	tag := new(controller.TagController)
	tagGroup := gin.Group("/tag", middle.LoginMiddleWare)
	tagGroup.POST("", tag.Create)    //添加tag
	tagGroup.GET("", tag.FindByName) //搜索用户tag
	tagGroup.GET("/list", tag.List)  //获取用户tag

	//标签文章模块
	tagArticle := new(controller.TagArticleController)
	gin.GET("/tagArticle/:id", tagArticle.List) //根据文章标签获取标签下的文章
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐