作者 郑周

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

@@ -188,8 +188,14 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int @@ -188,8 +188,14 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int
188 defer func() { 188 defer func() {
189 transactionContext.RollbackTransaction() 189 transactionContext.RollbackTransaction()
190 }() 190 }()
  191 +
  192 + queryOptions := tool_funs.SimpleStructToMap(in)
  193 + if in.CreatedAt == nil {
  194 + delete(queryOptions, "createdAt") // 删除创建时间
  195 + }
  196 +
191 templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) 197 templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
192 - total, templates, err := templateRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") 198 + total, templates, err := templateRepository.Find(queryOptions, "link_nodes")
193 if err != nil { 199 if err != nil {
194 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 200 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
195 } 201 }
@@ -142,7 +142,12 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface @@ -142,7 +142,12 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
142 } 142 }
143 143
144 if v, ok := queryOptions["createdAt"]; ok { 144 if v, ok := queryOptions["createdAt"]; ok {
145 - query.Where("created_at = ?", v) 145 + t := v.(*time.Time)
  146 + year, month, day := t.Date()
  147 + begin := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
  148 + end := time.Date(year, month, day, 23, 59, 59, 0, time.Local)
  149 + query.Where("created_at >= ?", begin)
  150 + query.Where("created_at <= ?", end)
146 } 151 }
147 152
148 if v, ok := queryOptions["limit"].(int); ok { 153 if v, ok := queryOptions["limit"].(int); ok {
@@ -22,8 +22,6 @@ func (controller *TemplateController) CreateTemplate() { @@ -22,8 +22,6 @@ func (controller *TemplateController) CreateTemplate() {
22 ua := middlewares.GetUser(controller.Ctx) 22 ua := middlewares.GetUser(controller.Ctx)
23 in.CompanyId = ua.CompanyId 23 in.CompanyId = ua.CompanyId
24 in.CreatorId = ua.UserId 24 in.CreatorId = ua.UserId
25 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
26 - //in.CreatorId = middlewares.GetUserId(controller.Ctx)  
27 controller.Response(ruService.Create(in)) 25 controller.Response(ruService.Create(in))
28 } 26 }
29 } 27 }
@@ -36,7 +34,6 @@ func (controller *TemplateController) UpdateTemplate() { @@ -36,7 +34,6 @@ func (controller *TemplateController) UpdateTemplate() {
36 } else { 34 } else {
37 ua := middlewares.GetUser(controller.Ctx) 35 ua := middlewares.GetUser(controller.Ctx)
38 in.CompanyId = ua.CompanyId 36 in.CompanyId = ua.CompanyId
39 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
40 controller.Response(ruService.Update(in)) 37 controller.Response(ruService.Update(in))
41 } 38 }
42 } 39 }
@@ -74,7 +71,6 @@ func (controller *TemplateController) ListTemplate() { @@ -74,7 +71,6 @@ func (controller *TemplateController) ListTemplate() {
74 } 71 }
75 ua := middlewares.GetUser(controller.Ctx) 72 ua := middlewares.GetUser(controller.Ctx)
76 in.CompanyId = ua.CompanyId 73 in.CompanyId = ua.CompanyId
77 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
78 controller.Response(ruService.List(in)) 74 controller.Response(ruService.List(in))
79 } 75 }
80 } 76 }
@@ -90,7 +86,6 @@ func (controller *TemplateController) ListEnableTemplate() { @@ -90,7 +86,6 @@ func (controller *TemplateController) ListEnableTemplate() {
90 } else { 86 } else {
91 ua := middlewares.GetUser(controller.Ctx) 87 ua := middlewares.GetUser(controller.Ctx)
92 in.CompanyId = ua.CompanyId 88 in.CompanyId = ua.CompanyId
93 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
94 controller.Response(ruService.List(in)) 89 controller.Response(ruService.List(in))
95 } 90 }
96 } 91 }
@@ -103,7 +98,6 @@ func (controller *TemplateController) StateTemplate() { @@ -103,7 +98,6 @@ func (controller *TemplateController) StateTemplate() {
103 } else { 98 } else {
104 ua := middlewares.GetUser(controller.Ctx) 99 ua := middlewares.GetUser(controller.Ctx)
105 in.CompanyId = ua.CompanyId 100 in.CompanyId = ua.CompanyId
106 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
107 controller.Response(ruService.State(in)) 101 controller.Response(ruService.State(in))
108 } 102 }
109 } 103 }