- 新增用户添加接口,支持数据库中创建用户 - 实现用户编辑接口,允许更新用户信息 - 添加用户删除接口,支持从数据库删除用户 - 修改路由配置,新增用户编辑和删除的GET请求路径 - 使用gorm完成用户数据的增删改查操作 - 初始化数据库连接,自动迁移User表结构 - 新增User和Article模型定义及对应的表名函数 - 在main.go中添加session中间件支持 - defaultController中实现基于session的用户名保存与读取 - 添加go.mod依赖,包含gorm与gin-contrib/sessions相关包
13 lines
147 B
Go
13 lines
147 B
Go
package model
|
|
|
|
type Article struct {
|
|
Id int
|
|
Title string
|
|
CateId int
|
|
State int
|
|
}
|
|
|
|
func (Article) TableName() string {
|
|
return "article"
|
|
}
|