Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/performance into test
正在显示
15 个修改的文件
包含
111 行增加
和
70 行删除
@@ -2,17 +2,16 @@ package command | @@ -2,17 +2,16 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type CreateCycleCommand struct { | 7 | type CreateCycleCommand struct { |
9 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
10 | - CreatorId int64 `cname:"创建人ID" json:"creatorId"` | ||
11 | - Name string `cname:"周期名称" json:"name" valid:"Required"` | ||
12 | - TimeStart *time.Time `cname:"起始时间" json:"timeStart"` | ||
13 | - TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` | ||
14 | - KpiCycle int `cname:"考核周期" json:"kpiCycle" valid:"Required"` | ||
15 | - TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | 8 | + CompanyId int64 `cname:"公司ID" json:"companyId"` |
9 | + CreatorId int64 `cname:"创建人ID" json:"creatorId"` | ||
10 | + Name string `cname:"周期名称" json:"name" valid:"Required"` | ||
11 | + TimeStart string `cname:"起始时间" json:"timeStart"` | ||
12 | + TimeEnd string `cname:"截至时间" json:"timeEnd"` | ||
13 | + KpiCycle int `cname:"考核周期" json:"kpiCycle" valid:"Required"` | ||
14 | + TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | ||
16 | } | 15 | } |
17 | 16 | ||
18 | func (in *CreateCycleCommand) Valid(validation *validation.Validation) { | 17 | func (in *CreateCycleCommand) Valid(validation *validation.Validation) { |
@@ -33,11 +32,11 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) { | @@ -33,11 +32,11 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) { | ||
33 | return | 32 | return |
34 | } | 33 | } |
35 | 34 | ||
36 | - if in.TimeStart == nil { | 35 | + if len(in.TimeStart) == 0 { |
37 | validation.SetError("timeStart", "请选择考核周期的开始时间") | 36 | validation.SetError("timeStart", "请选择考核周期的开始时间") |
38 | return | 37 | return |
39 | } | 38 | } |
40 | - if in.TimeEnd == nil { | 39 | + if len(in.TimeEnd) == 0 { |
41 | validation.SetError("timeEnd", "请选择考核周期的结束时间") | 40 | validation.SetError("timeEnd", "请选择考核周期的结束时间") |
42 | return | 41 | return |
43 | } | 42 | } |
@@ -2,17 +2,16 @@ package command | @@ -2,17 +2,16 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type UpdateCycleCommand struct { | 7 | type UpdateCycleCommand struct { |
9 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
10 | - Id int64 `cname:"周期ID" json:"id,string" valid:"Required"` | ||
11 | - Name string `cname:"周期名称" json:"name" valid:"Required"` | ||
12 | - TimeStart *time.Time `cname:"起始时间" json:"timeStart"` | ||
13 | - TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` | ||
14 | - KpiCycle int `cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"` | ||
15 | - TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | 8 | + CompanyId int64 `cname:"公司ID" json:"companyId"` |
9 | + Id int64 `cname:"周期ID" json:"id,string" valid:"Required"` | ||
10 | + Name string `cname:"周期名称" json:"name" valid:"Required"` | ||
11 | + TimeStart string `cname:"起始时间" json:"timeStart"` | ||
12 | + TimeEnd string `cname:"截至时间" json:"timeEnd"` | ||
13 | + KpiCycle int `cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"` | ||
14 | + TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | ||
16 | } | 15 | } |
17 | 16 | ||
18 | func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { | 17 | func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { |
@@ -20,11 +19,11 @@ func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { | @@ -20,11 +19,11 @@ func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { | ||
20 | validation.SetError("name", "角色名称最大长度40个字符") | 19 | validation.SetError("name", "角色名称最大长度40个字符") |
21 | return | 20 | return |
22 | } | 21 | } |
23 | - if in.TimeStart == nil { | 22 | + if len(in.TimeStart) == 0 { |
24 | validation.SetError("timeStart", "请选择考核周期的开始时间") | 23 | validation.SetError("timeStart", "请选择考核周期的开始时间") |
25 | return | 24 | return |
26 | } | 25 | } |
27 | - if in.TimeEnd == nil { | 26 | + if len(in.TimeEnd) == 0 { |
28 | validation.SetError("timeEnd", "请选择考核周期的结束时间") | 27 | validation.SetError("timeEnd", "请选择考核周期的结束时间") |
29 | return | 28 | return |
30 | } | 29 | } |
@@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
10 | "strconv" | 10 | "strconv" |
11 | + "time" | ||
11 | ) | 12 | ) |
12 | 13 | ||
13 | type EvaluationCycleService struct { | 14 | type EvaluationCycleService struct { |
@@ -49,12 +50,21 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -49,12 +50,21 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
49 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择") | 50 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择") |
50 | } | 51 | } |
51 | 52 | ||
53 | + start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local) | ||
54 | + if err != nil { | ||
55 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
56 | + } | ||
57 | + end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local) | ||
58 | + if err != nil { | ||
59 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
60 | + } | ||
61 | + | ||
52 | // 生成新周期数据 | 62 | // 生成新周期数据 |
53 | newCycle := &domain.EvaluationCycle{ | 63 | newCycle := &domain.EvaluationCycle{ |
54 | Id: 0, | 64 | Id: 0, |
55 | Name: in.Name, | 65 | Name: in.Name, |
56 | - TimeStart: in.TimeStart, | ||
57 | - TimeEnd: in.TimeEnd, | 66 | + TimeStart: &start, |
67 | + TimeEnd: &end, | ||
58 | CompanyId: in.CompanyId, | 68 | CompanyId: in.CompanyId, |
59 | CreatorId: in.CreatorId, | 69 | CreatorId: in.CreatorId, |
60 | KpiCycle: in.KpiCycle, | 70 | KpiCycle: in.KpiCycle, |
@@ -210,9 +220,18 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -210,9 +220,18 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
210 | } | 220 | } |
211 | } | 221 | } |
212 | 222 | ||
223 | + start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local) | ||
224 | + if err != nil { | ||
225 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
226 | + } | ||
227 | + end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local) | ||
228 | + if err != nil { | ||
229 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
230 | + } | ||
231 | + | ||
213 | cycle.Name = in.Name | 232 | cycle.Name = in.Name |
214 | - cycle.TimeStart = in.TimeStart | ||
215 | - cycle.TimeEnd = in.TimeEnd | 233 | + cycle.TimeStart = &start |
234 | + cycle.TimeEnd = &end | ||
216 | cycle.KpiCycle = in.KpiCycle | 235 | cycle.KpiCycle = in.KpiCycle |
217 | cycle, err = cycleRepository.Insert(cycle) | 236 | cycle, err = cycleRepository.Insert(cycle) |
218 | if err != nil { | 237 | if err != nil { |
@@ -2,7 +2,6 @@ package command | @@ -2,7 +2,6 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type UpdateProjectCommand struct { | 7 | type UpdateProjectCommand struct { |
@@ -17,16 +16,16 @@ type UpdateProjectCommand struct { | @@ -17,16 +16,16 @@ type UpdateProjectCommand struct { | ||
17 | } | 16 | } |
18 | 17 | ||
19 | type UpdateProjectTemplateCommand struct { | 18 | type UpdateProjectTemplateCommand struct { |
20 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
21 | - CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
22 | - Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | ||
23 | - TemplateId int64 `cname:"模板ID" json:"templateId,string"` | ||
24 | - Recipients []string `cname:"被评估人ID" json:"recipients"` | ||
25 | - TimeStart *time.Time `cname:"自评起始时间" json:"timeStart" valid:"Required"` | ||
26 | - TimeEnd *time.Time `cname:"自评截止时间" json:"timeEnd" valid:"Required"` | ||
27 | - KpiCycle int `cname:"评估周期" json:"kpiCycle" valid:"Required"` | ||
28 | - KpiResultStart *time.Time `cname:"绩效结果开始查看时间" json:"kpiResultStart"` | ||
29 | - Activate int `cname:"启动项目" json:"activate"` | 19 | + CompanyId int64 `cname:"公司ID" json:"companyId"` |
20 | + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
21 | + Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | ||
22 | + TemplateId int64 `cname:"模板ID" json:"templateId,string"` | ||
23 | + Recipients []string `cname:"被评估人ID" json:"recipients"` | ||
24 | + TimeStart string `cname:"自评起始时间" json:"timeStart" valid:"Required"` | ||
25 | + TimeEnd string `cname:"自评截止时间" json:"timeEnd" valid:"Required"` | ||
26 | + KpiCycle int `cname:"评估周期" json:"kpiCycle" valid:"Required"` | ||
27 | + KpiResultStart string `cname:"绩效结果开始查看时间" json:"kpiResultStart"` | ||
28 | + Activate int `cname:"启动项目" json:"activate"` | ||
30 | } | 29 | } |
31 | 30 | ||
32 | type CheckRecipientCommand struct { | 31 | type CheckRecipientCommand struct { |
@@ -48,4 +47,13 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) | @@ -48,4 +47,13 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) | ||
48 | validation.SetError("recipients", "请添加被评估人") | 47 | validation.SetError("recipients", "请添加被评估人") |
49 | return | 48 | return |
50 | } | 49 | } |
50 | + if len(in.TimeStart) == 0 { | ||
51 | + validation.SetError("timeEnd", "请选择开始时间") | ||
52 | + return | ||
53 | + } | ||
54 | + if len(in.TimeEnd) == 0 { | ||
55 | + validation.SetError("timeEnd", "请选择结束时间") | ||
56 | + return | ||
57 | + } | ||
58 | + | ||
51 | } | 59 | } |
@@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
11 | "strconv" | 11 | "strconv" |
12 | + "time" | ||
12 | ) | 13 | ) |
13 | 14 | ||
14 | type EvaluationProjectService struct { | 15 | type EvaluationProjectService struct { |
@@ -177,18 +178,31 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -177,18 +178,31 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
177 | project.State = domain.ProjectStateEnable | 178 | project.State = domain.ProjectStateEnable |
178 | } | 179 | } |
179 | 180 | ||
181 | + start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local) | ||
182 | + if err != nil { | ||
183 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
184 | + } | ||
185 | + end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local) | ||
186 | + if err != nil { | ||
187 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
188 | + } | ||
189 | + kpiStart, err := time.ParseInLocation("2006-01-02 15:04:05", in.KpiResultStart, time.Local) | ||
190 | + if err != nil { | ||
191 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
192 | + } | ||
193 | + | ||
180 | project.Recipients = in.Recipients | 194 | project.Recipients = in.Recipients |
181 | project.Template = cycleTemplate.Template | 195 | project.Template = cycleTemplate.Template |
182 | for i := range project.Template.LinkNodes { | 196 | for i := range project.Template.LinkNodes { |
183 | node := project.Template.LinkNodes[i] | 197 | node := project.Template.LinkNodes[i] |
184 | node.KpiCycle = in.KpiCycle // 设置周期 | 198 | node.KpiCycle = in.KpiCycle // 设置周期 |
185 | if node.Type == domain.LinkNodeViewResult { | 199 | if node.Type == domain.LinkNodeViewResult { |
186 | - if in.KpiResultStart != nil { | ||
187 | - node.TimeStart = in.KpiResultStart | 200 | + if len(in.KpiResultStart) > 0 { |
201 | + node.TimeStart = &kpiStart | ||
188 | } | 202 | } |
189 | } else { | 203 | } else { |
190 | - node.TimeStart = in.TimeStart | ||
191 | - node.TimeEnd = in.TimeEnd | 204 | + node.TimeStart = &start |
205 | + node.TimeEnd = &end | ||
192 | } | 206 | } |
193 | } | 207 | } |
194 | 208 | ||
@@ -404,5 +418,5 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | @@ -404,5 +418,5 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | ||
404 | if err := transactionContext.CommitTransaction(); err != nil { | 418 | if err := transactionContext.CommitTransaction(); err != nil { |
405 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 419 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
406 | } | 420 | } |
407 | - return repeatNum, nil | 421 | + return map[string]interface{}{"repeatNum": repeatNum}, nil |
408 | } | 422 | } |
@@ -2,16 +2,15 @@ package command | @@ -2,16 +2,15 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type QueryTemplateCommand struct { | 7 | type QueryTemplateCommand struct { |
9 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
10 | - Name string `cname:"模板名称" json:"name"` | ||
11 | - State int `cname:"模板状态" json:"state"` | ||
12 | - CreatedAt *time.Time `cname:"创建时间" json:"createdAt"` | ||
13 | - PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
14 | - PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | 8 | + CompanyId int64 `cname:"公司ID" json:"companyId"` |
9 | + Name string `cname:"模板名称" json:"name"` | ||
10 | + State int `cname:"模板状态" json:"state"` | ||
11 | + CreatedAt string `cname:"创建时间" json:"createdAt"` | ||
12 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
13 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
15 | } | 14 | } |
16 | 15 | ||
17 | func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { | 16 | func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { |
@@ -190,7 +190,7 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int | @@ -190,7 +190,7 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int | ||
190 | }() | 190 | }() |
191 | 191 | ||
192 | queryOptions := tool_funs.SimpleStructToMap(in) | 192 | queryOptions := tool_funs.SimpleStructToMap(in) |
193 | - if in.CreatedAt == nil { | 193 | + if len(in.CreatedAt) == 0 { |
194 | delete(queryOptions, "createdAt") // 删除创建时间 | 194 | delete(queryOptions, "createdAt") // 删除创建时间 |
195 | } | 195 | } |
196 | 196 |
@@ -119,7 +119,7 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | @@ -119,7 +119,7 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | ||
119 | 119 | ||
120 | query := tx.Model(&m).Where("deleted_at isnull") | 120 | query := tx.Model(&m).Where("deleted_at isnull") |
121 | 121 | ||
122 | - if v, ok := queryOptions["name"]; ok && len(v.(string)) > 0 { | 122 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
123 | query.Where("name LIKE ?", v) | 123 | query.Where("name LIKE ?", v) |
124 | } | 124 | } |
125 | 125 | ||
@@ -170,7 +170,7 @@ func (repo *EvaluationCycleRepository) Count(queryOptions map[string]interface{} | @@ -170,7 +170,7 @@ func (repo *EvaluationCycleRepository) Count(queryOptions map[string]interface{} | ||
170 | query.Where("id != ?", notId) | 170 | query.Where("id != ?", notId) |
171 | } | 171 | } |
172 | 172 | ||
173 | - if v, ok := queryOptions["name"]; ok { | 173 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
174 | query.Where("name = ?", v) | 174 | query.Where("name = ?", v) |
175 | } | 175 | } |
176 | 176 |
@@ -186,7 +186,7 @@ func (repo *EvaluationCycleTemplateRepository) Count(queryOptions map[string]int | @@ -186,7 +186,7 @@ func (repo *EvaluationCycleTemplateRepository) Count(queryOptions map[string]int | ||
186 | query.Where("id != ?", v) | 186 | query.Where("id != ?", v) |
187 | } | 187 | } |
188 | 188 | ||
189 | - if v, ok := queryOptions["name"]; ok { | 189 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
190 | query.Where("name = ?", v) | 190 | query.Where("name = ?", v) |
191 | } | 191 | } |
192 | 192 |
@@ -131,7 +131,7 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | @@ -131,7 +131,7 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | ||
131 | query.ExcludeColumn(excludeColumns...) | 131 | query.ExcludeColumn(excludeColumns...) |
132 | } | 132 | } |
133 | 133 | ||
134 | - if v, ok := queryOptions["name"]; ok { | 134 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
135 | query.Where("name = ?", v) | 135 | query.Where("name = ?", v) |
136 | } | 136 | } |
137 | 137 | ||
@@ -192,7 +192,7 @@ func (repo *EvaluationProjectRepository) Count(queryOptions map[string]interface | @@ -192,7 +192,7 @@ func (repo *EvaluationProjectRepository) Count(queryOptions map[string]interface | ||
192 | query.Where("id != ?", v) | 192 | query.Where("id != ?", v) |
193 | } | 193 | } |
194 | 194 | ||
195 | - if v, ok := queryOptions["name"]; ok { | 195 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
196 | query.Where("name = ?", v) | 196 | query.Where("name = ?", v) |
197 | } | 197 | } |
198 | 198 |
@@ -127,7 +127,7 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | @@ -127,7 +127,7 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | ||
127 | query.Where("id in(?)", pg.In(v)) | 127 | query.Where("id in(?)", pg.In(v)) |
128 | } | 128 | } |
129 | 129 | ||
130 | - if v, ok := queryOptions["name"]; ok { | 130 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
131 | query.Where("name = ?", v) | 131 | query.Where("name = ?", v) |
132 | } | 132 | } |
133 | 133 | ||
@@ -176,7 +176,7 @@ func (repo *EvaluationRuleRepository) Count(queryOptions map[string]interface{}) | @@ -176,7 +176,7 @@ func (repo *EvaluationRuleRepository) Count(queryOptions map[string]interface{}) | ||
176 | query.Where("id != ?", v) | 176 | query.Where("id != ?", v) |
177 | } | 177 | } |
178 | 178 | ||
179 | - if v, ok := queryOptions["name"]; ok { | 179 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
180 | query.Where("name = ?", v) | 180 | query.Where("name = ?", v) |
181 | } | 181 | } |
182 | 182 |
@@ -129,7 +129,7 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | @@ -129,7 +129,7 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | ||
129 | query.Where("id != ?", v) | 129 | query.Where("id != ?", v) |
130 | } | 130 | } |
131 | 131 | ||
132 | - if v, ok := queryOptions["name"]; ok && len(v.(string)) > 0 { | 132 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
133 | query.Where("name LIKE ?", v) | 133 | query.Where("name LIKE ?", v) |
134 | } | 134 | } |
135 | 135 | ||
@@ -142,12 +142,15 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | @@ -142,12 +142,15 @@ 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 | - 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) | 145 | + ts := v.(string) |
146 | + t, err := time.ParseInLocation("2006-01-02", ts, time.Local) | ||
147 | + if err == nil { | ||
148 | + year, month, day := t.Date() | ||
149 | + begin := time.Date(year, month, day, 0, 0, 0, 0, time.Local) | ||
150 | + end := time.Date(year, month, day, 23, 59, 59, 0, time.Local) | ||
151 | + query.Where("created_at >= ?", begin) | ||
152 | + query.Where("created_at <= ?", end) | ||
153 | + } | ||
151 | } | 154 | } |
152 | 155 | ||
153 | if v, ok := queryOptions["limit"].(int64); ok { | 156 | if v, ok := queryOptions["limit"].(int64); ok { |
@@ -183,7 +186,7 @@ func (repo *EvaluationTemplateRepository) Count(queryOptions map[string]interfac | @@ -183,7 +186,7 @@ func (repo *EvaluationTemplateRepository) Count(queryOptions map[string]interfac | ||
183 | query.Where("id != ?", v) | 186 | query.Where("id != ?", v) |
184 | } | 187 | } |
185 | 188 | ||
186 | - if v, ok := queryOptions["name"]; ok { | 189 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
187 | query.Where("name = ?", v) | 190 | query.Where("name = ?", v) |
188 | } | 191 | } |
189 | 192 |
@@ -113,8 +113,8 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, [] | @@ -113,8 +113,8 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, [] | ||
113 | var m []*models.Role | 113 | var m []*models.Role |
114 | query := tx.Model(&m).Where("deleted_at isnull") | 114 | query := tx.Model(&m).Where("deleted_at isnull") |
115 | 115 | ||
116 | - if name, ok := queryOptions["name"]; ok { | ||
117 | - query.Where("name = ?", name) | 116 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
117 | + query.Where("name = ?", v) | ||
118 | } | 118 | } |
119 | 119 | ||
120 | if companyId, ok := queryOptions["companyId"]; ok { | 120 | if companyId, ok := queryOptions["companyId"]; ok { |
@@ -154,8 +154,8 @@ func (repo *RoleRepository) Count(queryOptions map[string]interface{}) (int64, e | @@ -154,8 +154,8 @@ func (repo *RoleRepository) Count(queryOptions map[string]interface{}) (int64, e | ||
154 | query.Where("id != ?", notId) | 154 | query.Where("id != ?", notId) |
155 | } | 155 | } |
156 | 156 | ||
157 | - if name, ok := queryOptions["name"]; ok { | ||
158 | - query.Where("name = ?", name) | 157 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
158 | + query.Where("name = ?", v) | ||
159 | } | 159 | } |
160 | 160 | ||
161 | if companyId, ok := queryOptions["companyId"]; ok { | 161 | if companyId, ok := queryOptions["companyId"]; ok { |
@@ -161,8 +161,8 @@ func (repo *RoleUserRepository) Count(queryOptions map[string]interface{}) (int6 | @@ -161,8 +161,8 @@ func (repo *RoleUserRepository) Count(queryOptions map[string]interface{}) (int6 | ||
161 | query.Where("id != ?", notId) | 161 | query.Where("id != ?", notId) |
162 | } | 162 | } |
163 | 163 | ||
164 | - if name, ok := queryOptions["name"]; ok { | ||
165 | - query.Where("name = ?", name) | 164 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
165 | + query.Where("name = ?", v) | ||
166 | } | 166 | } |
167 | 167 | ||
168 | if companyId, ok := queryOptions["companyId"]; ok { | 168 | if companyId, ok := queryOptions["companyId"]; ok { |
@@ -116,7 +116,7 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d | @@ -116,7 +116,7 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d | ||
116 | if v, ok := queryOptions["account"]; ok { | 116 | if v, ok := queryOptions["account"]; ok { |
117 | query.Where("account like ?", v) | 117 | query.Where("account like ?", v) |
118 | } | 118 | } |
119 | - if v, ok := queryOptions["name"]; ok { | 119 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
120 | query.Where("name like ?", fmt.Sprintf("%%%v%%", v)) | 120 | query.Where("name like ?", fmt.Sprintf("%%%v%%", v)) |
121 | } | 121 | } |
122 | if v, ok := queryOptions["offset"]; ok { | 122 | if v, ok := queryOptions["offset"]; ok { |
-
请 注册 或 登录 后发表评论