8
8
import org .skhuton .skhudebug .bughunt .repository .BughuntRepository ;
9
9
import org .skhuton .skhudebug .exception .ErrorCode ;
10
10
import org .skhuton .skhudebug .exception .model .NotFoundException ;
11
+ import org .skhuton .skhudebug .match .domain .HuntReqManagement ;
12
+ import org .skhuton .skhudebug .match .repository .HuntMatchRepository ;
11
13
import org .skhuton .skhudebug .member .domain .User ;
12
14
import org .skhuton .skhudebug .member .repository .UserRepository ;
13
15
import org .springframework .stereotype .Service ;
24
26
public class BughuntService {
25
27
private final BughuntRepository bughuntRepository ;
26
28
private final UserRepository userRepository ;
29
+ private final HuntMatchRepository huntMatchRepository ;
27
30
28
31
@ Transactional
29
- public Bughunt save (BughuntSaveReqDto bughuntSaveReqDto ) {
32
+ public void save (BughuntSaveReqDto bughuntSaveReqDto ) {
30
33
User user = userRepository .findByLoginId (bughuntSaveReqDto .loginId ()).orElseThrow (
31
34
()-> new NotFoundException (
32
35
ErrorCode .USER_NOT_FOUND ,
@@ -42,7 +45,17 @@ public Bughunt save(BughuntSaveReqDto bughuntSaveReqDto) {
42
45
.radius (bughuntSaveReqDto .radius ())
43
46
.build ();
44
47
bughunt .setCreatedAt (LocalDateTime .now ());
45
- return bughuntRepository .save (bughunt );
48
+ bughuntRepository .save (bughunt );
49
+
50
+ //์์ฒญ ์์ด๋ ๊ฐ ๊ฐ์ ธ์์ ์ ์ฅํ๊ธฐ.
51
+ Bughunt getvalue = bughuntRepository .findByUser (user );
52
+ HuntReqManagement huntReqManagement = HuntReqManagement .builder ()
53
+ .requestId (getvalue .getId ())
54
+ .senderId (user .getLoginId ())
55
+ .senderId (null )
56
+ .complete (false )
57
+ .build ();
58
+ huntMatchRepository .save (huntReqManagement );
46
59
}
47
60
public BughuntListResDto findAll (){
48
61
List <Bughunt > bughunts = bughuntRepository .findAll ();
0 commit comments