作者 郑周

模板 增删改查 接口调试完成

... ... @@ -188,8 +188,14 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int
defer func() {
transactionContext.RollbackTransaction()
}()
queryOptions := tool_funs.SimpleStructToMap(in)
if in.CreatedAt == nil {
delete(queryOptions, "createdAt") // 删除创建时间
}
templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
total, templates, err := templateRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes")
total, templates, err := templateRepository.Find(queryOptions, "link_nodes")
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -142,7 +142,12 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
}
if v, ok := queryOptions["createdAt"]; ok {
query.Where("created_at = ?", v)
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)
}
if v, ok := queryOptions["limit"].(int); ok {
... ...
... ... @@ -22,8 +22,6 @@ func (controller *TemplateController) CreateTemplate() {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
in.CreatorId = ua.UserId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
//in.CreatorId = middlewares.GetUserId(controller.Ctx)
controller.Response(ruService.Create(in))
}
}
... ... @@ -36,7 +34,6 @@ func (controller *TemplateController) UpdateTemplate() {
} else {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller.Response(ruService.Update(in))
}
}
... ... @@ -74,7 +71,6 @@ func (controller *TemplateController) ListTemplate() {
}
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller.Response(ruService.List(in))
}
}
... ... @@ -90,7 +86,6 @@ func (controller *TemplateController) ListEnableTemplate() {
} else {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller.Response(ruService.List(in))
}
}
... ... @@ -103,7 +98,6 @@ func (controller *TemplateController) StateTemplate() {
} else {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller.Response(ruService.State(in))
}
}
... ...