作者 郑周

周期模板添加

... ... @@ -11,7 +11,7 @@ type CreateCycleCommand struct {
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"`
KpiCycle int `cname:"考核周期" json:"kpiCycle" valid:"Required"`
TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"`
}
... ...
... ... @@ -62,6 +62,9 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
ctAdapter := &adapter.CycleTemplateAdapter{}
ctAdapter.EvaluationCycle = cycle
for i := range templates {
v := templates[i]
cycleTemplate := &domain.EvaluationCycleTemplate{
... ... @@ -74,12 +77,18 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
if err != nil {
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,
})
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return cycle, nil
return ctAdapter, nil
}
... ... @@ -166,10 +175,26 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
_, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": cycle.Id}, "template")
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
ctAdapter := &adapter.CycleTemplateAdapter{}
ctAdapter.EvaluationCycle = cycle
for i := range cycleTemplates {
ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{
Id: cycleTemplates[i].Id,
Name: cycleTemplates[i].Name,
CreatedAt: cycleTemplates[i].CreatedAt,
})
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return cycle, nil
return ctAdapter, nil
}
func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) {
... ...
... ... @@ -4,6 +4,16 @@ import (
"time"
)
const (
KpiCycleDay int = 1 // 考核周期-日
KpiCycleWeek int = 2 // 考核周期-周
KpiCycleOneMonth int = 3 // 考核周期-月
KpiCycleTwoMonth int = 4 // 考核周期-双月
KpiCycleThreeMonth int = 5 // 考核周期-季度
KpiCycleSixMonth int = 6 // 考核周期-半年
KpiCycleYear int = 7 // 考核周期-年
)
type TemplateSimple struct {
Id int64 `json:"id,string" comment:"模板ID"`
Name string `json:"name" comment:"模板名称"`
... ... @@ -17,7 +27,7 @@ type EvaluationCycle struct {
TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"`
CompanyId int64 `json:"companyId,string" comment:"公司ID"`
CreatorId int64 `json:"creatorId,string" comment:"创建人ID"`
KpiCycle int `json:"state" comment:"考核周期(1日、2周、3月)"`
KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"`
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
... ...
... ... @@ -24,16 +24,6 @@ const (
)
const (
KpiCycleDay int = 1 // 考核周期-日
KpiCycleWeek int = 2 // 考核周期-周
KpiCycleOneMonth int = 3 // 考核周期-月
KpiCycleTwoMonth int = 4 // 考核周期-双月
KpiCycleThreeMonth int = 5 // 考核周期-季度
KpiCycleSixMonth int = 6 // 考核周期-半年
KpiCycleYear int = 7 // 考核周期-年
)
type EntryItem struct {
Title string `json:"title" comment:"填写标题"`
HintText string `json:"hintText" comment:"文本内容提示"`
... ...
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-cycle",
web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()),
web.NSRouter("/", &controllers.CycleController{}, "Post:CreateCycle"),
web.NSRouter("/", &controllers.CycleController{}, "Put:UpdateCycle"),
web.NSRouter("/", &controllers.CycleController{}, "Delete:RemoveCycle"),
web.NSRouter("/:Id", &controllers.CycleController{}, "Get:GetCycle"),
web.NSRouter("/list", &controllers.CycleController{}, "Post:ListRuleRelCreator"),
)
web.AddNamespace(ns)
}
... ...