model

package
v1.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2022 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPwd = "ABC123def"
View Source
var Logger *zap.Logger

Functions

func APIToPB

func APIToPB(in *API) *apipb.APIInfo

func APIsToPB

func APIsToPB(in []API) []*apipb.APIInfo

func AddMenu

func AddMenu(menu *Menu) error

@author: [guoxf](https://github.com/guoxf) @function: AddMenu @description: 添加菜单 @param: menu Menu @return: err error

func Authenticate

func Authenticate(t, method, url string, checkAuth bool) (*apipb.CurrentUser, int, error)

func AutoMigrate

func AutoMigrate()

AutoMigrate 自动生成表

func BindPhone added in v1.3.3

func BindPhone(userID string, phoneNuber string) error

func CheckRegisterWithWechat

func CheckRegisterWithWechat(unionID, openID string, resp *CheckRegisterWithWechatResp)

func ClearCasbin

func ClearCasbin(v int, p ...string) (bool, error)

@author: [guoxf](https://github.com/guoxf) @function: ClearCasbin @description: 清除匹配的权限 @param: v int, p ...string @return: bool

func CopyTenant

func CopyTenant(id string) error

func CreateAPI

func CreateAPI(api *API) error

@author: [guoxf](https://github.com/guoxf) @function: CreateAPI @description: 新增API @param: api API @return: err error

func CreateAPP

func CreateAPP(md *APP) error

func CreateRole

func CreateRole(newRole *Role) error

@author: [guoxf](https://github.com/guoxf) @function: CreateRole @description: 创建一个角色 @param: newRole Role @return: err error, role Role

func CreateTenant

func CreateTenant(m *Tenant) error

func CreateTitle

func CreateTitle(title *Title) error

func CreateUser

func CreateUser(user *User, isCreateFromWechat bool) error

@author: [guoxf](https://github.com/guoxf) @function: CreateUser @description: 新增User @param: user User @return: err error

func DeleteAPP

func DeleteAPP(id string) (err error)

func DeleteApi

func DeleteApi(id string) (err error)

@author: [guoxf](https://github.com/guoxf) @function: DeleteApi @description: 删除API @param: api API @return: err error

func DeleteMenu

func DeleteMenu(id string) (err error)

@author: [guoxf](https://github.com/guoxf) @function: DeleteMenu @description: 删除菜单 @param: id uint @return: err error

func DeleteRole

func DeleteRole(roleID string) (err error)

@author: [guoxf](https://github.com/guoxf) @function: DeleteRole @description: 删除角色 @param: auth *Role @return: err error

func DeleteTenant

func DeleteTenant(id string) (err error)

func DeleteTitle

func DeleteTitle(id string) (err error)

func DeleteUser

func DeleteUser(id string) (err error)

@author: [guoxf](https://github.com/guoxf) @function: DeleteUser @description: 删除User @param: user User @return: err error

func EnableAPI

func EnableAPI(id string, enable bool) error

func EnableTenant

func EnableTenant(id string, enable bool) error

func EnableUser

func EnableUser(id string, enable bool) error

func EncryptedPassword

func EncryptedPassword(password string) (string, error)

EncryptedPassword 对密码进行加密

func GetUserProfile

func GetUserProfile(id string) (*apipb.UserProfile, error)

func Init

func Init(connStr string, debug bool)

Init Init

func InitCasbin

func InitCasbin()

func Login

func Login(req *apipb.LoginRequest, resp *apipb.LoginResponse)

func LoginByWechat

func LoginByWechat(register bool, req *User, resp *apipb.LoginResponse)

func Logout

func Logout(t string) error
func MenuFuncApisToPB(params []MenuFuncApi) []*apipb.MenuFuncApi
func MenuFuncsToPB(params []*MenuFunc) []*apipb.MenuFunc
func MenuParametersToPB(params []*MenuParameter) []*apipb.MenuParameter
func MenuToPB(in *Menu) *apipb.MenuInfo
func MenusToPB(in []*Menu) []*apipb.MenuInfo

func NewEnforcer

func NewEnforcer() *casbin.Enforcer

@author: [guoxf](https://github.com/guoxf) @function: NewEnforcer @description: 持久化到数据库 引入自定义规则 @return: *casbin.Enforcer

func ParamsMatch

func ParamsMatch(fullNameKey1 string, key2 string) bool

@author: [guoxf](https://github.com/guoxf) @function: ParamsMatch @description: 自定义规则函数 @param: fullNameKey1 string, key2 string @return: bool

func ParamsMatchFunc

func ParamsMatchFunc(args ...interface{}) (interface{}, error)

@author: [guoxf](https://github.com/guoxf) @function: ParamsMatchFunc @description: 自定义规则函数 @param: args ...interface{} @return: interface{}, error

func QueryAPI

func QueryAPI(req *apipb.QueryAPIRequest, resp *apipb.QueryAPIResponse)

@author: [guoxf](https://github.com/guoxf) @function: GetAPIInfoList @description: 分页查询API @param: api API, info PageInfo, order string, desc bool @return: list []*API, total int64 , err error

func QueryAPP

func QueryAPP(req *QueryAPPRequest, resp *QueryAPPResponse)

func QueryMenu

func QueryMenu(req *apipb.QueryMenuRequest, resp *apipb.QueryMenuResponse)

@author: [guoxf](https://github.com/guoxf) @function: GetMenuInfoList @description: 分页查询Menu @param: api Menu, info PageInfo, order string, desc bool @return: list []*Menu, total int64 , err error

func QueryRole

func QueryRole(req *apipb.QueryRoleRequest, resp *apipb.QueryRoleResponse)

func QueryTenant

func QueryTenant(req *apipb.QueryTenantRequest, resp *apipb.QueryTenantResponse)

func QueryTitle

func QueryTitle(req *QueryTitleRequest, resp *QueryTitleResponse)

func QueryUser

func QueryUser(req *apipb.QueryUserRequest, resp *apipb.QueryUserResponse)

@author: [guoxf](https://github.com/guoxf) @function: GetUserInfoList @description: 分页查询User @param: user User, info PageInfo, order string, desc bool @return: list []*User, total int64 , err error

func ResetPwd

func ResetPwd(id string, pwd string) error

func RoleMenusToPB

func RoleMenusToPB(roleMenus []*RoleMenu) []*apipb.RoleMenu

func RoleToPB

func RoleToPB(in *Role) *apipb.RoleInfo

func RolesToPB

func RolesToPB(in []*Role) []*apipb.RoleInfo

func SetDefaultPwd

func SetDefaultPwd(defaultPwd string)

func StatisticRoleCount added in v1.1.0

func StatisticRoleCount(tenantID string) (int64, error)

func StatisticTenantCount added in v1.1.0

func StatisticTenantCount() (int64, error)

func StatisticUserCount added in v1.1.0

func StatisticUserCount(t int, tenantID, group string) (int64, error)

func TenantToPB

func TenantToPB(in *Tenant) *apipb.TenantInfo

func TenantsToPB

func TenantsToPB(in []*Tenant) []*apipb.TenantInfo

func UpdateAPI

func UpdateAPI(api *API) error

@author: [guoxf](https://github.com/guoxf) @function: UpdateAPI @description: 根据id更新api @param: api API @return: err error

func UpdateAPP

func UpdateAPP(md *APP) error

func UpdateCasbin

func UpdateCasbin(roleID string, casbinInfos []*CasbinRule) error

@author: [guoxf](https://github.com/guoxf) @function: UpdateCasbin @description: 更新casbin权限 @param: roleID string, casbinInfos []CasbinRule @return: error

func UpdateCasbinApi

func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod string) error

@author: [guoxf](https://github.com/guoxf) @function: UpdateCasbinApi @description: API更新随动 @param: oldPath string, newPath string, oldMethod string, newMethod string @return: error

func UpdateMenu

func UpdateMenu(menu *Menu) (err error)

@author: [guoxf](https://github.com/guoxf) @function: UpdateMenu @description: 更新菜单 @param: menu Menu @return:err error

func UpdateProfile

func UpdateProfile(m *User, updateUserName bool) error

UpdateProfile 更新个人信息

func UpdateProfileAndUserName added in v1.1.7

func UpdateProfileAndUserName(m *User) error

func UpdatePwd

func UpdatePwd(id string, oldPwd, newPwd string) error

func UpdateRole

func UpdateRole(newRole *Role) error

@author: [guoxf](https://github.com/guoxf) @function: UpdateRole @description: 更改一个角色 @param: newRole Role @return:err error, role Role

func UpdateTenant

func UpdateTenant(m *Tenant) error

func UpdateTitle

func UpdateTitle(title *Title) error

func UpdateUser

func UpdateUser(user *User) error

@author: [guoxf](https://github.com/guoxf) @function: UpdateUser @description: 根据id更新user @param: user User @return: err error

func UserRolesToPB

func UserRolesToPB(userRoles []*UserRole) []*apipb.UserRole

func UserToPB

func UserToPB(in *User) *apipb.UserInfo

func UsersToPB

func UsersToPB(in []*User) []*apipb.UserInfo

func ValidPasswdStrength

func ValidPasswdStrength(str string) bool

Types

type API

type API struct {
	model.Model
	Path        string `json:"path" gorm:"size:200;index;comment:路径"`
	Group       string `json:"group" gorm:"size:50;index;comment:分组"`
	Method      string `json:"method" gorm:"size:50;index;default:POST;comment:方法"`
	Description string `json:"description" gorm:"size:200;index;comment:中文描述"`
	Enable      bool   `json:"enable" gorm:"index;comment:是否启用API"`
	//如果不开启权限校验,那么在每个角色都加上casbin rule
	//1. 不需要登录就可以直接访问
	//2. 需要登录但不需要校验权限,也就是所有人都可以访问
	//3. 需要登录并且校验权限
	CheckAuth  bool `json:"checkAuth" gorm:"index;comment:是否校验权限"`
	CheckLogin bool `json:"checkLogin" gorm:"index;comment:是否校验登录"`
}

func GetAPIById

func GetAPIById(id string) (api API, err error)

@author: [guoxf](https://github.com/guoxf) @function: GetAPIById @description: 根据id获取api @param: id string @return: api API , err error

func GetAllAPIs

func GetAllAPIs() (apis []API, err error)

@author: [guoxf](https://github.com/guoxf) @function: GetAllAPIs @description: 获取所有API @return: apis []API , err error

func PBToAPI

func PBToAPI(in *apipb.APIInfo) *API

func (API) TableName

func (API) TableName() string

type APP

type APP struct {
	model.Model
	Name        string    `json:"name" gorm:"size:200;index"`
	Entry       string    `json:"entry" gorm:"size:200;"`
	DevEntry    string    `json:"devEntry" gorm:"size:200;"`
	TestEntry   string    `json:"testEntry" gorm:"size:200;"`
	PreEntry    string    `json:"preEntry" gorm:"size:200;"`
	DisplayName string    `json:"displayName" gorm:"size:100;comment:显示名字"`
	Credentials bool      `json:"credentials"`
	Description string    `json:"description" gorm:"size:200;"`
	Props       []APPProp `json:"props"`
	Container   string    `json:"container" gorm:"size:100"`
	ActiveRule  string    `json:"activeRule" gorm:"size:200"`
	Enable      bool      `json:"enable"`
}

func GetAPPById

func GetAPPById(id string) (md APP, err error)

func GetAllAPPs

func GetAllAPPs() (mds []*APP, err error)

type APPProp

type APPProp struct {
	gorm.Model
	APPID uint   `json:"appID"`
	Key   string `json:"key" gorm:"size:50;"`
	Value string `json:"value" gorm:"size:200;"`
}

type CasbinRule

type CasbinRule struct {
	ID        uint   `gorm:"primaryKey;autoIncrement"`
	Ptype     string `json:"ptype" gorm:"column:ptype;size:8;uniqueIndex:unique_index"`
	RoleID    string `json:"roleID" gorm:"column:v0;size:36;uniqueIndex:unique_index"`
	Path      string `json:"path" gorm:"column:v1;size:200;uniqueIndex:unique_index"`
	Method    string `json:"method" gorm:"column:v2;size:10;uniqueIndex:unique_index"`
	CheckAuth string `gorm:"column:v3;size:10;uniqueIndex:unique_index"`
	V4        string `gorm:"size:128;uniqueIndex:unique_index"`
	V5        string `gorm:"size:128;uniqueIndex:unique_index"`
}

func GetPolicyPathByRoleID

func GetPolicyPathByRoleID(roleID string) (pathMaps []*CasbinRule)

@author: [guoxf](https://github.com/guoxf) @function: GetPolicyPathByRoleID @description: 获取权限列表 @param: roleID string @return: pathMaps []CasbinRule

func (CasbinRule) TableName

func (CasbinRule) TableName() string

type CheckRegisterWithWechatResp

type CheckRegisterWithWechatResp struct {
	model.CommonResponse
	Data bool `json:"data"`
}
type Menu struct {
	model.Model
	Level       uint32           `json:"level"`
	ParentID    string           `json:"parentID" gorm:"comment:父菜单ID"`
	Path        string           `json:"path" gorm:"size:200;comment:路由path"`
	Name        string           `json:"name" gorm:"size:100;comment:路由name"`
	Hidden      bool             `json:"hidden" gorm:"comment:是否在列表隐藏"`
	Component   string           `json:"component" gorm:"size:200;comment:对应前端文件路径"`
	Sort        int32            `json:"sort" gorm:"comment:排序标记"`
	Cache       bool             `json:"cache" gorm:"comment:是否缓存"`
	DefaultMenu bool             `json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"`
	Title       string           `json:"title" gorm:"size:100;comment:菜单名"`
	Icon        string           `json:"icon" gorm:"size:100;comment:菜单图标"`
	CloseTab    bool             `json:"closeTab" gorm:"comment:自动关闭tab"`
	Children    []*Menu          `json:"children" gorm:"-"`
	Parameters  []*MenuParameter `json:"parameters"`
	MenuFuncs   []*MenuFunc      `json:"menuFuncs"`
}

func GetAllMenus

func GetAllMenus() (menus []*Menu, err error)

func GetBaseMenuTree

func GetBaseMenuTree() (menus []*Menu, err error)

@author: [guoxf](https://github.com/guoxf) @function: GetBaseMenuTree @description: 获取基础路由树 @return: err error, menus []Menu

func GetInfoList

func GetInfoList() (list []*Menu, total int64, err error)

@author: [guoxf](https://github.com/guoxf) @function: GetInfoList @description: 获取路由分页 @return: err error, list interface{}, total int64

func GetMenuByID

func GetMenuByID(id string) (*Menu, error)

@author: [guoxf](https://github.com/guoxf) @function: GetMenuByID @description: 返回当前选中menu @param: id uint @return: err error, menu Menu

func GetMenuTree

func GetMenuTree(roleID string) (menus []*Menu, err error)

@author: [guoxf](https://github.com/guoxf) @function: GetMenuTree @description: 获取动态菜单树 @param: roleID string @return: err error, menus []RoleMenu

func PBToMenu

func PBToMenu(in *apipb.MenuInfo) *Menu
type MenuFunc struct {
	model.Model
	MenuID       string        `json:"menuID" gorm:"index"`
	Name         string        `json:"name" gorm:"size:100;comment:功能名称"`
	Title        string        `json:"title" gorm:"size:100;comment:显示名称"`
	Hidden       bool          `json:"hidden" gorm:"comment:是否隐藏"`
	MenuFuncApis []MenuFuncApi `json:"menuFuncApis"`
}

func PBToMenuFuncs

func PBToMenuFuncs(params []*apipb.MenuFunc) []*MenuFunc
type MenuFuncApi struct {
	model.Model
	MenuFuncID string `json:"menuFuncID" gorm:"index"`
	APIID      string `json:"apiID" gorm:"column:api_id"`
	API        *API   `json:"apiInfo"`
}

func PBToMenuFuncApis

func PBToMenuFuncApis(params []*apipb.MenuFuncApi) []MenuFuncApi
type MenuParameter struct {
	model.Model
	MenuID string `json:"menuID" gorm:"index"`
	Type   string `json:"type" gorm:"size:50;comment:地址栏携带参数为params还是query"`
	Key    string `json:"key" gorm:"size:100;comment:地址栏携带参数的key"`
	Value  string `json:"value" gorm:"size:200;comment:地址栏携带参数的值"`
}

func PBToMenuParameters

func PBToMenuParameters(params []*apipb.MenuParameter) []*MenuParameter

type QueryAPIRequest

type QueryAPIRequest struct {
	model.CommonRequest
	Path       string `json:"path" form:"path" path:"path"`
	Method     string `json:"method" form:"method" path:"method"`
	Group      string `json:"group" form:"group" path:"group"`
	CheckAuth  int    `json:"checkAuth" form:"checkAuth" path:"checkAuth"`
	CheckLogin int    `json:"checkLogin" form:"checkLogin" path:"checkLogin"`
}

type QueryAPIResponse

type QueryAPIResponse struct {
	model.CommonResponse
	Data []API `json:"data"`
}

type QueryAPPRequest

type QueryAPPRequest struct {
	model.CommonRequest
	Name   string `json:"name" form:"name" uri:"name"`
	Enable int    `json:"enable" form:"enable" uri:"enable"`
}

type QueryAPPResponse

type QueryAPPResponse struct {
	model.CommonResponse
	Data []*APP `json:"data"`
}

type QueryMenuRequest

type QueryMenuRequest struct {
	model.CommonRequest
	Name     string `json:"name" form:"name" uri:"name"`
	Path     string `json:"path" form:"path" uri:"path"`
	ParentID string `json:"group" form:"group" uri:"group"`
	Title    string `json:"title"  form:"title" uri:"title"`
	Level    uint   `json:"level"  form:"level" uri:"level"`
}

type QueryMenuResponse

type QueryMenuResponse struct {
	model.CommonResponse
	Data []*Menu `json:"data"`
}

type QueryTenantRequest

type QueryTenantRequest struct {
	model.CommonRequest
	Name string `json:"name" form:"name" uri:"name"`
}

type QueryTenantResponse

type QueryTenantResponse struct {
	model.CommonResponse
	Data []*Tenant `json:"data"`
}

type QueryTitleRequest

type QueryTitleRequest struct {
	model.CommonRequest
	Name        string `json:"name" form:"name" uri:"name"`
	DisplayName string `json:"displayName" form:"displayName" uri:"displayName"`
}

type QueryTitleResponse

type QueryTitleResponse struct {
	model.CommonResponse
	Data []Title `json:"data"`
}

type QueryUserRequest

type QueryUserRequest struct {
	model.CommonRequest
	UserName  string `json:"userName" form:"userName" uri:"userName"`
	Nickname  string `json:"nickname" form:"nickname" uri:"nickname"`
	IDCard    string `json:"idCard" form:"idCard" uri:"idCard"`
	Mobile    string `json:"mobile" form:"mobile" uri:"mobile"`
	WechatID  string `json:"wechatID" form:"wechatID" uri:"wechatID"`
	Title     string `json:"title" form:"title" uri:"title"`
	UserNames string `json:"userNames" form:"userNames" uri:"userNames"`
}

type QueryUserResponse

type QueryUserResponse struct {
	model.CommonResponse
	Data []*User `json:"data"`
}

type Role

type Role struct {
	model.Model
	TenantID      *sql.NullString `json:"tenantID" gorm:"index;size:36"`
	Name          string          `json:"name" gorm:"size:100;comment:角色名"`
	ParentID      string          `json:"parentID" gorm:"comment:父角色ID"`
	Children      []*Role         `json:"children" gorm:"-"`
	RoleMenus     []*RoleMenu     `json:"roleMenus"`
	DefaultRouter string          `json:"defaultRouter" gorm:"size:100;comment:默认菜单;default:dashboard"`
	Description   string          `json:"description" gorm:"size:200;"`
	CanDel        bool            `json:"canDel" gorm:"default:1"`
	Tenant        *Tenant         `json:"tenant"`
}

func CopyRole

func CopyRole(copyInfo RoleCopyResponse) (*Role, error)

@author: [guoxf](https://github.com/guoxf) @function: CopyRole @description: 复制一个角色 @param: copyInfo RoleCopyResponse @return: err error, role Role

func GetAllRole

func GetAllRole(tenantID string, containerCommon bool) (roles []*Role, err error)

GetAllRole 获取所有用户 containerCommon true-包含公共角色 false-不包含公共角色 公共角色定义:不设置租户的角色

func GetFullRoleByID

func GetFullRoleByID(id string) (*Role, error)

func GetRoleByID

func GetRoleByID(id string) (*Role, error)

func PBToRole

func PBToRole(in *apipb.RoleInfo) *Role

type RoleCopyResponse

type RoleCopyResponse struct {
	Role      Role   `json:"role"`
	OldRoleID string `json:"oldRoleID"`
}

type RoleMenu

type RoleMenu struct {
	model.Model
	RoleID string `json:"roleID" gorm:"index;comment:角色ID"`
	MenuID string `json:"menuID" gorm:"index;comment:菜单ID"`
	Funcs  string `json:"funcs" gorm:"size:500;comment:功能名称,多个以逗号隔开"`
	Menu   *Menu  `json:"menu"`
}

func GetMenuRole

func GetMenuRole(roleID string) (menus []RoleMenu, err error)

@author: [guoxf](https://github.com/guoxf) @function: GetMenuRole @description: 查看当前角色权限树 @param: info *request.GetAuthorityId @return: err error, menus []RoleMenu

func PBToRoleMenus

func PBToRoleMenus(roleMenus []*apipb.RoleMenu) []*RoleMenu

type RoleResponse

type RoleResponse struct {
	Role Role `json:"role"`
}

type Tenant

type Tenant struct {
	model.Model
	// 租户名称
	// required: true
	// @inject_tag: validate:"required"
	Name string `json:"name" validate:"required" gorm:"index;size:200"`
	// 联系人
	Contact string `json:"contact" gorm:"size:100"`
	// 联系人电话
	CellPhone string `json:"cellPhone" gorm:"size:50"`
	// 地址
	Address string `json:"address" gorm:"size:200"`
	// 业务范围
	BusinessScope string `json:"businessScope" gorm:"size:200"`
	// 占地面积
	AreaCovered string `json:"areaCovered" gorm:"size:100"`
	// 人员规模
	StaffSize int32 `json:"staffSize"`
	Enable    bool  `json:"enable" gorm:"index"`
}

func GetAllTenant

func GetAllTenant() (list []*Tenant, err error)

func GetTenantByID

func GetTenantByID(id string) (*Tenant, error)

func PBToTenant

func PBToTenant(in *apipb.TenantInfo) *Tenant

type Title

type Title struct {
	model.TenantModel
	Name        string `json:"name" gorm:"size:100;"`
	DisplayName string `json:"displayName" gorm:"size:100;"`
	Description string `json:"description" gorm:"size:200;"`
}

func GetAllTitles

func GetAllTitles() (titles []Title, err error)

func GetTitleById

func GetTitleById(id string) (title Title, err error)

type User

type User struct {
	model.TenantModel
	//账号信息
	UserName      string      `json:"userName"  validate:"required" gorm:"size:50;index;comment:用户登录名"`
	Password      string      `json:"password"  gorm:"size:200;comment:用户登录密码"`
	Nickname      string      `json:"nickname"  validate:"required" gorm:"size:100;index;default:未设置;comment:用户昵称" `
	UserRoles     []*UserRole `json:"userRoles"`
	RoleIDs       []string    `json:"roleIDs" gorm:"-"`
	WechatUnionID string      `json:"wechatUnionID" gorm:"size:36;index;comment:微信UionID"`
	WechatOpenID  string      `json:"wechatOpenID" gorm:"size:36;index;comment:微信OpenID"`
	//用户类型
	Type  int32  `json:"type" gorm:"index"`
	Group string `json:"group" gorm:"index;size:50"`
	//启用账号后可以登录系统
	Enable bool `json:"enable" gorm:"index"`
	// 用户名/密码错误次数
	ErrNumber int32 `json:"errNumber"`
	// 随着密码/用户名错误次数增加,用户被锁定的时间也就越长,一天最多错误5次
	LockedExpired int64 `json:"lockedExpired"`
	// 强制修改密码
	ForceChangePwd bool `json:"forceChangePwd"`
	// 用户过期时间
	Expired                int64 `json:"expired"`
	ChangePwdErrNum        int32 `json:"changePwdErrNum"`
	ChangePwdLockedExpired int64 `json:"changePwdLockedExpired"`

	CanDel bool `json:"canDel"`

	//基本信息
	Email       string `json:"email" gorm:"size:100;"`
	Mobile      string `json:"mobile" gorm:"size:20;index;comment:手机号"`
	IDCard      string `json:"idCard"  gorm:"size:18;index;comment:身份证号"`
	Avatar      string `json:"avatar" gorm:"size:200;comment:用户头像"`
	EID         string `json:"eid" gorm:"size:50;"`
	Title       string `json:"title" gorm:"size:100;comment:职位"`
	Description string `json:"description" gorm:"size:200;"`
	RealName    string `json:"realName" gorm:"index;size:50;"`
	Gender      bool   `json:"gender"`

	Country  string `json:"country" gorm:"size:100;"`  //国家
	Province string `json:"province" gorm:"size:100;"` //省份
	City     string `json:"city" gorm:"size:100;"`     //城市
	County   string `json:"county" gorm:"size:100;"`   //区县
	Birthday int64  `json:"birthday"`                  //公历出生日期包含时分

	Tenant *Tenant `json:"tenant"`
}

func GetAllUsers

func GetAllUsers(req *apipb.GetAllUsersRequest) (users []*User, err error)

@author: [guoxf](https://github.com/guoxf) @function: GetAllUsers @description: 获取所有User @return: users []User , err error

func GetUserById

func GetUserById(id string) (user User, err error)

@author: [guoxf](https://github.com/guoxf) @function: GetUserById @description: 根据id获取user @param: id uint @return: user User , err error

func PBToUser

func PBToUser(in *apipb.UserInfo) *User

func UserProfileToUser added in v1.1.3

func UserProfileToUser(in *apipb.UserProfile) *User

func (User) GetRoleIDs

func (u User) GetRoleIDs() []string

type UserProfile

type UserProfile struct {
	apipb.UserProfile
	Menus []*Menu `json:"menus"`
}

type UserRole

type UserRole struct {
	model.Model
	UserID string `json:"userID" gorm:"index"`
	RoleID string `json:"roleID" gorm:"index"`
	Role   *Role
}

func PBToUserRoles

func PBToUserRoles(userRoles []*apipb.UserRole) []*UserRole

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL