mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
组织数据读取权限完成
This commit is contained in:
@@ -90,7 +90,6 @@ func (u *UserApi) Login(rc *restfulx.ReqCtx) {
|
||||
loginLog.Ipaddr = rc.Request.Request.RemoteAddr
|
||||
loginLog.LoginLocation = utils.GetRealAddressByIP(rc.Request.Request.RemoteAddr)
|
||||
loginLog.LoginTime = time.Now()
|
||||
loginLog.OrgId = login.OrganizationId
|
||||
loginLog.Status = "0"
|
||||
loginLog.Remark = rc.Request.Request.UserAgent()
|
||||
browserName, browserVersion := ua.Browser()
|
||||
@@ -131,7 +130,6 @@ func (u *UserApi) LogOut(rc *restfulx.ReqCtx) {
|
||||
loginLog.Ipaddr = rc.Request.Request.RemoteAddr
|
||||
loginLog.LoginTime = time.Now()
|
||||
loginLog.Status = "0"
|
||||
loginLog.OrgId = rc.LoginAccount.OrganizationId
|
||||
loginLog.Remark = rc.Request.Request.UserAgent()
|
||||
browserName, browserVersion := ua.Browser()
|
||||
loginLog.Browser = browserName + " " + browserVersion
|
||||
|
||||
@@ -27,6 +27,8 @@ type SysRole struct {
|
||||
ApiIds []casbin.CasbinRule `json:"apiIds" gorm:"-"`
|
||||
MenuIds []int64 `json:"menuIds" gorm:"-"`
|
||||
OrganizationIds []int64 `json:"organizationIds" gorm:"-"`
|
||||
|
||||
Org string `json:"org" gorm:"column:org"`
|
||||
}
|
||||
|
||||
type MenuIdList struct {
|
||||
|
||||
@@ -17,6 +17,7 @@ type (
|
||||
Delete(roleId []int64)
|
||||
GetRoleMeunId(data entity.SysRole) []int64
|
||||
GetRoleOrganizationId(data entity.SysRole) []int64
|
||||
FindOrganizationsByRoleId(roleId int64) (entity.SysRole, error)
|
||||
}
|
||||
|
||||
sysRoleModel struct {
|
||||
@@ -130,3 +131,14 @@ func (m *sysRoleModel) GetRoleOrganizationId(data entity.SysRole) []int64 {
|
||||
}
|
||||
return organizationIds
|
||||
}
|
||||
|
||||
func (m *sysRoleModel) FindOrganizationsByRoleId(roleId int64) (entity.SysRole, error) {
|
||||
var roleData entity.SysRole
|
||||
err := global.Db.Table(m.table).
|
||||
Select("sys_roles.data_scope, GROUP_CONCAT(sys_role_organizations.organization_id) as org").
|
||||
Joins("LEFT JOIN sys_role_organizations ON sys_roles.role_id = sys_role_organizations.role_id").
|
||||
Where("sys_roles.role_id = ?", roleId).
|
||||
Group("sys_roles.role_id").
|
||||
First(&roleData).Error
|
||||
return roleData, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user