切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
4f0788397de380f7fba1546f86f6999e01e83c23
1 个父辈
93b39154
格式格式化
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
57 行增加
和
38 行删除
pkg/application/evaluation_cycle/command/cycle_create.go
pkg/application/evaluation_cycle/command/cycle_update.go
pkg/application/evaluation_cycle/cycle_service.go
pkg/application/evaluation_template/command/template_query.go
pkg/application/evaluation_template/template_service.go
pkg/infrastructure/repository/pg_evaluation_template_repository.go
pkg/application/evaluation_cycle/command/cycle_create.go
查看文件 @
4f07883
...
...
@@ -2,17 +2,16 @@ package command
import
(
"github.com/beego/beego/v2/core/validation"
"time"
)
type
CreateCycleCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
CreatorId
int64
`cname:"创建人ID" json:"creatorId"`
Name
string
`cname:"周期名称" json:"name" valid:"Required"`
TimeStart
*
time
.
Time
`cname:"起始时间" json:"timeStart"`
TimeEnd
*
time
.
Time
`cname:"截至时间" json:"timeEnd"`
KpiCycle
int
`cname:"考核周期" json:"kpiCycle" valid:"Required"`
TemplateIds
[]
string
`cname:"周期使用模板ID" json:"templateIds"`
CompanyId
int64
`cname:"公司ID" json:"companyId"`
CreatorId
int64
`cname:"创建人ID" json:"creatorId"`
Name
string
`cname:"周期名称" json:"name" valid:"Required"`
TimeStart
string
`cname:"起始时间" json:"timeStart"`
TimeEnd
string
`cname:"截至时间" json:"timeEnd"`
KpiCycle
int
`cname:"考核周期" json:"kpiCycle" valid:"Required"`
TemplateIds
[]
string
`cname:"周期使用模板ID" json:"templateIds"`
}
func
(
in
*
CreateCycleCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
...
...
@@ -33,11 +32,11 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) {
return
}
if
in
.
TimeStart
==
nil
{
if
len
(
in
.
TimeStart
)
==
0
{
validation
.
SetError
(
"timeStart"
,
"请选择考核周期的开始时间"
)
return
}
if
in
.
TimeEnd
==
nil
{
if
len
(
in
.
TimeEnd
)
==
0
{
validation
.
SetError
(
"timeEnd"
,
"请选择考核周期的结束时间"
)
return
}
...
...
pkg/application/evaluation_cycle/command/cycle_update.go
查看文件 @
4f07883
...
...
@@ -2,17 +2,16 @@ package command
import
(
"github.com/beego/beego/v2/core/validation"
"time"
)
type
UpdateCycleCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Id
int64
`cname:"周期ID" json:"id,string" valid:"Required"`
Name
string
`cname:"周期名称" json:"name" valid:"Required"`
TimeStart
*
time
.
Time
`cname:"起始时间" json:"timeStart"`
TimeEnd
*
time
.
Time
`cname:"截至时间" json:"timeEnd"`
KpiCycle
int
`cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"`
TemplateIds
[]
string
`cname:"周期使用模板ID" json:"templateIds"`
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Id
int64
`cname:"周期ID" json:"id,string" valid:"Required"`
Name
string
`cname:"周期名称" json:"name" valid:"Required"`
TimeStart
string
`cname:"起始时间" json:"timeStart"`
TimeEnd
string
`cname:"截至时间" json:"timeEnd"`
KpiCycle
int
`cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"`
TemplateIds
[]
string
`cname:"周期使用模板ID" json:"templateIds"`
}
func
(
in
*
UpdateCycleCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
...
...
@@ -20,11 +19,11 @@ func (in *UpdateCycleCommand) Valid(validation *validation.Validation) {
validation
.
SetError
(
"name"
,
"角色名称最大长度40个字符"
)
return
}
if
in
.
TimeStart
==
nil
{
if
len
(
in
.
TimeStart
)
==
0
{
validation
.
SetError
(
"timeStart"
,
"请选择考核周期的开始时间"
)
return
}
if
in
.
TimeEnd
==
nil
{
if
len
(
in
.
TimeEnd
)
==
0
{
validation
.
SetError
(
"timeEnd"
,
"请选择考核周期的结束时间"
)
return
}
...
...
pkg/application/evaluation_cycle/cycle_service.go
查看文件 @
4f07883
...
...
@@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"strconv"
"time"
)
type
EvaluationCycleService
struct
{
...
...
@@ -49,12 +50,21 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"模板不存在, 请重新选择"
)
}
start
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeStart
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
end
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeEnd
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 生成新周期数据
newCycle
:=
&
domain
.
EvaluationCycle
{
Id
:
0
,
Name
:
in
.
Name
,
TimeStart
:
in
.
TimeStart
,
TimeEnd
:
in
.
TimeEnd
,
TimeStart
:
&
start
,
TimeEnd
:
&
end
,
CompanyId
:
in
.
CompanyId
,
CreatorId
:
in
.
CreatorId
,
KpiCycle
:
in
.
KpiCycle
,
...
...
@@ -210,9 +220,18 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf
}
}
start
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeStart
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
end
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeEnd
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
cycle
.
Name
=
in
.
Name
cycle
.
TimeStart
=
in
.
TimeStart
cycle
.
TimeEnd
=
in
.
TimeEnd
cycle
.
TimeStart
=
&
start
cycle
.
TimeEnd
=
&
end
cycle
.
KpiCycle
=
in
.
KpiCycle
cycle
,
err
=
cycleRepository
.
Insert
(
cycle
)
if
err
!=
nil
{
...
...
pkg/application/evaluation_template/command/template_query.go
查看文件 @
4f07883
...
...
@@ -2,16 +2,15 @@ package command
import
(
"github.com/beego/beego/v2/core/validation"
"time"
)
type
QueryTemplateCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Name
string
`cname:"模板名称" json:"name"`
State
int
`cname:"模板状态" json:"state"`
CreatedAt
*
time
.
Time
`cname:"创建时间" json:"createdAt"`
PageNumber
int64
`cname:"分页页码" json:"pageNumber" valid:"Required"`
PageSize
int64
`cname:"分页数量" json:"pageSize" valid:"Required"`
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Name
string
`cname:"模板名称" json:"name"`
State
int
`cname:"模板状态" json:"state"`
CreatedAt
string
`cname:"创建时间" json:"createdAt"`
PageNumber
int64
`cname:"分页页码" json:"pageNumber" valid:"Required"`
PageSize
int64
`cname:"分页数量" json:"pageSize" valid:"Required"`
}
func
(
in
*
QueryTemplateCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
...
...
pkg/application/evaluation_template/template_service.go
查看文件 @
4f07883
...
...
@@ -190,7 +190,7 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int
}()
queryOptions
:=
tool_funs
.
SimpleStructToMap
(
in
)
if
in
.
CreatedAt
==
nil
{
if
len
(
in
.
CreatedAt
)
==
0
{
delete
(
queryOptions
,
"createdAt"
)
// 删除创建时间
}
...
...
pkg/infrastructure/repository/pg_evaluation_template_repository.go
查看文件 @
4f07883
...
...
@@ -142,12 +142,15 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
}
if
v
,
ok
:=
queryOptions
[
"createdAt"
];
ok
{
t
:=
v
.
(
*
time
.
Time
)
year
,
month
,
day
:=
t
.
Date
()
begin
:=
time
.
Date
(
year
,
month
,
day
,
0
,
0
,
0
,
0
,
time
.
Local
)
end
:=
time
.
Date
(
year
,
month
,
day
,
23
,
59
,
59
,
0
,
time
.
Local
)
query
.
Where
(
"created_at >= ?"
,
begin
)
query
.
Where
(
"created_at <= ?"
,
end
)
ts
:=
v
.
(
string
)
t
,
err
:=
time
.
ParseInLocation
(
"2006-01-02"
,
ts
,
time
.
Local
)
if
err
==
nil
{
year
,
month
,
day
:=
t
.
Date
()
begin
:=
time
.
Date
(
year
,
month
,
day
,
0
,
0
,
0
,
0
,
time
.
Local
)
end
:=
time
.
Date
(
year
,
month
,
day
,
23
,
59
,
59
,
0
,
time
.
Local
)
query
.
Where
(
"created_at >= ?"
,
begin
)
query
.
Where
(
"created_at <= ?"
,
end
)
}
}
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int64
);
ok
{
...
...
请
注册
或
登录
后发表评论