作者 郑周

1. 查询列表数据 不等nil

正在显示 30 个修改的文件 包含 64 行增加59 行删除
@@ -4,7 +4,7 @@ import "github.com/beego/beego/v2/core/validation" @@ -4,7 +4,7 @@ import "github.com/beego/beego/v2/core/validation"
4 4
5 type QueryLogCommand struct { 5 type QueryLogCommand struct {
6 CompanyId int64 `cname:"公司ID" json:"-"` 6 CompanyId int64 `cname:"公司ID" json:"-"`
7 - TaskId int `cname:"任务ID" json:"taskId,string" valid:"Required"` 7 + TaskId string `cname:"任务ID" json:"taskId" valid:"Required"`
8 PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` 8 PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"`
9 PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` 9 PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"`
10 } 10 }
@@ -103,12 +103,13 @@ func (repo *CompanyRepository) Find(queryOptions map[string]interface{}) (int, [ @@ -103,12 +103,13 @@ func (repo *CompanyRepository) Find(queryOptions map[string]interface{}) (int, [
103 if err != nil { 103 if err != nil {
104 return 0, nil, err 104 return 0, nil, err
105 } 105 }
106 - var resultList []*domain.Company 106 +
  107 + arrays := make([]*domain.Company, 0)
107 for i := range companyModel { 108 for i := range companyModel {
108 result := repo.TransformToCompanyDomain(&companyModel[i]) 109 result := repo.TransformToCompanyDomain(&companyModel[i])
109 - resultList = append(resultList, result) 110 + arrays = append(arrays, result)
110 } 111 }
111 - return cnt, resultList, nil 112 + return cnt, arrays, nil
112 } 113 }
113 114
114 func (repo *CompanyRepository) TransformToCompanyDomain(m *models.Company) *domain.Company { 115 func (repo *CompanyRepository) TransformToCompanyDomain(m *models.Company) *domain.Company {
@@ -112,12 +112,13 @@ func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int @@ -112,12 +112,13 @@ func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int
112 if err != nil { 112 if err != nil {
113 return 0, nil, err 113 return 0, nil, err
114 } 114 }
115 - var resultList []*domain.Department 115 +
  116 + arrays := make([]*domain.Department, 0)
116 for i := range dparmentModel { 117 for i := range dparmentModel {
117 result := repo.TransformToCompanyDomain(&dparmentModel[i]) 118 result := repo.TransformToCompanyDomain(&dparmentModel[i])
118 - resultList = append(resultList, result) 119 + arrays = append(arrays, result)
119 } 120 }
120 - return cnt, resultList, nil 121 + return cnt, arrays, nil
121 } 122 }
122 123
123 func (repo *DepartmentRepository) FindAll(companyId int64) ([]*domain.Department, error) { 124 func (repo *DepartmentRepository) FindAll(companyId int64) ([]*domain.Department, error) {
@@ -161,7 +161,7 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) @@ -161,7 +161,7 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{})
161 if err != nil { 161 if err != nil {
162 return 0, nil, err 162 return 0, nil, err
163 } 163 }
164 - var arrays []*domain.EvaluationCycle 164 + arrays := make([]*domain.EvaluationCycle, 0)
165 for _, v := range m { 165 for _, v := range m {
166 d := repo.TransformToDomain(v) 166 d := repo.TransformToDomain(v)
167 arrays = append(arrays, &d) 167 arrays = append(arrays, &d)
@@ -212,7 +212,7 @@ func (repo *EvaluationCycleRepository) FindCycleEnd(limit int) ([]*domain.Evalua @@ -212,7 +212,7 @@ func (repo *EvaluationCycleRepository) FindCycleEnd(limit int) ([]*domain.Evalua
212 if err != nil { 212 if err != nil {
213 return nil, err 213 return nil, err
214 } 214 }
215 - var arrays []*domain.EvaluationCycle 215 + arrays := make([]*domain.EvaluationCycle, 0)
216 for _, v := range m { 216 for _, v := range m {
217 d := repo.TransformToDomain(v) 217 d := repo.TransformToDomain(v)
218 arrays = append(arrays, &d) 218 arrays = append(arrays, &d)
@@ -175,7 +175,7 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte @@ -175,7 +175,7 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte
175 if err != nil { 175 if err != nil {
176 return 0, nil, err 176 return 0, nil, err
177 } 177 }
178 - var arrays []*domain.EvaluationCycleTemplate 178 + arrays := make([]*domain.EvaluationCycleTemplate, 0)
179 for _, v := range m { 179 for _, v := range m {
180 d := repo.TransformToDomain(v) 180 d := repo.TransformToDomain(v)
181 arrays = append(arrays, &d) 181 arrays = append(arrays, &d)
@@ -111,10 +111,10 @@ func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface @@ -111,10 +111,10 @@ func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface
111 if err != nil { 111 if err != nil {
112 return 0, nil, err 112 return 0, nil, err
113 } 113 }
114 - var datas []*domain.EvaluationItemUsed 114 + arrays := make([]*domain.EvaluationItemUsed, 0)
115 for _, v := range m { 115 for _, v := range m {
116 d := repo.TransformToDomain(v) 116 d := repo.TransformToDomain(v)
117 - datas = append(datas, d) 117 + arrays = append(arrays, d)
118 } 118 }
119 - return count, datas, nil 119 + return count, arrays, nil
120 } 120 }
@@ -208,7 +208,7 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ @@ -208,7 +208,7 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{
208 if err != nil { 208 if err != nil {
209 return 0, nil, err 209 return 0, nil, err
210 } 210 }
211 - var arrays []*domain.EvaluationProject 211 + arrays := make([]*domain.EvaluationProject, 0)
212 for _, v := range m { 212 for _, v := range m {
213 d := repo.TransformToDomain(v) 213 d := repo.TransformToDomain(v)
214 arrays = append(arrays, &d) 214 arrays = append(arrays, &d)
@@ -163,7 +163,7 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) @@ -163,7 +163,7 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{})
163 if err != nil { 163 if err != nil {
164 return 0, nil, err 164 return 0, nil, err
165 } 165 }
166 - var arrays []*domain.EvaluationRule 166 + arrays := make([]*domain.EvaluationRule, 0)
167 for _, v := range m { 167 for _, v := range m {
168 d := repo.TransformToDomain(v) 168 d := repo.TransformToDomain(v)
169 arrays = append(arrays, &d) 169 arrays = append(arrays, &d)
@@ -176,7 +176,7 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface @@ -176,7 +176,7 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
176 if err != nil { 176 if err != nil {
177 return 0, nil, err 177 return 0, nil, err
178 } 178 }
179 - var arrays []*domain.EvaluationTemplate 179 + arrays := make([]*domain.EvaluationTemplate, 0)
180 for _, v := range m { 180 for _, v := range m {
181 d := repo.TransformToDomain(v) 181 d := repo.TransformToDomain(v)
182 arrays = append(arrays, &d) 182 arrays = append(arrays, &d)
@@ -145,7 +145,7 @@ func (repo *LogOptRepository) Find(queryOptions map[string]interface{}) (int64, @@ -145,7 +145,7 @@ func (repo *LogOptRepository) Find(queryOptions map[string]interface{}) (int64,
145 if err != nil { 145 if err != nil {
146 return 0, nil, err 146 return 0, nil, err
147 } 147 }
148 - var arrays []*domain.LogOpt 148 + arrays := make([]*domain.LogOpt, 0)
149 for _, v := range m { 149 for _, v := range m {
150 d := repo.TransformToDomain(v) 150 d := repo.TransformToDomain(v)
151 arrays = append(arrays, &d) 151 arrays = append(arrays, &d)
@@ -78,12 +78,13 @@ func (repo *LogSmsRepository) Find(queryOptions map[string]interface{}) (int, [] @@ -78,12 +78,13 @@ func (repo *LogSmsRepository) Find(queryOptions map[string]interface{}) (int, []
78 if err != nil { 78 if err != nil {
79 return 0, nil, err 79 return 0, nil, err
80 } 80 }
81 - var datas []*domain.LogSms 81 +
  82 + arrays := make([]*domain.LogSms, 0)
82 for _, v := range m { 83 for _, v := range m {
83 d := repo.TransformToDomain(v) 84 d := repo.TransformToDomain(v)
84 - datas = append(datas, d) 85 + arrays = append(arrays, d)
85 } 86 }
86 - return count, datas, nil 87 + return count, arrays, nil
87 } 88 }
88 89
89 func (repo *LogSmsRepository) TransformToDomain(d *models.LogSms) *domain.LogSms { 90 func (repo *LogSmsRepository) TransformToDomain(d *models.LogSms) *domain.LogSms {
@@ -81,11 +81,12 @@ func (repo *MessagePersonalRepository) Find(param map[string]interface{}) (int, @@ -81,11 +81,12 @@ func (repo *MessagePersonalRepository) Find(param map[string]interface{}) (int,
81 if err != nil { 81 if err != nil {
82 return 0, nil, err 82 return 0, nil, err
83 } 83 }
84 - var datas []*domain.MessagePersonal 84 +
  85 + arrays := make([]*domain.MessagePersonal, 0)
85 for _, v := range m { 86 for _, v := range m {
86 d := repo.TransformToDomain(v) 87 d := repo.TransformToDomain(v)
87 - datas = append(datas, d) 88 + arrays = append(arrays, d)
88 } 89 }
89 - return count, datas, nil 90 + return count, arrays, nil
90 91
91 } 92 }
@@ -159,7 +159,7 @@ func (repo *NodeTaskRepository) Find(queryOptions map[string]interface{}) ([]*do @@ -159,7 +159,7 @@ func (repo *NodeTaskRepository) Find(queryOptions map[string]interface{}) ([]*do
159 if err != nil { 159 if err != nil {
160 return nil, err 160 return nil, err
161 } 161 }
162 - var arrays []*domain.NodeTask 162 + arrays := make([]*domain.NodeTask, 0)
163 for _, v := range m { 163 for _, v := range m {
164 d := repo.TransformToDomain(v) 164 d := repo.TransformToDomain(v)
165 arrays = append(arrays, &d) 165 arrays = append(arrays, &d)
@@ -119,7 +119,7 @@ func (repo *PermissionRepository) Find(queryOptions map[string]interface{}) (int @@ -119,7 +119,7 @@ func (repo *PermissionRepository) Find(queryOptions map[string]interface{}) (int
119 if err != nil { 119 if err != nil {
120 return 0, nil, err 120 return 0, nil, err
121 } 121 }
122 - var arrays []*domain.Permission 122 + arrays := make([]*domain.Permission, 0)
123 for _, v := range m { 123 for _, v := range m {
124 d := repo.TransformToDomain(v) 124 d := repo.TransformToDomain(v)
125 arrays = append(arrays, &d) 125 arrays = append(arrays, &d)
@@ -90,12 +90,12 @@ func (repo *PositionRepository) Find(queryOptions map[string]interface{}) (int, @@ -90,12 +90,12 @@ func (repo *PositionRepository) Find(queryOptions map[string]interface{}) (int,
90 if err != nil { 90 if err != nil {
91 return 0, nil, err 91 return 0, nil, err
92 } 92 }
93 - var resultList []*domain.Position 93 + arrays := make([]*domain.Position, 0)
94 for i := range positionModel { 94 for i := range positionModel {
95 result := repo.transferToDomain(&positionModel[i]) 95 result := repo.transferToDomain(&positionModel[i])
96 - resultList = append(resultList, result) 96 + arrays = append(arrays, result)
97 } 97 }
98 - return cnt, resultList, nil 98 + return cnt, arrays, nil
99 } 99 }
100 100
101 func (repository *PositionRepository) transferToDomain(model *models.Position) *domain.Position { 101 func (repository *PositionRepository) transferToDomain(model *models.Position) *domain.Position {
@@ -137,7 +137,8 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, [] @@ -137,7 +137,8 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, []
137 if err != nil { 137 if err != nil {
138 return 0, nil, err 138 return 0, nil, err
139 } 139 }
140 - var arrays []*domain.Role 140 +
  141 + arrays := make([]*domain.Role, 0)
141 for _, v := range m { 142 for _, v := range m {
142 d := repo.TransformToDomain(v) 143 d := repo.TransformToDomain(v)
143 arrays = append(arrays, &d) 144 arrays = append(arrays, &d)
@@ -139,7 +139,7 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64 @@ -139,7 +139,7 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64
139 if err != nil { 139 if err != nil {
140 return 0, nil, err 140 return 0, nil, err
141 } 141 }
142 - var arrays []*domain.RoleUser 142 + arrays := make([]*domain.RoleUser, 0)
143 for _, v := range m { 143 for _, v := range m {
144 d := repo.TransformToDomain(v) 144 d := repo.TransformToDomain(v)
145 arrays = append(arrays, &d) 145 arrays = append(arrays, &d)
@@ -125,7 +125,7 @@ func (repo *StaffAssessCacheRepository) Find(queryOptions map[string]interface{} @@ -125,7 +125,7 @@ func (repo *StaffAssessCacheRepository) Find(queryOptions map[string]interface{}
125 if err != nil { 125 if err != nil {
126 return 0, nil, err 126 return 0, nil, err
127 } 127 }
128 - var arrays []*domain.StaffAssessCache 128 + arrays := make([]*domain.StaffAssessCache, 0)
129 for _, v := range m { 129 for _, v := range m {
130 d := repo.TransformToDomain(v) 130 d := repo.TransformToDomain(v)
131 arrays = append(arrays, &d) 131 arrays = append(arrays, &d)
@@ -139,7 +139,7 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface @@ -139,7 +139,7 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface
139 if err != nil { 139 if err != nil {
140 return 0, nil, err 140 return 0, nil, err
141 } 141 }
142 - var arrays []*domain.StaffAssessContent 142 + arrays := make([]*domain.StaffAssessContent, 0)
143 for _, v := range m { 143 for _, v := range m {
144 d := repo.TransformToDomain(v) 144 d := repo.TransformToDomain(v)
145 arrays = append(arrays, d) 145 arrays = append(arrays, d)
@@ -172,7 +172,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -172,7 +172,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
172 if err != nil { 172 if err != nil {
173 return 0, nil, err 173 return 0, nil, err
174 } 174 }
175 - var arrays []*domain.StaffAssess 175 + arrays := make([]*domain.StaffAssess, 0)
176 for _, v := range m { 176 for _, v := range m {
177 d := repo.TransformToDomain(v) 177 d := repo.TransformToDomain(v)
178 arrays = append(arrays, d) 178 arrays = append(arrays, d)
@@ -136,7 +136,7 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) @@ -136,7 +136,7 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
136 if err != nil { 136 if err != nil {
137 return 0, nil, err 137 return 0, nil, err
138 } 138 }
139 - var arrays []*domain.StaffAssessTask 139 + arrays := make([]*domain.StaffAssessTask, 0)
140 for _, v := range m { 140 for _, v := range m {
141 d := repo.TransformToDomain(v) 141 d := repo.TransformToDomain(v)
142 arrays = append(arrays, d) 142 arrays = append(arrays, d)
@@ -180,12 +180,12 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{ @@ -180,12 +180,12 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
180 if err != nil { 180 if err != nil {
181 return 0, nil, err 181 return 0, nil, err
182 } 182 }
183 - var datas []*domain.SummaryEvaluation 183 + arrays := make([]*domain.SummaryEvaluation, 0)
184 for _, v := range m { 184 for _, v := range m {
185 d := repo.TransformToDomain(v) 185 d := repo.TransformToDomain(v)
186 - datas = append(datas, d) 186 + arrays = append(arrays, d)
187 } 187 }
188 - return count, datas, nil 188 + return count, arrays, nil
189 } 189 }
190 190
191 func (repo *SummaryEvaluationRepository) RemoveByProjectId(id int) error { 191 func (repo *SummaryEvaluationRepository) RemoveByProjectId(id int) error {
@@ -125,10 +125,10 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter @@ -125,10 +125,10 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter
125 if err != nil { 125 if err != nil {
126 return 0, nil, err 126 return 0, nil, err
127 } 127 }
128 - var datas []*domain.SummaryEvaluationValue 128 + arrays := make([]*domain.SummaryEvaluationValue, 0)
129 for _, v := range m { 129 for _, v := range m {
130 d := repo.TransformToDomain(v) 130 d := repo.TransformToDomain(v)
131 - datas = append(datas, d) 131 + arrays = append(arrays, d)
132 } 132 }
133 - return count, datas, nil 133 + return count, arrays, nil
134 } 134 }
@@ -138,10 +138,10 @@ func (repo *TaskAnomalyRepository) Find(queryOptions map[string]interface{}) (in @@ -138,10 +138,10 @@ func (repo *TaskAnomalyRepository) Find(queryOptions map[string]interface{}) (in
138 if err != nil { 138 if err != nil {
139 return 0, nil, err 139 return 0, nil, err
140 } 140 }
141 - var datas []*domain.TaskAnomaly 141 + arrays := make([]*domain.TaskAnomaly, 0)
142 for _, v := range m { 142 for _, v := range m {
143 d := repo.TransformToDomain(v) 143 d := repo.TransformToDomain(v)
144 - datas = append(datas, d) 144 + arrays = append(arrays, d)
145 } 145 }
146 - return count, datas, nil 146 + return count, arrays, nil
147 } 147 }
@@ -99,10 +99,10 @@ func (repo *TaskIgnoreRepository) Find(queryOptions map[string]interface{}) (int @@ -99,10 +99,10 @@ func (repo *TaskIgnoreRepository) Find(queryOptions map[string]interface{}) (int
99 if err != nil { 99 if err != nil {
100 return 0, nil, err 100 return 0, nil, err
101 } 101 }
102 - var datas []*domain.TaskIgnore 102 + arrays := make([]*domain.TaskIgnore, 0)
103 for _, v := range m { 103 for _, v := range m {
104 d := repo.TransformToDomain(v) 104 d := repo.TransformToDomain(v)
105 - datas = append(datas, d) 105 + arrays = append(arrays, d)
106 } 106 }
107 - return count, datas, nil 107 + return count, arrays, nil
108 } 108 }
@@ -64,10 +64,10 @@ func (repo *TaskLevelRepository) Find(queryOptions map[string]interface{}) (int, @@ -64,10 +64,10 @@ func (repo *TaskLevelRepository) Find(queryOptions map[string]interface{}) (int,
64 if err != nil { 64 if err != nil {
65 return 0, nil, err 65 return 0, nil, err
66 } 66 }
67 - var datas []*domain.TaskLevel 67 + arrays := make([]*domain.TaskLevel, 0)
68 for _, v := range m { 68 for _, v := range m {
69 d := repo.TransformToDomain(v) 69 d := repo.TransformToDomain(v)
70 - datas = append(datas, d) 70 + arrays = append(arrays, d)
71 } 71 }
72 - return count, datas, nil 72 + return count, arrays, nil
73 } 73 }
@@ -177,7 +177,7 @@ func (repo *TaskRecordRepository) Find(queryOptions map[string]interface{}) (int @@ -177,7 +177,7 @@ func (repo *TaskRecordRepository) Find(queryOptions map[string]interface{}) (int
177 if err != nil { 177 if err != nil {
178 return 0, nil, err 178 return 0, nil, err
179 } 179 }
180 - var arrays []*domain.TaskRecord 180 + arrays := make([]*domain.TaskRecord, 0)
181 for _, v := range m { 181 for _, v := range m {
182 d := repo.TransformToDomain(v) 182 d := repo.TransformToDomain(v)
183 arrays = append(arrays, &d) 183 arrays = append(arrays, &d)
@@ -179,10 +179,10 @@ func (repo *TaskRepository) Find(queryOptions map[string]interface{}) (int, []*d @@ -179,10 +179,10 @@ func (repo *TaskRepository) Find(queryOptions map[string]interface{}) (int, []*d
179 if err != nil { 179 if err != nil {
180 return 0, nil, err 180 return 0, nil, err
181 } 181 }
182 - var datas []*domain.Task 182 + arrays := make([]*domain.Task, 0)
183 for _, v := range m { 183 for _, v := range m {
184 d := repo.TransformToDomain(v) 184 d := repo.TransformToDomain(v)
185 - datas = append(datas, d) 185 + arrays = append(arrays, d)
186 } 186 }
187 - return count, datas, nil 187 + return count, arrays, nil
188 } 188 }
@@ -118,10 +118,10 @@ func (repo *TaskStageRepository) Find(queryOptions map[string]interface{}) (int, @@ -118,10 +118,10 @@ func (repo *TaskStageRepository) Find(queryOptions map[string]interface{}) (int,
118 if err != nil { 118 if err != nil {
119 return 0, nil, err 119 return 0, nil, err
120 } 120 }
121 - var datas []*domain.TaskStage 121 + arrays := make([]*domain.TaskStage, 0)
122 for _, v := range m { 122 for _, v := range m {
123 d := repo.TransformToDomain(v) 123 d := repo.TransformToDomain(v)
124 - datas = append(datas, d) 124 + arrays = append(arrays, d)
125 } 125 }
126 - return count, datas, nil 126 + return count, arrays, nil
127 } 127 }
@@ -169,12 +169,12 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d @@ -169,12 +169,12 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d
169 if err != nil { 169 if err != nil {
170 return 0, nil, err 170 return 0, nil, err
171 } 171 }
172 - var resultList []*domain.User 172 + arrays := make([]*domain.User, 0)
173 for i := range userModel { 173 for i := range userModel {
174 result := repo.TransformToUserDomain(&userModel[i]) 174 result := repo.TransformToUserDomain(&userModel[i])
175 - resultList = append(resultList, result) 175 + arrays = append(arrays, result)
176 } 176 }
177 - return cnt, resultList, nil 177 + return cnt, arrays, nil
178 } 178 }
179 179
180 func (repo *UserRepository) TransformToUserDomain(user *models.User) *domain.User { 180 func (repo *UserRepository) TransformToUserDomain(user *models.User) *domain.User {