Skip to content

Commit

Permalink
Merge pull request #42 from How-homework-out/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
ryulkim authored Nov 14, 2023
2 parents 63f5971 + 4e5c508 commit 1f53408
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/main/java/inha/how/Controller/LiveController.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public BaseResponse<liveListRes> LiveProgressList(){
return new BaseResponse<>(liveListRes);
}

@Operation(summary = "live 등록(수정 필요)", description = "방장이 live 방을 등록하는 api다.")
@Operation(summary = "live 등록", description = "방장이 live 방을 등록하는 api다.")
@PostMapping("")
public BaseResponse<liveAddRes> LiveAdd(@RequestHeader("Authorization") String jws, @RequestBody liveReq liveReq){
User user = userService.validUser(jws);
Expand All @@ -43,12 +43,12 @@ public BaseResponse LiveLeave(@PathVariable("id") Long roomId){
return new BaseResponse();
}

@Operation(summary = "live 참여하기(테스트)", description = "참여자가 live를 참여할 때 쓰는 api다.")
@Operation(summary = "live 참여하기", description = "참여자가 live를 참여할 때 쓰는 api다.")
@PostMapping("/participates")
public BaseResponse LiveParticipate(@RequestHeader("Authorization") String jws, @RequestBody liveParticipateReq req){
public BaseResponse<liveAddRes> LiveParticipate(@RequestHeader("Authorization") String jws, @RequestBody liveParticipateReq req){
User user = userService.validUser(jws);
liveService.addParticipate(user, req.getLiveId());
return new BaseResponse();
liveAddRes res = liveService.addParticipate(user, req.getLiveId());
return new BaseResponse<>(res);
}

@Operation(summary = "live 나가기", description = "참여자가 live를 나갈 때 쓰는 api다.")
Expand Down
1 change: 1 addition & 0 deletions src/main/java/inha/how/Domain/dto/live/liveAddRes.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
@AllArgsConstructor
public class liveAddRes {
Long roomId;
String subject;
}
2 changes: 1 addition & 1 deletion src/main/java/inha/how/Domain/entity/Participate.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Setter
@Getter
@Entity
public class Participate {
public class Participate extends BaseTimeEntity{
@EmbeddedId
private ParticipateId participateId;
@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Repository
public interface ParticipateRepository extends JpaRepository<Participate, Long> {
Integer countByParticipateIdLiveRoom(LiveRoom live);
List<ParticipateNicksMapping> findParticipateByParticipateIdLiveRoom(LiveRoom live);
List<ParticipateNicksMapping> findParticipateByParticipateIdLiveRoomOrderByCreateDateAsc(LiveRoom live);
void deleteByParticipateId(ParticipateId participateId);
void deleteByParticipateIdLiveRoom(LiveRoom liveRoom);

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/inha/how/Service/LiveService.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public liveAddRes addLive(User user, String subject, Long routId){
// live방 운동 루틴 로컬 저장
liveRoutine.save(liveRoom.getId(), routineService.findRoutineOne(routId));

return new liveAddRes(liveRoom.getId());
return new liveAddRes(liveRoom.getId(), liveRoom.getRoomSubject());
}

@Transactional
Expand All @@ -68,7 +68,7 @@ public void deleteLive(Long liveId){
liveRepository.deleteById(liveId);
}

public void addParticipate(User user, Long liveId){
public liveAddRes addParticipate(User user, Long liveId){
LiveRoom liveRoom = liveRepository.findLiveRoomById(liveId);
Participate participate = new Participate();
ParticipateId participateId=new ParticipateId();
Expand All @@ -80,6 +80,8 @@ public void addParticipate(User user, Long liveId){
participate.setAccess(Access.participate);

participateRepository.save(participate);

return new liveAddRes(liveRoom.getId(), liveRoom.getRoomSubject());
}

@Transactional
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/inha/how/Service/StompService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public RoutineDetailRes modifyRoutine(Long roomId, Map<String, Object> data){

public List<ParticipateNicksMapping> findNicks(Long roomId){
LiveRoom liveRoom=liveRepository.findLiveRoomById(roomId);
List<ParticipateNicksMapping> nicks = participateRepository.findParticipateByParticipateIdLiveRoom(liveRoom);
List<ParticipateNicksMapping> nicks = participateRepository.findParticipateByParticipateIdLiveRoomOrderByCreateDateAsc(liveRoom);

return nicks;
}
Expand Down

0 comments on commit 1f53408

Please sign in to comment.