uniugm/admin/apps/user/model/character.go
2025-04-30 15:46:14 +08:00

44 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"admin/internal/db"
"admin/internal/global"
"admin/lib/xlog"
"time"
)
func init() {
db.RegisterTableModels(Character{})
}
type Permission struct {
}
// Character 角色权限组
type Character struct {
ID int `gorm:"primarykey" readonly:"true"`
Name string `name:"角色名" desc:"区别一组用户的名字例如qa、策划、运营" gorm:"type:varchar(255);unique" required:"true" uneditable:"true"`
// 权限列表,格式就是 ["project:<projectId>:<resource>:<get>", "sys:user:get", ...]
// 例如项目3封禁功能的列表获取权限"project:3:ban:list"
Permissions []string `gorm:"type:json;serializer:json" name:"权限列表" type:"Permissions"`
CreatedAt time.Time `readonly:"true"`
}
func (m *Character) TableName() string {
return "character"
}
func (m *Character) GetId() int {
return m.ID
}
func (m *Character) List() []*Character {
list := make([]*Character, 0)
err := global.GLOB_DB.Find(&list).Error
if err != nil {
xlog.Errorf("get all character error:%v", err)
return list
}
return list
}