Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jinsu4755 committed Jul 12, 2023
2 parents c98905d + 87f43b9 commit 6d73cb0
Show file tree
Hide file tree
Showing 28 changed files with 478 additions and 18 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<!-- ALL-CONTRIBUTORS-BADGE:END -->
해당 프로젝트는 SOPT 32th APPJAM 프로젝트입니다.

Sparkle, 연인과 승부를 통한 설렘 가득 소원권 내기 앱 서비스입니다.

## Contributors
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
Expand Down Expand Up @@ -94,3 +96,21 @@ hotfix : 출시 버전에서 발생한 버그를 수정 하는 브랜치
└── test
```

### 역할 분담
```
박진수
DB 설계, AWS 인프라, CD 구성, User 도메인 및 소셜 로그인 api, 잡일
```
```
이영주
DB 설계, CI구성, 소원권 및 미션 카테고리 api
```
```
신지연
DB 설계, 한판 승부 및 승부 히스토리 api
```

### Architecture

<img width="672" alt="image" src="https://github.com/TeamPophory/pophory-server/assets/81692211/4e1ac301-9bc5-4fb9-b877-d58c18c0ca8b">
28 changes: 28 additions & 0 deletions src/main/java/com/universe/uni/controller/ShortGameController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.universe.uni.controller;

import javax.validation.Valid;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.universe.uni.dto.request.CreateShortGameRequestDto;
import com.universe.uni.dto.response.CreateShortGameResponseDto;
import com.universe.uni.service.GameService;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/game/short")
public class ShortGameController {

private final GameService gameService;

@PostMapping
public CreateShortGameResponseDto createShortGame(@RequestBody @Valid final CreateShortGameRequestDto createShortGameRequestDto) {
return gameService.createShortGame(createShortGameRequestDto);
}

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.universe.uni.controller;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.universe.uni.dto.request.UpdateWishCouponRequestDto;
import com.universe.uni.dto.response.UpdateWishCouponResponseDto;
import com.universe.uni.dto.response.WishCouponResponseDto;
import com.universe.uni.service.WishCouponService;

import lombok.RequiredArgsConstructor;
Expand All @@ -22,9 +25,19 @@ public class WishCouponController {

@PatchMapping
@ResponseStatus(HttpStatus.OK)
public UpdateWishCouponResponseDto updateWishCoupon(
@RequestBody UpdateWishCouponRequestDto requestDto
) {
public UpdateWishCouponResponseDto updateWishCoupon(@RequestBody UpdateWishCouponRequestDto requestDto) {
return wishCouponService.uploadWishCoupon(requestDto);
}

@PatchMapping("/{wishCouponId}")
@ResponseStatus(HttpStatus.OK)
public void useWishCoupon(@PathVariable Long wishCouponId) {
wishCouponService.useWishCoupon(wishCouponId);
}

@GetMapping("/{wishCouponId}")
@ResponseStatus(HttpStatus.OK)
public WishCouponResponseDto wishCouponResponseDto(@PathVariable Long wishCouponId) {
return wishCouponService.getWishCoupon(wishCouponId);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/universe/uni/domain/GameResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Objects;

public enum GameResult {
WIN, LOSE, DRAW;
WIN, LOSE, DRAW, UNDECIDED;

public static GameResult findMatchResultBy(String gameResultName) {
return Arrays.stream(values())
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/universe/uni/domain/entity/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ public class Game {

@Column(name = "finish_at")
private LocalDateTime finishAt;

public Game(Couple couple) {
this.couple = couple;
this.enable = Boolean.TRUE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import javax.persistence.Table;

import com.universe.uni.domain.MissionType;
import com.universe.uni.domain.entity.convertor.GameResultAttributeConverter;
import com.universe.uni.domain.entity.convertor.MissionTypeAttributeConverter;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@Table(name = "mission_category")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MissionCategory {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/universe/uni/domain/entity/RoundGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javax.persistence.Table;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand Down Expand Up @@ -39,4 +40,11 @@ public class RoundGame {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_game_history_id")
private UserGameHistory userGameHistory;

@Builder
public RoundGame(Game game, MissionCategory missionCategory) {
this.game = game;
this.missionCategory = missionCategory;
this.enable = Boolean.TRUE;
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/universe/uni/domain/entity/RoundMission.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.universe.uni.domain.entity.convertor.GameResultAttributeConverter;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand Down Expand Up @@ -53,4 +54,13 @@ public class RoundMission {
@Column(name = "final_result")
@Convert(converter = GameResultAttributeConverter.class)
private GameResult finalResult;

@Builder
public RoundMission(RoundGame roundGame, MissionContent missionContent, User user) {
this.roundGame = roundGame;
this.missionContent = missionContent;
this.user = user;
this.result = GameResult.UNDECIDED;
this.finalResult = GameResult.UNDECIDED;
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/universe/uni/domain/entity/ShortGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.persistence.PrimaryKeyJoinColumn;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand All @@ -15,4 +16,8 @@
@PrimaryKeyJoinColumn(name = "game_id")
public class ShortGame extends Game {

@Builder
public ShortGame(Couple couple) {
super(couple);
}
}
1 change: 1 addition & 0 deletions src/main/java/com/universe/uni/domain/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.universe.uni.domain.SnsType;
import com.universe.uni.domain.entity.convertor.SnsTypeAttributeConverter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import static lombok.AccessLevel.PROTECTED;

@Entity
@Table(name = "user_match_history")
@Table(name = "user_game_history")
@NoArgsConstructor(access = PROTECTED)
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/universe/uni/domain/entity/WishCoupon.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class WishCoupon {
private LocalDateTime usedAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
@JoinColumn(name = "user_id")
private User user;

@ManyToOne(fetch = FetchType.LAZY)
Expand All @@ -61,15 +61,12 @@ public class WishCoupon {
private GameType gameType;

@Builder
public WishCoupon(Long id, String image, String content, boolean isVisible, boolean isUsed, LocalDateTime usedAt,
User user, Game game, GameType gameType) {
this.id = id;
public WishCoupon(String image, String content, boolean isVisible,
Game game, GameType gameType) {
this.image = image;
this.content = content;
this.isVisible = isVisible;
this.isUsed = isUsed;
this.usedAt = usedAt;
this.user = user;
this.isUsed = Boolean.FALSE;
this.game = game;
this.gameType = gameType;
}
Expand All @@ -81,4 +78,9 @@ public void updateContent(String content) {
public void makeVisible() {
this.isVisible = true;
}

public void useWishCoupon() {
this.isUsed = true;
this.usedAt = LocalDateTime.now();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.universe.uni.dto.request;

import javax.validation.constraints.NotNull;

import lombok.Getter;

@Getter
public class CreateShortGameRequestDto {

@NotNull
private Long missionCategoryId;

@NotNull
private String wishContent;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.universe.uni.dto.response;

import com.universe.uni.domain.entity.RoundMission;
import com.universe.uni.domain.entity.ShortGame;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class CreateShortGameResponseDto {
private ShortGameDto shortGame;
private RoundMissionDto roundMission;

public static CreateShortGameResponseDto of(ShortGame shortGame, RoundMission roundMission) {
return new CreateShortGameResponseDto(new ShortGameDto(shortGame), new RoundMissionDto(roundMission));
}
}
26 changes: 26 additions & 0 deletions src/main/java/com/universe/uni/dto/response/RoundMissionDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.universe.uni.dto.response;

import java.time.LocalDateTime;

import com.universe.uni.domain.GameResult;
import com.universe.uni.domain.entity.MissionContent;
import com.universe.uni.domain.entity.RoundMission;

import lombok.Getter;

@Getter
public class RoundMissionDto {
private long roundMissionId;
private MissionContent missionContent;
private GameResult result;
private GameResult finalResult;
private LocalDateTime updatedAt;

public RoundMissionDto(RoundMission roundMission){
this.roundMissionId = roundMission.getId();
this.missionContent = roundMission.getMissionContent();
this.result = roundMission.getResult();
this.finalResult = roundMission.getFinalResult();
this.updatedAt = roundMission.getUpdatedAt();
}
}
21 changes: 21 additions & 0 deletions src/main/java/com/universe/uni/dto/response/ShortGameDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.universe.uni.dto.response;

import java.time.LocalDateTime;

import com.universe.uni.domain.entity.ShortGame;

import lombok.Getter;

@Getter
public class ShortGameDto {
private Long id;
private Boolean enable;
private LocalDateTime finishAt;

public ShortGameDto(ShortGame shortGame) {
this.id = shortGame.getId();
this.enable = shortGame.getEnable();
this.finishAt = shortGame.getFinishAt();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.universe.uni.dto.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import lombok.Builder;

@JsonPropertyOrder({"id", "isMine", "image", "content", "isVisible", "isUsed", "usedAt", "gameType"})
@Builder
public record WishCouponResponseDto(
Long id,
boolean isMine,
String image,
String content,
@JsonProperty("isVisible") boolean visible,
@JsonProperty("isUsed") boolean used,
String usedAt,
String gameType
) {
}
5 changes: 5 additions & 0 deletions src/main/java/com/universe/uni/exception/dto/ErrorType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public enum ErrorType {
"요청 방식이 잘못된 경우입니다. 요청 방식 자체가 잘못된 경우입니다."),
VALIDATION_TOKEN_MISSING_EXCEPTION(HttpStatus.BAD_REQUEST, "UE1002",
"요청 시 토큰이 누락되어 토큰 값이 없는 경우입니다."),
ALREADY_GAME_CREATED(HttpStatus.BAD_REQUEST, "UE1003",
"이미 생성된 승부가 있습니다."),

/**
* 401 Unauthorized
Expand All @@ -32,6 +34,9 @@ public enum ErrorType {
"잘못된 endpoint에 요청한 경우입니다."),
USER_NOT_FOUND_EXCEPTION(HttpStatus.NOT_FOUND, "UE5002",
"조회한 유저가 존재하지 않는 경우 입니다."),
NOT_FOUND_MISSION_CATEGORY_EXCEPTION(HttpStatus.NOT_FOUND, "UE5003", "존재하지 않는 미션 카테고리입니다"),
NOT_FOUND_MISSION_CONTENT(HttpStatus.NOT_FOUND, "UE5004", "해당 카테고리 미션이 존재하지 않습니다."),
NOT_FOUND_ROUND_MISSION(HttpStatus.NOT_FOUND, "UE5005", "해당 라운드 미션이 존재하지 않습니다."),

/**
* 406 Not Acceptable
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/universe/uni/repository/GameRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.universe.uni.repository;

import org.springframework.data.jpa.repository.JpaRepository;

import com.universe.uni.domain.entity.Couple;
import com.universe.uni.domain.entity.Game;

public interface GameRepository extends JpaRepository<Game, Long> {

boolean existsByCoupleAndEnable(Couple couple, boolean enable);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.universe.uni.repository;

import org.springframework.data.jpa.repository.JpaRepository;

import com.universe.uni.domain.entity.MissionCategory;

public interface MissionCategoryRepository extends JpaRepository<MissionCategory, Long> {
}
Loading

0 comments on commit 6d73cb0

Please sign in to comment.