forked from lxh/go-wxhelper
26 lines
633 B
Go
26 lines
633 B
Go
|
package initialize
|
||
|
|
||
|
import (
|
||
|
"gitee.ltd/lxh/logger/log"
|
||
|
"wechat-robot/internal/database"
|
||
|
"wechat-robot/model/entity"
|
||
|
)
|
||
|
|
||
|
// databaseTable
|
||
|
// @description: 初始化数据库表
|
||
|
func databaseTable() {
|
||
|
tables := []any{
|
||
|
new(entity.AdminUser), // 用户表
|
||
|
new(entity.Menu), // 菜单表
|
||
|
new(entity.Role), // 角色表
|
||
|
new(entity.RoleMenu), // 角色菜单表
|
||
|
new(entity.AdminUserRole), // 用户角色表
|
||
|
new(entity.Robot), // 机器人表
|
||
|
}
|
||
|
|
||
|
// 同步表结构
|
||
|
if err := database.Client.AutoMigrate(tables...); err != nil {
|
||
|
log.Panicf("初始化数据库表失败: %v", err)
|
||
|
}
|
||
|
}
|