2 Star 0 Fork 0

hero/momo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
user.go 3.24 KB
一键复制 编辑 原始数据 按行查看 历史
hero 提交于 2024-11-06 16:32 . upd:unique
package model
import (
"strconv"
"strings"
"gitee.com/linqwen/momo/base"
)
type RoleEntity struct {
base.SnowflakeIDModel
ParentId int64 `gorm:"column:parent_id" json:"ParentId,string" form:"ParentId" comment:"父Id"`
RoleName string `gorm:"column:role_name" json:"RoleName" form:"RoleName" comment:"角色名"`
RoleAlias string `gorm:"column:role_alias" json:"RoleAlias" form:"RoleAlias" comment:"角色别名"`
Sort int `gorm:"column:sort" json:"Sort" form:"Sort" comment:"排序"`
MenuIds string `gorm:"column:menu_ids" json:"MenuIds" form:"MenuIds" comment:"MenuIds"`
Children []*RoleEntity `gorm:"-" json:"children"`
Status int `gorm:"column:status;default:0" json:"Status" form:"Status" comment:"状态"`
}
func (RoleEntity) TableName() string { return "rbac_role" }
func (c RoleEntity) GetId() int64 { return c.Id }
func (c RoleEntity) GetAlias() string { return c.RoleAlias }
func (c RoleEntity) GetPermitIds() []int64 { return StringToInt64Slice(c.MenuIds) }
type UserEntity struct {
base.IdTimeStampsModel
base.SoftDeleteModel
ParentId int64 `gorm:"column:parent_id" json:"ParentId,string" form:"ParentId" comment:"父Id"`
Name string `gorm:"column:name" json:"Name" form:"Name" comment:"Name"`
UserType int `gorm:"column:user_type" json:"UserType" form:"UserType" comment:"UserType"`
Account string `gorm:"column:account;unique" json:"Account" form:"Account" comment:"Account"`
Password string `gorm:"column:password" json:"Password" form:"Password" comment:"Password"`
RealName string `gorm:"column:real_name" json:"RealName" form:"RealName" comment:"RealName"`
Avatar string `gorm:"column:avatar" json:"Avatar" form:"Avatar" comment:"Avatar"`
Email string `gorm:"column:email" json:"Email" form:"Email" comment:"Email"`
Phone string `gorm:"column:phone" json:"Phone" form:"Phone" comment:"Phone"`
Birthday string `gorm:"column:birthday" json:"Birthday" form:"Birthday" comment:"Birthday"`
Sex int `gorm:"column:sex" json:"Sex" form:"Sex" comment:"Sex"`
RoleIds string `gorm:"column:role_ids" json:"RoleIds" form:"RoleIds" comment:"RoleIds"`
DeptIds string `gorm:"column:dept_ids" json:"DeptIds" form:"DeptIds" comment:"DeptIds"`
PostIds string `gorm:"column:post_ids" json:"PostIds" form:"PostIds" comment:"PostIds"`
Tags string `gorm:"column:tags" json:"Tags" form:"Tags" comment:"Tags"`
Status int `gorm:"column:status;default:1" json:"Status" form:"Status" comment:"状态"`
Children []UserEntity `gorm:"-" json:"children"`
}
func (c UserEntity) TableName() string { return "rbac_user" }
func (c UserEntity) GetId() int64 { return c.Id }
func (c UserEntity) GetRoleIds() []int64 { return StringToInt64Slice(c.RoleIds) }
// 字符串转换成int64的切片
func StringToInt64Slice(s string) []int64 {
strArray := strings.Split(s, ",")
int64Slice := make([]int64, 0, len(strArray))
for _, str := range strArray {
trimmedStr := strings.TrimSpace(str) // 移除前后空白
int64Val, err := strconv.ParseInt(trimmedStr, 10, 64)
if err != nil {
return nil
}
int64Slice = append(int64Slice, int64Val)
}
return int64Slice
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/linqwen/momo.git
git@gitee.com:linqwen/momo.git
linqwen
momo
momo
v1.1.13

搜索帮助