切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
53def8bceb5498ebcb2f4854442fe2fbb70cb3cd
1 个父辈
c13ed216
周期下的 模板和规则数据 生成
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
53 行增加
和
10 行删除
pkg/application/evaluation_cycle/cycle_service.go
pkg/domain/evaluation_template.go
pkg/infrastructure/repository/pg_evaluation_cycle_template_repository.go
pkg/infrastructure/repository/pg_evaluation_rule_repository.go
pkg/application/evaluation_cycle/cycle_service.go
查看文件 @
53def8b
...
...
@@ -30,6 +30,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
cycleRepository
:=
factory
.
CreateEvaluationCycleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
cycleTemplateRepository
:=
factory
.
CreateEvaluationCycleTemplateRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
templateRepository
:=
factory
.
CreateEvaluationTemplateRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
ruleRepository
:=
factory
.
CreateEvaluationRuleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
// 检测名称重复
count
,
err
:=
cycleRepository
.
Count
(
map
[
string
]
interface
{}{
"name"
:
in
.
Name
,
"companyId"
:
in
.
CompanyId
})
...
...
@@ -48,6 +49,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"模板不存在, 请重新选择"
)
}
// 生成新周期数据
newCycle
:=
&
domain
.
EvaluationCycle
{
Id
:
0
,
Name
:
in
.
Name
,
...
...
@@ -62,11 +64,41 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 获取所有模板中的规则对象数据
ruleIds
:=
make
([]
int64
,
0
)
ruleMap
:=
map
[
int64
]
*
domain
.
EvaluationRule
{}
for
i
:=
range
templates
{
v
:=
templates
[
i
]
for
j
:=
range
v
.
LinkNodes
{
node
:=
v
.
LinkNodes
[
j
]
for
k
:=
range
node
.
NodeContents
{
nodeContent
:=
node
.
NodeContents
[
k
]
ruleIds
=
append
(
ruleIds
,
nodeContent
.
RuleId
)
}
}
}
_
,
rules
,
err
:=
ruleRepository
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
ruleIds
,
"companyId"
:
in
.
CompanyId
})
for
i
:=
range
rules
{
ruleMap
[
rules
[
i
]
.
Id
]
=
rules
[
i
]
}
ctAdapter
:=
&
adapter
.
CycleTemplateAdapter
{}
ctAdapter
.
EvaluationCycle
=
cycle
for
i
:=
range
templates
{
v
:=
templates
[
i
]
// 对评估模板中的评估规则进行数据赋值
for
j
:=
range
v
.
LinkNodes
{
node
:=
v
.
LinkNodes
[
j
]
for
k
:=
range
node
.
NodeContents
{
nodeContent
:=
node
.
NodeContents
[
k
]
if
rule
,
ok
:=
ruleMap
[
nodeContent
.
RuleId
];
ok
{
nodeContent
.
Rule
=
rule
}
}
}
// 插入周期中的模板数据
cycleTemplate
:=
&
domain
.
EvaluationCycleTemplate
{
Id
:
0
,
Name
:
v
.
Name
,
...
...
@@ -78,10 +110,11 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 输出模板简单信息
ctAdapter
.
TemplateSimples
=
append
(
ctAdapter
.
TemplateSimples
,
&
domain
.
TemplateSimple
{
Id
:
v
.
Id
,
Name
:
v
.
Name
,
CreatedAt
:
v
.
CreatedAt
,
Id
:
cycleTemplate
.
Id
,
Name
:
cycleTemplate
.
Name
,
CreatedAt
:
cycleTemplate
.
CreatedAt
,
})
}
...
...
pkg/domain/evaluation_template.go
查看文件 @
53def8b
...
...
@@ -31,12 +31,13 @@ type EntryItem struct {
// NodeContent 评估内容
type
NodeContent
struct
{
Category
string
`json:"category" comment:"类别"`
Name
string
`json:"name" comment:"名称"`
RuleId
string
`json:"ruleId" comment:"评估规则ID"`
PromptTitle
string
`json:"promptTitle" comment:"提示项标题"`
PromptText
string
`json:"promptText" comment:"提示项正文"`
EntryItems
[]
*
EntryItem
`json:"entryItems" comment:"填写项"`
Category
string
`json:"category" comment:"类别"`
Name
string
`json:"name" comment:"名称"`
RuleId
int64
`json:"ruleId" comment:"评估规则ID"`
Rule
*
EvaluationRule
`json:"rule" comment:"评估规则对象"`
PromptTitle
string
`json:"promptTitle" comment:"提示项标题"`
PromptText
string
`json:"promptText" comment:"提示项正文"`
EntryItems
[]
*
EntryItem
`json:"entryItems" comment:"填写项"`
}
//// NodeAllInvite 360°邀请
...
...
pkg/infrastructure/repository/pg_evaluation_cycle_template_repository.go
查看文件 @
53def8b
...
...
@@ -58,9 +58,14 @@ func (repo *EvaluationCycleTemplateRepository) Insert(d *domain.EvaluationCycleT
d
.
Id
=
id
d
.
CreatedAt
=
time
.
Now
()
d
.
UpdatedAt
=
d
.
CreatedAt
// 模板对象ID也更新
if
d
.
Template
!=
nil
{
d
.
Template
.
Id
=
id
}
}
else
{
d
.
UpdatedAt
=
time
.
Now
()
}
m
:=
repo
.
TransformToModel
(
d
)
tx
:=
repo
.
transactionContext
.
PgTx
var
err
error
...
...
pkg/infrastructure/repository/pg_evaluation_rule_repository.go
查看文件 @
53def8b
...
...
@@ -123,6 +123,10 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{})
query
.
Where
(
"name LIKE ? or remark LIKE ?"
,
v
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"ids"
];
ok
{
query
.
Where
(
"id in(?)"
,
pg
.
In
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"name"
];
ok
{
query
.
Where
(
"name = ?"
,
v
)
}
...
...
请
注册
或
登录
后发表评论