切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
ebc7c7aaf24c7731827da601e824cde8c72e5977
1 个父辈
74e3f031
角色逻辑
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
85 行增加
和
47 行删除
pkg/application/role/role_service.go
pkg/application/role/role_user_service.go
pkg/port/beego/controllers/role_controller.go
pkg/port/beego/controllers/role_user_controller.go
pkg/port/beego/routers/role_router.go
pkg/port/beego/routers/role_user_router.go
pkg/application/role/role_service.go
查看文件 @
ebc7c7a
...
...
@@ -80,7 +80,7 @@ func (rs *RoleService) Update(in *command.UpdateRoleCommand) (interface{}, error
}
role
.
Name
=
in
.
Name
role
.
Name
=
in
.
Description
role
.
Description
=
in
.
Description
role
,
err
=
roleRepository
.
Insert
(
role
)
if
err
!=
nil
{
...
...
@@ -171,6 +171,5 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{
roleUser
.
Users
=
tempList
adapterList
=
append
(
adapterList
,
roleUser
)
}
return
map
[
string
]
interface
{}{
"list"
:
adapterList
},
nil
return
tool_funs
.
SimpleWrapGridMap
(
int64
(
len
(
adapterList
)),
adapterList
),
nil
}
...
...
pkg/application/role/role_user_service.go
查看文件 @
ebc7c7a
...
...
@@ -2,6 +2,7 @@ package service
import
(
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
...
...
@@ -88,47 +89,25 @@ func (rs *RoleUserService) Remove(in *command.UserRoleDeleteCommand) (interface{
return
rus
,
nil
}
//func (rs *RoleUserService) ListForUser(in *command.UserRoleQueryCommand) (interface{}, error) {
// transactionContext, err := factory.StartTransaction()
// if err != nil {
// return nil, err
// }
// defer func() {
// transactionContext.RollbackTransaction()
// }()
// roleRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
// userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
//
// in.PageNumber = 1
// in.PageSize = 9999999
//
// conditionMap := tool_funs.SimpleStructToMap(in)
// _, roles, err := roleRepository.Find(conditionMap)
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// if len(roles) == 0 {
// return nil, application.ThrowError(application.BUSINESS_ERROR, "未找到角色数据")
// }
//
// ids := make([]int64, 0)
// for i := range roles {
// ids = append(ids, roles[i].Id)
// }
//
// _, users, err := userRepository.Find(conditionMap)
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
//
// //for i := range users {
// // users[i].RoleUserIds
// //}
//
// //if err := transactionContext.CommitTransaction(); err != nil {
// // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// //}
// //groupAdapter := &adapter.RoleUserAdapter{}
// //newList := groupAdapter.TransformTree(groups)
// return map[string]interface{}{"list": users}, nil
//}
func
(
rs
*
RoleUserService
)
ListRole
(
in
*
command
.
UserRoleQueryCommand
)
(
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
StartTransaction
()
if
err
!=
nil
{
return
nil
,
err
}
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
ruRepository
:=
factory
.
CreateRoleUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
in
.
PageNumber
=
1
in
.
PageSize
=
9999999
tempList
,
err
:=
ruRepository
.
FindAllContainUser
(
1
,
10
,
in
.
CompanyId
,
in
.
RoleId
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
tool_funs
.
SimpleWrapGridMap
(
int64
(
len
(
tempList
)),
tempList
),
nil
}
...
...
pkg/port/beego/controllers/role_controller.go
查看文件 @
ebc7c7a
...
...
@@ -44,3 +44,14 @@ func (controller *RoleController) RemoveRole() {
controller
.
Response
(
ruService
.
Remove
(
in
))
}
}
func
(
controller
*
RoleController
)
ListForUserRole
()
{
ruService
:=
service
.
NewRoleService
()
in
:=
&
command
.
QueryRoleUserCommand
{}
if
err
:=
controller
.
Unmarshal
(
in
);
err
!=
nil
{
controller
.
Response
(
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
err
.
Error
()))
}
else
{
in
.
CompanyId
=
middlewares
.
GetCompanyId
(
controller
.
Ctx
)
controller
.
Response
(
ruService
.
ListForUser
(
in
))
}
}
...
...
pkg/port/beego/controllers/role_user_controller.go
查看文件 @
ebc7c7a
...
...
@@ -33,3 +33,14 @@ func (controller *RoleUserController) RemoveRoleUser() {
controller
.
Response
(
ruService
.
Remove
(
in
))
}
}
func
(
controller
*
RoleUserController
)
ListRoleUser
()
{
ruService
:=
service
.
NewRoleUserService
()
in
:=
&
command
.
UserRoleQueryCommand
{}
if
err
:=
controller
.
Unmarshal
(
in
);
err
!=
nil
{
controller
.
Response
(
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
err
.
Error
()))
}
else
{
in
.
CompanyId
=
middlewares
.
GetCompanyId
(
controller
.
Ctx
)
controller
.
Response
(
ruService
.
ListRole
(
in
))
}
}
...
...
pkg/port/beego/routers/role_router.go
0 → 100644
查看文件 @
ebc7c7a
package
routers
import
(
"github.com/beego/beego/v2/server/web"
"github.com/linmadan/egglib-go/web/beego/filters"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)
func
init
()
{
ns
:=
web
.
NewNamespace
(
"/v1/role"
,
web
.
NSBefore
(
filters
.
AllowCors
(),
middlewares
.
CheckToken
()),
//web.NSRouter("/", &controllers.RoleController{}, "Post:CreateRole"),
//web.NSRouter("/", &controllers.RoleController{}, "Put:UpdateRole"),
//web.NSRouter("/", &controllers.RoleController{}, "Delete:RemoveRole"),
//web.NSRouter("/:Id", &controllers.RoleController{}, "Get:GetRole"),
web
.
NSRouter
(
"/all"
,
&
controllers
.
RoleController
{},
"Post:ListForUserRole"
),
)
web
.
AddNamespace
(
ns
)
}
...
...
pkg/port/beego/routers/role_user_router.go
0 → 100644
查看文件 @
ebc7c7a
package
routers
import
(
"github.com/beego/beego/v2/server/web"
"github.com/linmadan/egglib-go/web/beego/filters"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)
func
init
()
{
ns
:=
web
.
NewNamespace
(
"/v1/role-user"
,
web
.
NSBefore
(
filters
.
AllowCors
(),
middlewares
.
CheckToken
()),
web
.
NSRouter
(
"/"
,
&
controllers
.
RoleUserController
{},
"Post:CreateRole"
),
web
.
NSRouter
(
"/"
,
&
controllers
.
RoleUserController
{},
"Delete:RemoveRole"
),
web
.
NSRouter
(
"/all"
,
&
controllers
.
RoleUserController
{},
"Post:ListRoleUser"
),
)
web
.
AddNamespace
(
ns
)
}
...
...
请
注册
或
登录
后发表评论