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

12
model/article.go Normal file
View File

@@ -0,0 +1,12 @@
package model
type Article struct {
Id int
Title string
CateId int
State int
}
func (Article) TableName() string {
return "article"
}