2 Star 2 Fork 3

联犀/core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
assemble.go 2.80 KB
一键复制 编辑 原始数据 按行查看 历史
杨磊 提交于 2024-10-25 18:22 . feat: 支持区域树权限
package datamanagelogic
import (
"context"
"gitee.com/unitedrhino/core/service/syssvr/internal/repo/relationDB"
"gitee.com/unitedrhino/core/service/syssvr/internal/svc"
"gitee.com/unitedrhino/core/service/syssvr/pb/sys"
"gitee.com/unitedrhino/share/domain/userDataAuth"
)
func transAreaPoToPb(po *relationDB.SysDataArea) *sys.DataArea {
return &sys.DataArea{
AreaID: int64(po.AreaID),
AuthType: po.AuthType,
IsAuthChildren: po.IsAuthChildren,
}
}
func transProjectPoToPb(po *relationDB.SysDataProject) *sys.DataProject {
return &sys.DataProject{
ProjectID: int64(po.ProjectID),
AuthType: po.AuthType,
TargetID: po.TargetID,
}
}
func ToAuthAreaDo(ctx context.Context, svcCtx *svc.ServiceContext, area *sys.DataArea) *userDataAuth.Area {
if area == nil {
return nil
}
a, err := svcCtx.AreaCache.GetData(ctx, area.AreaID)
if err != nil {
return nil
}
return &userDataAuth.Area{AreaID: area.AreaID, AreaIDPath: a.AreaIDPath, AuthType: area.AuthType, IsAuthChildren: area.IsAuthChildren}
}
func ToAuthAreaDos(ctx context.Context, svcCtx *svc.ServiceContext, areas []*sys.DataArea) (ret []*userDataAuth.Area) {
if len(areas) == 0 {
return
}
for _, v := range areas {
a := ToAuthAreaDo(ctx, svcCtx, v)
if a == nil {
continue
}
ret = append(ret, a)
}
return
}
func DBToAuthAreaDo(area *relationDB.SysDataArea) *userDataAuth.Area {
if area == nil {
return nil
}
return &userDataAuth.Area{AreaID: int64(area.AreaID), AuthType: area.AuthType, IsAuthChildren: area.IsAuthChildren}
}
func DBToAuthAreaDos(areas []*relationDB.SysDataArea) (ret []*userDataAuth.Area) {
if len(areas) == 0 {
return
}
for _, v := range areas {
ret = append(ret, DBToAuthAreaDo(v))
}
return
}
func ToAuthProjectDo(area *sys.DataProject) *userDataAuth.Project {
if area == nil {
return nil
}
return &userDataAuth.Project{ProjectID: area.ProjectID, AuthType: area.AuthType}
}
func ToAuthProjectDos(areas []*sys.DataProject) (ret []*userDataAuth.Project) {
if len(areas) == 0 {
return
}
for _, v := range areas {
ret = append(ret, ToAuthProjectDo(v))
}
return
}
func DBToAuthProjectDo(area *relationDB.SysDataProject) *userDataAuth.Project {
if area == nil {
return nil
}
return &userDataAuth.Project{ProjectID: int64(area.ProjectID), AuthType: area.AuthType}
}
func DBToAuthProjectDos(areas []*relationDB.SysDataProject) (ret []*userDataAuth.Project) {
if len(areas) == 0 {
return
}
for _, v := range areas {
ret = append(ret, DBToAuthProjectDo(v))
}
return
}
func ToUserAreaApplyInfos(in []*relationDB.SysUserAreaApply) (ret []*sys.UserAreaApplyInfo) {
for _, v := range in {
ret = append(ret, &sys.UserAreaApplyInfo{
Id: v.ID,
UserID: v.UserID,
AreaID: int64(v.AreaID),
AuthType: v.AuthType,
CreatedTime: v.CreatedTime.Unix(),
})
}
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/unitedrhino/core.git
git@gitee.com:unitedrhino/core.git
unitedrhino
core
core
v1.0.3

搜索帮助