Skip to content

Commit

Permalink
Merge pull request #19 from softeerbootcamp4th/feat#11-Create-Casper-Bot
Browse files Browse the repository at this point in the history
Feat#11 create casper bot
  • Loading branch information
k000927 authored Jul 30, 2024
2 parents 61278f2 + cfd48e9 commit 5ac96e5
Show file tree
Hide file tree
Showing 21 changed files with 367 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/Server/build/
/Server/src/main/resources/application.properties
/.idea/
/Server/out/
30 changes: 17 additions & 13 deletions Server/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.2'
id 'io.spring.dependency-management' version '1.1.6'
id 'java'
id 'org.springframework.boot' version '3.3.2'
id 'io.spring.dependency-management' version '1.1.6'
}

group = 'JGS'
version = '0.0.1-SNAPSHOT'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.google.code.gson:gson:2.9.0'

runtimeOnly 'com.h2database:h2'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
package JGS.CasperEvent.domain.event.controller.eventController;

import JGS.CasperEvent.domain.event.dto.GetCasperBot;
import JGS.CasperEvent.domain.event.service.eventService.LotteryEventService;
import JGS.CasperEvent.global.response.CustomResponse;
import org.springframework.beans.factory.annotation.Autowired;
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;

@RestController
@RequestMapping("/event/lottery")
public class LotteryEventController {

private final LotteryEventService lotteryEventService;

@Autowired
public LotteryEventController(LotteryEventService lotteryEventService) {
this.lotteryEventService = lotteryEventService;
}

@PostMapping
public CustomResponse<GetCasperBot> postCasperBot(@RequestBody String body) {
return CustomResponse.create(lotteryEventService.postCasperBot(body));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package JGS.CasperEvent.domain.event.entity.admin;

import JGS.CasperEvent.global.entity.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;

@Entity
public class Admin extends BaseEntity {
@Id
private String adminId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import JGS.CasperEvent.domain.event.entity.casperBot.casperEnum.*;
import JGS.CasperEvent.global.entity.BaseEntity;
import com.google.gson.annotations.SerializedName;
import jakarta.persistence.*;

import static jakarta.persistence.GenerationType.IDENTITY;
Expand All @@ -15,18 +16,23 @@ public class CasperBot extends BaseEntity {

private String phoneNumber;

@SerializedName("eyeShape")
@Enumerated(EnumType.STRING)
private EyeShape eyeShape;

@SerializedName("eyePosition")
@Enumerated(EnumType.STRING)
private EyePosition eyePosition;

@SerializedName("mouthShape")
@Enumerated(EnumType.STRING)
private MouthShape mouthShape;

@SerializedName("color")
@Enumerated(EnumType.STRING)
private Color color;

@SerializedName("sticker")
@Enumerated(EnumType.STRING)
private Sticker sticker;
private String name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
package JGS.CasperEvent.domain.event.entity.casperBot.casperEnum;

import com.google.gson.annotations.SerializedName;

public enum Color {
@SerializedName("1")
BUTTERCREAM_YELLOW_PEARL(1),
@SerializedName("2")
SIENNA_ORANGE_METALLIC(2),
@SerializedName("3")
DUSK_BLUE_MATT(3),
@SerializedName("4")
AERO_SILVER_MATT(4),
@SerializedName("5")
ABYSS_BLACK_PEARL(5),
@SerializedName("6")
LIME_GREEN(6),
@SerializedName("7")
TEAL_GREEN(7),
@SerializedName("8")
LIGHT_BLUE(8),
@SerializedName("9")
SKY_BLUE(9),
@SerializedName("10")
INDIGO(10),
@SerializedName("11")
DEEP_PURPLE(11),
@SerializedName("12")
PURPLE(12),
@SerializedName("13")
MAGENTA(13),
@SerializedName("14")
RED(14),
@SerializedName("15")
ORANGE(15),
@SerializedName("16")
GOLD(16),
@SerializedName("17")
YELLOW(17);

private final int color;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package JGS.CasperEvent.domain.event.entity.casperBot.casperEnum;

import com.google.gson.annotations.SerializedName;

public enum EyePosition {
@SerializedName("1")
CENTER(1),
@SerializedName("2")
LEFT(2),
@SerializedName("3")
RIGHT(3);

private final int eyePosition;

EyePosition(int eyePosition)
{
EyePosition(int eyePosition) {
this.eyePosition = eyePosition;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
package JGS.CasperEvent.domain.event.entity.casperBot.casperEnum;

import com.google.gson.annotations.SerializedName;

public enum EyeShape {
@SerializedName("1")
ALLOY_WHEEL_15(1),
@SerializedName("2")
ALLOY_WHEEL_17(2),
@SerializedName("3")
PIXEL_BY_PIXEL(3),
@SerializedName("4")
ELECTRIC(4),
@SerializedName("5")
GLASSY(5),
@SerializedName("6")
SMILE(6),
@SerializedName("7")
CUTE(7),
@SerializedName("8")
HEART(8);

private final int eyeShape;

EyeShape(int eyeShape)
{
EyeShape(int eyeShape) {
this.eyeShape = eyeShape;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package JGS.CasperEvent.domain.event.entity.casperBot.casperEnum;

import com.google.gson.annotations.SerializedName;

public enum MouthShape {
@SerializedName("1")
SMILING(1),
@SerializedName("2")
DISPLEASED(2),
@SerializedName("3")
GRINNING(3),
@SerializedName("4")
BEAMING(4),
@SerializedName("5")
NEUTRAL(5);

private final int mouthShape;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package JGS.CasperEvent.domain.event.entity.casperBot.casperEnum;

import com.google.gson.annotations.SerializedName;

public enum Sticker {
@SerializedName("1")
ELECTRIC_SHOCK(1),
@SerializedName("2")
FULL_CHARGE(2),
@SerializedName("3")
BATTERY_BLINKING(3),
@SerializedName("4")
LOVELY_RIBBON(4),
@SerializedName("5")
SPARKLING(5);

private final int sticker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.util.Set;

@Entity
public class LotteryEvent extends BaseEvent {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.util.Set;

@Entity
public class RushEvent extends BaseEvent {
private String prizeImageUrl;
private String prizeDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

import JGS.CasperEvent.global.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;

@Entity
public class RushOption extends BaseEntity{

@Column(name = "rush_event_id")
private Long rushEventId;

@Id
private int optionId;
private String mainText;
private String subText;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package JGS.CasperEvent.domain.event.entity.participants;

import JGS.CasperEvent.domain.event.entity.event.LotteryEvent;
import JGS.CasperEvent.global.entity.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

public class LotteryParticipants extends BaseParticipant{
@Entity
public class LotteryParticipants extends BaseEntity {
private int linkClickedCount;
private int expectations;

@ManyToOne
@JoinColumn(name="lottery_event_id")
private Long lotteryEventId;
private LotteryEvent lotteryEvent;

@Id
private String phoneNumber;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package JGS.CasperEvent.domain.event.entity.participants;

import JGS.CasperEvent.domain.event.entity.event.RushEvent;
import JGS.CasperEvent.global.entity.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

public class RushParticipants extends BaseParticipant{
@Entity
public class RushParticipants extends BaseEntity {
private int choice;

@ManyToOne
@JoinColumn(name = "rush_event_id")
private Long rushEventId;
private RushEvent rushEvent;

@Id
private String phoneNumber;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
package JGS.CasperEvent.domain.event.service.eventService;

import JGS.CasperEvent.domain.event.dto.GetCasperBot;
import JGS.CasperEvent.domain.event.entity.casperBot.CasperBot;
import JGS.CasperEvent.domain.event.repository.eventRepository.LotteryEventRepository;
import com.google.gson.Gson;
import org.springframework.stereotype.Service;

import static JGS.CasperEvent.global.util.GsonUtil.getGson;

@Service
public class LotteryEventService {
private LotteryEventRepository lotteryEventRepository;

public GetCasperBot postCasperBot(String body) {
Gson gson = getGson();
CasperBot casperBot = gson.fromJson(body, CasperBot.class);
return GetCasperBot.of(casperBot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ public record CustomResponse<T> (int statusCode, String message, T result){
public static <T> CustomResponse<T> success(T result){
return new CustomResponse<>(200, "요청에 성공하였습니다.", result);
}

public static <T> CustomResponse<T> create(T result){
return new CustomResponse<>(201, "생성에 성공하였습니다", result);
}
}

Loading

0 comments on commit 5ac96e5

Please sign in to comment.