質問編集履歴
1
原因究明するにあたって不足していたコードを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,6 +118,160 @@
|
|
118
118
|
|
119
119
|
|
120
120
|
|
121
|
+
UnitService
|
122
|
+
|
123
|
+
```java
|
124
|
+
|
125
|
+
package com.ransu.lastperiodweb.service;
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
import org.bson.types.ObjectId;
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
import com.ransu.lastperiodweb.entity.UnitEntity;
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
public interface UnitService {
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
UnitEntity getUnitById(ObjectId id);
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
UnitEntity save(UnitEntity units);
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
Boolean delete(UnitEntity units);
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
```
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
UnitServiceImp
|
158
|
+
|
159
|
+
```java
|
160
|
+
|
161
|
+
package com.ransu.lastperiodweb.service.imp;
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
import org.bson.types.ObjectId;
|
166
|
+
|
167
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
168
|
+
|
169
|
+
import org.springframework.stereotype.Service;
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
import com.ransu.lastperiodweb.entity.UnitEntity;
|
174
|
+
|
175
|
+
import com.ransu.lastperiodweb.repository.UnitRepository;
|
176
|
+
|
177
|
+
import com.ransu.lastperiodweb.service.UnitService;
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
@Service
|
182
|
+
|
183
|
+
public class UnitServiceImp implements UnitService {
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
@Autowired
|
188
|
+
|
189
|
+
private UnitRepository repository;
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
@Override
|
194
|
+
|
195
|
+
public UnitEntity getUnitById(ObjectId id) {
|
196
|
+
|
197
|
+
return repository.findById(id);
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
@Override
|
204
|
+
|
205
|
+
public UnitEntity save(UnitEntity units) {
|
206
|
+
|
207
|
+
return repository.save(units);
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
@Override
|
214
|
+
|
215
|
+
public Boolean delete(UnitEntity units) {
|
216
|
+
|
217
|
+
Boolean result = true;
|
218
|
+
|
219
|
+
try {
|
220
|
+
|
221
|
+
repository.delete(units);
|
222
|
+
|
223
|
+
} catch (Exception e) {
|
224
|
+
|
225
|
+
result = false;
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
return result;
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
```
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
UnitRepository
|
242
|
+
|
243
|
+
```java
|
244
|
+
|
245
|
+
package com.ransu.lastperiodweb.repository;
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
import org.bson.types.ObjectId;
|
250
|
+
|
251
|
+
import org.springframework.data.mongodb.repository.MongoRepository;
|
252
|
+
|
253
|
+
import org.springframework.stereotype.Repository;
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
import com.ransu.lastperiodweb.entity.UnitEntity;
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
@Repository
|
262
|
+
|
263
|
+
public interface UnitRepository extends MongoRepository<UnitEntity, String> {
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
UnitEntity findById(ObjectId id);
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
```
|
274
|
+
|
121
275
|
こちらぜひ、何かヒントでもわかる方がいましたらご助力をお願いいたします。
|
122
276
|
|
123
277
|
また、原因究明の際に何か足りない情報がございましたご指摘をお願いいたします。
|