切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
600b5dd78097811771a368e5b28dc65d4e506a8e
1 个父辈
7a776259
模板业务功能提交(增删改查、复制、状态变更)
显示空白字符变更
内嵌
并排对比
正在显示
9 个修改的文件
包含
98 行增加
和
47 行删除
pkg/application/evaluation_template/command/template_create.go
pkg/application/evaluation_template/command/template_option.go
pkg/application/evaluation_template/command/template_query.go
pkg/application/evaluation_template/command/template_update.go
pkg/application/evaluation_template/template_service.go
pkg/domain/evaluation_template.go
pkg/infrastructure/repository/pg_evaluation_template_repository.go
pkg/port/beego/controllers/evaluation_template_controller.go
pkg/port/beego/routers/evaluation_template_router.go
pkg/application/evaluation_template/command/template_create.go
查看文件 @
600b5dd
...
...
@@ -8,7 +8,7 @@ type CreateTemplateCommand struct {
CompanyId
int64
`cname:"公司ID" json:"companyId"`
CreatorId
int64
`cname:"创建人ID" json:"creatorId"`
Name
string
`cname:"模板名称" json:"name" valid:"Required"`
Describe
string
`cname:"模板描述" json:"
remark
"`
Describe
string
`cname:"模板描述" json:"
describe
"`
}
func
(
in
*
CreateTemplateCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
...
...
@@ -25,4 +25,9 @@ func (in *CreateTemplateCommand) Valid(validation *validation.Validation) {
validation
.
SetError
(
"name"
,
"模板名称最大长度40个字符"
)
return
}
if
len
(
in
.
Describe
)
>
100
{
validation
.
SetError
(
"describe"
,
"备注最大长度100个字符"
)
return
}
}
...
...
pkg/application/evaluation_template/command/template_option.go
查看文件 @
600b5dd
...
...
@@ -6,11 +6,14 @@ import (
)
type
StateTemplateCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Id
int64
`cname:"模板ID" json:"id,string" valid:"Required"`
State
int
`cname:"模板状态" json:"state"`
}
type
CopyTemplateCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
CreatorId
int64
`cname:"创建人ID" json:"creatorId"`
Id
int64
`cname:"模板ID" json:"id,string" valid:"Required"`
}
...
...
pkg/application/evaluation_template/command/template_query.go
查看文件 @
600b5dd
package
command
import
"github.com/beego/beego/v2/core/validation"
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
int
`cname:"分页页码" json:"pageNumber" valid:"Required"`
PageSize
int
`cname:"分页数量" json:"pageSize" valid:"Required"`
}
...
...
@@ -16,14 +21,14 @@ func (in *QueryTemplateCommand) Valid(validation *validation.Validation) {
}
}
// AllEnableTemplateCommand 查询所有已启用的模板
type
AllEnableTemplateCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
}
func
(
in
*
AllEnableTemplateCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
if
in
.
CompanyId
==
0
{
validation
.
SetError
(
"companyId"
,
"公司ID无效"
)
return
}
}
//// AllEnableTemplateCommand 查询所有已启用的模板
//type AllEnableTemplateCommand struct {
// CompanyId int64 `cname:"公司ID" json:"companyId"`
//}
//
//func (in *AllEnableTemplateCommand) Valid(validation *validation.Validation) {
// if in.CompanyId == 0 {
// validation.SetError("companyId", "公司ID无效")
// return
// }
//}
...
...
pkg/application/evaluation_template/command/template_update.go
查看文件 @
600b5dd
...
...
@@ -9,7 +9,7 @@ type UpdateTemplateCommand struct {
Id
int64
`cname:"模板ID" json:"id,string" valid:"Required"`
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Name
string
`cname:"模板名称" json:"name" valid:"Required"`
Describe
string
`cname:"模板描述" json:"
remark
"`
Describe
string
`cname:"模板描述" json:"
describe
"`
LinkNodes
[]
*
domain
.
LinkNode
`cname:"评估流程" json:"linkNodes"`
}
...
...
@@ -24,6 +24,11 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) {
return
}
if
len
(
in
.
Describe
)
>
100
{
validation
.
SetError
(
"describe"
,
"备注最大长度100个字符"
)
return
}
if
len
(
in
.
LinkNodes
)
==
0
{
validation
.
SetError
(
"linkNodes"
,
"评估模板流程不能为空"
)
return
...
...
pkg/application/evaluation_template/template_service.go
查看文件 @
600b5dd
...
...
@@ -188,29 +188,10 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
return
tool_funs
.
SimpleWrapGridMap
(
total
,
templates
),
nil
}
func
(
rs
*
EvaluationTemplateService
)
ListForEnable
(
in
*
command
.
AllEnableTemplateCommand
)
(
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
StartTransaction
()
if
err
!=
nil
{
return
nil
,
err
}
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
templateRepository
:=
factory
.
CreateEvaluationTemplateRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
count
,
templates
,
err
:=
templateRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
in
.
CompanyId
,
"state"
:
domain
.
TemplateStateEnable
,
"offset"
:
0
,
"limit"
:
9999999
,
},
"linkNodes"
)
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
(
count
,
templates
),
nil
return
tool_funs
.
SimpleWrapGridMap
(
total
,
templates
),
nil
}
func
(
rs
*
EvaluationTemplateService
)
State
(
in
*
command
.
StateTemplateCommand
)
(
interface
{},
error
)
{
...
...
@@ -255,10 +236,20 @@ func (rs *EvaluationTemplateService) Copy(in *command.CopyTemplateCommand) (inte
}
// ID重置
template
.
Id
=
0
template
.
Name
=
template
.
Name
+
" 副本"
template
.
CreatorId
=
in
.
CreatorId
// 如果拷贝已经启用的模板,默认先设置为待启用
if
template
.
State
==
domain
.
TemplateStateEnable
{
template
.
State
=
domain
.
TemplateStateWaitActive
}
// 流程环节ID重置
sid
,
_
:=
utils
.
NewSnowflakeId
()
for
i
:=
range
template
.
LinkNodes
{
template
.
LinkNodes
[
i
]
.
Id
=
sid
+
int64
(
i
+
1
)
}
template
,
err
=
templateRepository
.
Insert
(
template
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
...
...
pkg/domain/evaluation_template.go
查看文件 @
600b5dd
...
...
@@ -27,7 +27,11 @@ const (
const
(
KpiCycleDay
int
=
1
// 考核周期-日
KpiCycleWeek
int
=
2
// 考核周期-周
KpiCycleMonth
int
=
3
// 考核周期-月
KpiCycleOneMonth
int
=
3
// 考核周期-月
KpiCycleTwoMonth
int
=
4
// 考核周期-双月
KpiCycleThreeMonth
int
=
5
// 考核周期-季度
KpiCycleSixMonth
int
=
6
// 考核周期-半年
KpiCycleYear
int
=
7
// 考核周期-年
)
type
EntryItem
struct
{
...
...
@@ -39,17 +43,17 @@ type EntryItem struct {
type
NodeContent
struct
{
Category
string
`json:"category" comment:"类别"`
Name
string
`json:"name" comment:"名称"`
RuleId
int64
`json:"ruleId" comment:"评估规则ID"`
RuleId
string
`json:"ruleId" comment:"评估规则ID"`
PromptTitle
string
`json:"promptTitle" comment:"提示项标题"`
PromptText
string
`json:"promptText" comment:"提示项正文"`
EntryItems
[]
*
EntryItem
`json:"entryItems" comment:"填写项"`
}
// NodeAllInvite 360°邀请
type
NodeAllInvite
struct
{
ParentDifferentIds
[]
int64
`json:"parentDifferentIds" comment:"不同上级同事ID"`
ParentSameIds
[]
int64
`json:"parentSameIds" comment:"相同上级同事ID"`
}
//// NodeAllInvite 360°邀请
//type NodeAllInvite struct {
// ParentDifferentIds []string `json:"parentDifferentIds" comment:"不同上级同事ID"`
// ParentSameIds []string `json:"parentSameIds" comment:"相同上级同事ID"`
//}
//// NodeKpiResult 绩效结果查看
//type NodeKpiResult struct {
...
...
@@ -62,10 +66,11 @@ type LinkNode struct {
Name
string
`json:"name" comment:"环节名称"`
Describe
string
`json:"describe" comment:"环节描述"`
NodeContents
[]
*
NodeContent
`json:"nodeContents" comment:"环节-评估内容"`
NodeAllInvite
*
NodeAllInvite
`json:"nodeAllInvite" comment:"360°邀请人员"`
TimeStart
*
time
.
Time
`json:"timeStart" comment:"起始时间"`
TimeEnd
*
time
.
Time
`json:"timeEnd" comment:"截至时间"`
KpiCycle
int
`json:"state" comment:"考核周期(1日、2周、3月)"`
//NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"360°邀请人员"`
}
// 评估模板
...
...
pkg/infrastructure/repository/pg_evaluation_template_repository.go
查看文件 @
600b5dd
...
...
@@ -125,6 +125,10 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
query
.
Where
(
"id in(?)"
,
pg
.
In
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"notId"
];
ok
{
query
.
Where
(
"id != ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"name"
];
ok
&&
len
(
v
.
(
string
))
>
0
{
query
.
Where
(
"name LIKE ?"
,
v
)
}
...
...
@@ -133,10 +137,14 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
query
.
Where
(
"company_id = ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"state"
];
ok
{
if
v
,
ok
:=
queryOptions
[
"state"
];
ok
&&
v
.
(
int
)
>=
0
{
query
.
Where
(
"state = ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"createdAt"
];
ok
{
query
.
Where
(
"created_at = ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
}
...
...
pkg/port/beego/controllers/evaluation_template_controller.go
查看文件 @
600b5dd
...
...
@@ -5,6 +5,7 @@ import (
"github.com/linmadan/egglib-go/web/beego"
service
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_template"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_template/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)
...
...
@@ -59,6 +60,7 @@ func (controller *TemplateController) RemoveTemplate() {
func
(
controller
*
TemplateController
)
ListTemplate
()
{
ruService
:=
service
.
NewEvaluationTemplateService
()
in
:=
&
command
.
QueryTemplateCommand
{}
in
.
State
=
-
1
if
err
:=
controller
.
Unmarshal
(
in
);
err
!=
nil
{
controller
.
Response
(
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
err
.
Error
()))
}
else
{
...
...
@@ -72,12 +74,15 @@ func (controller *TemplateController) ListTemplate() {
func
(
controller
*
TemplateController
)
ListEnableTemplate
()
{
ruService
:=
service
.
NewEvaluationTemplateService
()
in
:=
&
command
.
AllEnableTemplateCommand
{}
in
:=
&
command
.
QueryTemplateCommand
{}
in
.
State
=
domain
.
TemplateStateEnable
in
.
PageNumber
=
1
in
.
PageSize
=
999999
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
.
List
ForEnable
(
in
))
controller
.
Response
(
ruService
.
List
(
in
))
}
}
...
...
@@ -87,6 +92,7 @@ func (controller *TemplateController) StateTemplate() {
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
.
State
(
in
))
}
}
...
...
@@ -97,6 +103,8 @@ func (controller *TemplateController) CopyTemplate() {
if
err
:=
controller
.
Unmarshal
(
in
);
err
!=
nil
{
controller
.
Response
(
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
err
.
Error
()))
}
else
{
in
.
CompanyId
=
middlewares
.
GetCompanyId
(
controller
.
Ctx
)
in
.
CreatorId
=
middlewares
.
GetUserId
(
controller
.
Ctx
)
controller
.
Response
(
ruService
.
Copy
(
in
))
}
}
...
...
pkg/port/beego/routers/evaluation_template_router.go
0 → 100644
查看文件 @
600b5dd
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/evaluation-template"
,
web
.
NSBefore
(
filters
.
AllowCors
(),
middlewares
.
CheckToken
()),
web
.
NSRouter
(
"/"
,
&
controllers
.
TemplateController
{},
"Post:CreateTemplate"
),
web
.
NSRouter
(
"/"
,
&
controllers
.
TemplateController
{},
"Put:UpdateTemplate"
),
web
.
NSRouter
(
"/"
,
&
controllers
.
TemplateController
{},
"Delete:RemoveTemplate"
),
web
.
NSRouter
(
"/:Id"
,
&
controllers
.
TemplateController
{},
"Get:GetTemplate"
),
web
.
NSRouter
(
"/list"
,
&
controllers
.
TemplateController
{},
"Post:ListTemplate"
),
web
.
NSRouter
(
"/list-enable"
,
&
controllers
.
TemplateController
{},
"Post:ListEnableTemplate"
),
)
web
.
AddNamespace
(
ns
)
}
...
...
请
注册
或
登录
后发表评论