45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
package model
|
||
|
||
import (
|
||
"admin/internal/db"
|
||
"admin/internal/model/dto"
|
||
"time"
|
||
)
|
||
|
||
func init() {
|
||
db.RegisterTableModels(Role{})
|
||
}
|
||
|
||
// Role 空表,就是用来兼容资源增删改查公共操作的,实际列举账号等都是走各个项目api拉取
|
||
type Role struct {
|
||
ProjectId int
|
||
ServerConfId string `name:"区服id" json:"serverId" choices:"GetServerConfIDChoices" where:"eq"`
|
||
Account string `name:"账号" json:"account" where:"eq"`
|
||
RoleId string `name:"角色ID" json:"roleId" where:"eq"`
|
||
Name string `name:"名称" json:"roleName" where:"eq"`
|
||
Status string `name:"状态" desc:"离线|在线" type:"tagStatus" choices:"GetStatusChoices"`
|
||
Level int `name:"等级" json:"roleLevel"`
|
||
Profession string `name:"职业" json:"profession"`
|
||
LatestLoginTime time.Time `name:"最近登录时间" json:"latestLoginAt"`
|
||
CreatedAt time.Time `name:"创建时间" json:"createAt"`
|
||
}
|
||
|
||
func (lm *Role) TableName() string {
|
||
return "role"
|
||
}
|
||
|
||
func (m *Role) GetId() int {
|
||
return 0
|
||
}
|
||
|
||
func (m *Role) GetServerConfIDChoices(project *Project) []*dto.CommonDtoFieldChoice {
|
||
return getChoiceServers(project)
|
||
}
|
||
|
||
func (m *Role) GetStatusChoices(project *Project) []*dto.CommonDtoFieldChoice {
|
||
return []*dto.CommonDtoFieldChoice{
|
||
{Desc: "离线", Value: "离线", Type: 3}, // type: 0:plain 1:primary 2:success 3:info 4:warning 5:danger
|
||
{Desc: "在线", Value: "在线", Type: 2},
|
||
}
|
||
}
|