切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
766ec72a3f6685862634cd3ecfe57d0852bbccfb
1 个父辈
562fd8fb
1. 获取规则列表,优化默认规则判断
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
13 行增加
和
21 行删除
pkg/application/evaluation_rule/rule_service.go
pkg/application/evaluation_rule/rule_service.go
查看文件 @
766ec72
...
...
@@ -173,6 +173,19 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i
ruleRepository
:=
factory
.
CreateEvaluationRuleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
userRepository
:=
factory
.
CreateUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
// 查询系统默认规则
_
,
sysRules
,
err
:=
ruleRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
in
.
CompanyId
,
"sysType"
:
domain
.
EvaluationSysTypeSystem
,
"limit"
:
1
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 不存在,生成默认规则
if
len
(
sysRules
)
==
0
{
newRule
:=
domain
.
GenerateSysRule
(
in
.
CompanyId
)
if
_
,
err
:=
ruleRepository
.
Insert
(
newRule
);
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
}
total
,
rules
,
err
:=
ruleRepository
.
Find
(
tool_funs
.
SimpleStructToMap
(
in
))
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
...
...
@@ -180,31 +193,11 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i
ras
:=
make
([]
*
adapter
.
RuleAdapter
,
0
)
creatorIds
:=
make
([]
int64
,
0
)
var
havaSystemType
=
false
for
i
:=
range
rules
{
ra
:=
&
adapter
.
RuleAdapter
{}
ra
.
EvaluationRule
=
rules
[
i
]
ras
=
append
(
ras
,
ra
)
creatorIds
=
append
(
creatorIds
,
rules
[
i
]
.
CreatorId
)
if
rules
[
i
]
.
SysType
==
domain
.
EvaluationSysTypeSystem
{
havaSystemType
=
true
break
}
}
// 如果不存在系统默认就生成一个
if
!
havaSystemType
{
newRule
:=
domain
.
GenerateSysRule
(
in
.
CompanyId
)
rule
,
err
:=
ruleRepository
.
Insert
(
newRule
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
ra
:=
&
adapter
.
RuleAdapter
{}
ra
.
EvaluationRule
=
rule
ras
=
append
(
ras
,
ra
)
total
+=
1
}
_
,
users
,
_
:=
userRepository
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
creatorIds
,
"limit"
:
len
(
creatorIds
)})
...
...
@@ -218,7 +211,6 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i
if
v
,
ok
:=
userNameMap
[
ras
[
i
]
.
CreatorId
];
ok
{
ras
[
i
]
.
CreatorName
=
v
}
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
...
...
请
注册
或
登录
后发表评论