feat(admin): 实现用户管理的增删改查功能

- 新增用户添加接口,支持数据库中创建用户
- 实现用户编辑接口,允许更新用户信息
- 添加用户删除接口,支持从数据库删除用户
- 修改路由配置,新增用户编辑和删除的GET请求路径
- 使用gorm完成用户数据的增删改查操作
- 初始化数据库连接,自动迁移User表结构
- 新增User和Article模型定义及对应的表名函数
- 在main.go中添加session中间件支持
- defaultController中实现基于session的用户名保存与读取
- 添加go.mod依赖,包含gorm与gin-contrib/sessions相关包
This commit is contained in:
2026-03-11 17:32:59 +08:00
parent 4229a59d89
commit 4a3c510a00
8 changed files with 133 additions and 20 deletions

19
go.mod
View File

@@ -2,9 +2,15 @@ module awesomeProject
go 1.25
require github.com/gin-gonic/gin v1.11.0
require (
github.com/gin-contrib/sessions v1.0.4
github.com/gin-gonic/gin v1.11.0
gorm.io/driver/mysql v1.6.0
gorm.io/gorm v1.31.1
)
require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.14.2 // indirect
github.com/bytedance/sonic/loader v0.4.0 // indirect
@@ -14,8 +20,14 @@ require (
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.28.0 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.18.0 // indirect
github.com/gorilla/context v1.1.2 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/gorilla/sessions v1.4.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
@@ -30,11 +42,8 @@ require (
go.uber.org/mock v0.6.0 // indirect
golang.org/x/arch v0.23.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/tools v0.39.0 // indirect
golang.org/x/text v0.34.0 // indirect
google.golang.org/protobuf v1.36.10 // indirect
)