作者 郑周

1增加周期下的模板列表

2增加周期下的模板详情
... ... @@ -9,6 +9,20 @@ type QueryCycleCommand struct {
PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"`
}
type StatisticCycleProjectUserCommand struct {
CompanyId int64 `cname:"公司ID" json:"companyId"`
CycleId int64 `cname:"周期ID" json:"cycleId,string"`
}
type CycleTemplateListCommand struct {
CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
}
type CycleTemplateCommand struct {
CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
TemplateId int64 `cname:"模板ID" json:"templateId,string" valid:"Required"`
}
func (in *QueryCycleCommand) Valid(validation *validation.Validation) {
if in.CompanyId == 0 {
validation.SetError("companyId", "公司ID无效")
... ... @@ -16,17 +30,12 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) {
}
}
type StatisticCycleProjectUserCommand struct {
CompanyId int64 `cname:"公司ID" json:"companyId"`
CycleId int64 `cname:"周期ID" json:"cycleId,string"`
}
func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) {
}
type CycleTemplateCommand struct {
CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
func (in *CycleTemplateListCommand) Valid(*validation.Validation) {
}
func (in *CycleTemplateCommand) Valid(*validation.Validation) {
... ...
... ... @@ -364,7 +364,7 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP
return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil
}
func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateCommand) (interface{}, error) {
func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateListCommand) (interface{}, error) {
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
... ... @@ -375,6 +375,9 @@ func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateCom
cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
_, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": in.CycleId}, "template")
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
list := make([]*domain.TemplateSimple, 0)
for i := range cycleTemplates {
... ... @@ -390,3 +393,23 @@ func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateCom
}
return map[string]interface{}{"list": list}, nil
}
func (rs *EvaluationCycleService) CycleTemplate(in *command.CycleTemplateCommand) (interface{}, error) {
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId})
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 cycleTemplate.Template, nil
}
... ...
... ... @@ -90,10 +90,20 @@ func (controller *CycleController) StatisticCycleUser() {
func (controller *CycleController) CycleTemplateList() {
ruService := service.NewEvaluationCycleService()
in := &command.CycleTemplateCommand{}
in := &command.CycleTemplateListCommand{}
if err := controller.Unmarshal(in); err != nil {
controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
} else {
controller.Response(ruService.CycleTemplateList(in))
}
}
func (controller *CycleController) CycleTemplate() {
ruService := service.NewEvaluationCycleService()
in := &command.CycleTemplateCommand{}
if err := controller.Unmarshal(in); err != nil {
controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
} else {
controller.Response(ruService.CycleTemplate(in))
}
}
... ...