切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
65cbc1d169a1a30611dfac0fd7bae87d017515cc
1 个父辈
7582e8f7
周期统计项目 人员和部门数量
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
106 行增加
和
35 行删除
pkg/application/evaluation_cycle/cycle_service.go
pkg/application/evaluation_project/command/project_query.go
pkg/application/evaluation_project/command/project_update.go
pkg/application/evaluation_project/project_service.go
pkg/application/evaluation_rule/rule_service.go
pkg/application/evaluation_template/template_service.go
pkg/port/beego/controllers/evaluation_project_controller.go
pkg/application/evaluation_cycle/cycle_service.go
查看文件 @
65cbc1d
...
...
@@ -7,7 +7,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_cycle/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
"strconv"
)
...
...
@@ -174,14 +173,13 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf
}
func
(
rs
*
EvaluationCycleService
)
Get
(
in
*
command
.
GetCycleCommand
)
(
interface
{},
error
)
{
// Get 不需要事务
if
err
:=
utils
.
ValidateCommand
(
in
);
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
err
.
Error
())
}
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
transactionContext
,
err
:=
factory
.
ValidateStartTransaction
(
in
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
return
nil
,
err
}
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
cycleRepository
:=
factory
.
CreateEvaluationCycleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
cycleTemplateRepository
:=
factory
.
CreateEvaluationCycleTemplateRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
...
...
@@ -204,6 +202,10 @@ func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{},
CreatedAt
:
cycleTemplates
[
i
]
.
CreatedAt
,
})
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
ctAdapter
,
nil
}
...
...
@@ -247,12 +249,8 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface
transactionContext
.
RollbackTransaction
()
}()
cycleRepository
:=
factory
.
CreateEvaluationCycleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
inMap
:=
tool_funs
.
SimpleStructToMap
(
in
)
if
len
(
in
.
Name
)
>
0
{
inMap
[
"name"
]
=
"%"
+
in
.
Name
+
"%"
}
// FIXME 总数量是否使用Count获取一个总数量
count
,
cycles
,
err
:=
cycleRepository
.
Find
(
inMap
)
count
,
cycles
,
err
:=
cycleRepository
.
Find
(
tool_funs
.
SimpleStructToMap
(
in
)
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
...
...
pkg/application/evaluation_project/command/project_query.go
查看文件 @
65cbc1d
...
...
@@ -17,3 +17,12 @@ func (in *QueryProjectCommand) Valid(validation *validation.Validation) {
return
}
}
type
StatisticCycleProjectUserCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
CycleId
int64
`cname:"周期ID" json:"cycleId,string"`
}
func
(
in
*
StatisticCycleProjectUserCommand
)
Valid
(
*
validation
.
Validation
)
{
}
...
...
pkg/application/evaluation_project/command/project_update.go
查看文件 @
65cbc1d
...
...
@@ -42,7 +42,7 @@ func (in *UpdateProjectCommand) Valid(validation *validation.Validation) {
func
(
in
*
UpdateProjectTemplateCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
if
len
(
in
.
Recipients
)
==
0
{
validation
.
SetError
(
"recipients"
,
"请
选择
被评估人"
)
validation
.
SetError
(
"recipients"
,
"请
添加
被评估人"
)
return
}
}
...
...
pkg/application/evaluation_project/project_service.go
查看文件 @
65cbc1d
...
...
@@ -7,7 +7,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
"strconv"
)
...
...
@@ -172,16 +171,14 @@ func (rs *EvaluationProjectService) UpdateTemplateNode(in *command.UpdateProject
}
func
(
rs
*
EvaluationProjectService
)
Get
(
in
*
command
.
GetProjectCommand
)
(
interface
{},
error
)
{
// Get 不需要事务
if
err
:=
utils
.
ValidateCommand
(
in
);
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
err
.
Error
())
}
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
transactionContext
,
err
:=
factory
.
ValidateStartTransaction
(
in
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
return
nil
,
err
}
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
project
,
err
:=
projectRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
Id
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
...
...
@@ -201,6 +198,9 @@ func (rs *EvaluationProjectService) Get(in *command.GetProjectCommand) (interfac
projectAdapter
.
TransformRecipientAdapter
(
users
)
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
projectAdapter
,
nil
}
...
...
@@ -317,3 +317,52 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf
}
return
project
,
nil
}
func
(
rs
*
EvaluationProjectService
)
StatisticCycleUser
(
in
*
command
.
StatisticCycleProjectUserCommand
)
(
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
ValidateStartTransaction
(
in
)
if
err
!=
nil
{
return
nil
,
err
}
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
_
,
projects
,
err
:=
projectRepository
.
Find
(
tool_funs
.
SimpleStructToMap
(
in
),
"linkNodes"
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
userIds
:=
make
([]
int64
,
0
)
userIdMap
:=
map
[
int64
]
int64
{}
for
i
:=
range
projects
{
project
:=
projects
[
i
]
for
j
:=
range
project
.
Recipients
{
userId
,
_
:=
strconv
.
ParseInt
(
project
.
Recipients
[
j
],
10
,
64
)
userIdMap
[
userId
]
=
userId
}
}
for
_
,
v
:=
range
userIdMap
{
userIds
=
append
(
userIds
,
v
)
}
userTotal
:=
0
departmentTotal
:=
0
if
len
(
userIds
)
>
0
{
userRepository
:=
factory
.
CreateUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
_
,
users
,
_
:=
userRepository
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
userIds
,
"limit"
:
len
(
userIds
)})
departmentIdMap
:=
map
[
int
]
int
{}
for
i
:=
range
users
{
user
:=
users
[
i
]
for
_
,
v
:=
range
user
.
DepartmentId
{
departmentIdMap
[
v
]
=
v
}
}
userTotal
=
len
(
users
)
departmentTotal
=
len
(
departmentIdMap
)
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
map
[
string
]
interface
{}{
"userTotal"
:
userTotal
,
"departmentTotal"
:
departmentTotal
},
nil
}
...
...
pkg/application/evaluation_rule/rule_service.go
查看文件 @
65cbc1d
...
...
@@ -7,7 +7,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_rule/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
)
type
EvaluationRuleService
struct
{
...
...
@@ -100,19 +99,22 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac
}
func
(
rs
*
EvaluationRuleService
)
Get
(
in
*
command
.
GetRuleCommand
)
(
interface
{},
error
)
{
// Get 不需要事务
if
err
:=
utils
.
ValidateCommand
(
in
);
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
err
.
Error
())
}
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
transactionContext
,
err
:=
factory
.
ValidateStartTransaction
(
in
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
return
nil
,
err
}
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
ruleRepository
:=
factory
.
CreateEvaluationRuleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
rule
,
err
:=
ruleRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
Id
})
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
rule
,
nil
}
...
...
pkg/application/evaluation_template/template_service.go
查看文件 @
65cbc1d
...
...
@@ -6,7 +6,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_template/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
)
type
EvaluationTemplateService
struct
{
...
...
@@ -124,19 +123,22 @@ func (rs *EvaluationTemplateService) Update(in *command.UpdateTemplateCommand) (
}
func
(
rs
*
EvaluationTemplateService
)
Get
(
in
*
command
.
GetTemplateCommand
)
(
interface
{},
error
)
{
// Get 不需要事务
if
err
:=
utils
.
ValidateCommand
(
in
);
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
err
.
Error
())
}
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
transactionContext
,
err
:=
factory
.
ValidateStartTransaction
(
in
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
return
nil
,
err
}
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
templateRepository
:=
factory
.
CreateEvaluationTemplateRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
template
,
err
:=
templateRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
Id
})
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
template
,
nil
}
...
...
pkg/port/beego/controllers/evaluation_project_controller.go
查看文件 @
65cbc1d
...
...
@@ -112,3 +112,14 @@ func (controller *ProjectController) CopyProject() {
controller
.
Response
(
ruService
.
Copy
(
in
))
}
}
func
(
controller
*
ProjectController
)
StatisticCycleUser
()
{
ruService
:=
service
.
NewEvaluationProjectService
()
in
:=
&
command
.
StatisticCycleProjectUserCommand
{}
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
.
StatisticCycleUser
(
in
))
}
}
...
...
请
注册
或
登录
后发表评论