質問するログイン新規登録

質問編集履歴

1

原因究明するにあたって不足していたコードを追記

2020/12/31 13:54

投稿

ransuS_T
ransuS_T

スコア106

title CHANGED
File without changes
body CHANGED
@@ -58,5 +58,82 @@
58
58
 
59
59
  ```
60
60
 
61
+ UnitService
62
+ ```java
63
+ package com.ransu.lastperiodweb.service;
64
+
65
+ import org.bson.types.ObjectId;
66
+
67
+ import com.ransu.lastperiodweb.entity.UnitEntity;
68
+
69
+ public interface UnitService {
70
+
71
+ UnitEntity getUnitById(ObjectId id);
72
+
73
+ UnitEntity save(UnitEntity units);
74
+
75
+ Boolean delete(UnitEntity units);
76
+ }
77
+ ```
78
+
79
+ UnitServiceImp
80
+ ```java
81
+ package com.ransu.lastperiodweb.service.imp;
82
+
83
+ import org.bson.types.ObjectId;
84
+ import org.springframework.beans.factory.annotation.Autowired;
85
+ import org.springframework.stereotype.Service;
86
+
87
+ import com.ransu.lastperiodweb.entity.UnitEntity;
88
+ import com.ransu.lastperiodweb.repository.UnitRepository;
89
+ import com.ransu.lastperiodweb.service.UnitService;
90
+
91
+ @Service
92
+ public class UnitServiceImp implements UnitService {
93
+
94
+ @Autowired
95
+ private UnitRepository repository;
96
+
97
+ @Override
98
+ public UnitEntity getUnitById(ObjectId id) {
99
+ return repository.findById(id);
100
+ }
101
+
102
+ @Override
103
+ public UnitEntity save(UnitEntity units) {
104
+ return repository.save(units);
105
+ }
106
+
107
+ @Override
108
+ public Boolean delete(UnitEntity units) {
109
+ Boolean result = true;
110
+ try {
111
+ repository.delete(units);
112
+ } catch (Exception e) {
113
+ result = false;
114
+ }
115
+ return result;
116
+ }
117
+ }
118
+
119
+ ```
120
+
121
+ UnitRepository
122
+ ```java
123
+ package com.ransu.lastperiodweb.repository;
124
+
125
+ import org.bson.types.ObjectId;
126
+ import org.springframework.data.mongodb.repository.MongoRepository;
127
+ import org.springframework.stereotype.Repository;
128
+
129
+ import com.ransu.lastperiodweb.entity.UnitEntity;
130
+
131
+ @Repository
132
+ public interface UnitRepository extends MongoRepository<UnitEntity, String> {
133
+
134
+ UnitEntity findById(ObjectId id);
135
+ }
136
+
137
+ ```
61
138
  こちらぜひ、何かヒントでもわかる方がいましたらご助力をお願いいたします。
62
139
  また、原因究明の際に何か足りない情報がございましたご指摘をお願いいたします。