Skip to content

Commit

Permalink
Merge pull request #3 from lsn5963/feat/init_settings
Browse files Browse the repository at this point in the history
[FEAT] 기초세팅
  • Loading branch information
lsn5963 authored Jul 29, 2024
2 parents d7a4409 + 652f913 commit b22c292
Show file tree
Hide file tree
Showing 27 changed files with 541 additions and 2 deletions.
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

/src/main/resources/auth/
/src/main/resources/database/
### MAC ###
.DS_Store

### ELSE ###
application.yml
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
// implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
// implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.noplanb.domain.character.application;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class CharacterService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.noplanb.domain.character.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequiredArgsConstructor
@RequestMapping("/api/v1")
@Tag(name = "CharacterController", description = "CharacterController입니다.")
public class CharacterController {
}
44 changes: 44 additions & 0 deletions src/main/java/com/noplanb/domain/character/domain/Character.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.noplanb.domain.character.domain;

import com.noplanb.domain.common.BaseEntity;
import com.noplanb.domain.item.domain.Item;
import com.noplanb.domain.quest.domain.Quest;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

import static jakarta.persistence.GenerationType.IDENTITY;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "character_entity")
public class Character extends BaseEntity {
@Id
@GeneratedValue(strategy = IDENTITY)
private Long id;
private String characterName;
private Long totalExp;
private Long totalQuest;
private Long todayExp;
private Long level;
@OneToMany(mappedBy = "character")
private List<Quest> quests = new ArrayList<>();
@OneToMany(mappedBy = "character")
private List<Item> items = new ArrayList<>();

public void addQuest(Quest quest){
this.quests.add(quest);
quest.updateCharacter(this);

}
public void addItem(Item item){
this.items.add(item);
item.updateCharacter(this);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.noplanb.domain.character.repository;

import com.noplanb.domain.character.domain.Character;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface CharacterRepository extends JpaRepository<Character,Long> {
}
32 changes: 32 additions & 0 deletions src/main/java/com/noplanb/domain/common/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.noplanb.domain.common;

import jakarta.persistence.*;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseEntity {

@CreatedDate
@Column(updatable=false)
private LocalDateTime createdAt;

@LastModifiedDate
private LocalDateTime modifiedAt;

@Enumerated(value = EnumType.STRING)
private Status status = Status.ACTIVE;

public void updateStatus(Status status){
this.status = status;
}



}
6 changes: 6 additions & 0 deletions src/main/java/com/noplanb/domain/common/Status.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.noplanb.domain.common;

public enum Status {
ACTIVE,
DELETED
}
11 changes: 11 additions & 0 deletions src/main/java/com/noplanb/domain/item/application/ItemService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.noplanb.domain.item.application;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class ItemService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.noplanb.domain.item.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequiredArgsConstructor
@RequestMapping("/api/v1")
@Tag(name = "ItemController", description = "ItemControllerController입니다.")
public class ItemController {
}
32 changes: 32 additions & 0 deletions src/main/java/com/noplanb/domain/item/domain/Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.noplanb.domain.item.domain;

import com.noplanb.domain.character.domain.Character;
import com.noplanb.domain.common.BaseEntity;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static jakarta.persistence.GenerationType.IDENTITY;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Item extends BaseEntity {
@Id
@GeneratedValue(strategy = IDENTITY)
private Long id;
private String item_name;
@Enumerated(EnumType.STRING)
private ItemType itemType;
@Enumerated(EnumType.STRING)
private ItemStatus itemStatus;
private Long requiredLevel;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "character_id")
private Character character;

public void updateCharacter(Character character) {
this.character = character;
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/noplanb/domain/item/domain/ItemStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.noplanb.domain.item.domain;

public enum ItemStatus {
EQUIP,
UNEQUIP
}
8 changes: 8 additions & 0 deletions src/main/java/com/noplanb/domain/item/domain/ItemType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.noplanb.domain.item.domain;

public enum ItemType {
HEAD,
FACE,
CLOTHES,
BACKGROUND
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.noplanb.domain.item.repository;

import com.noplanb.domain.item.domain.Item;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface ItemRepository extends JpaRepository<Item,Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.noplanb.domain.quest.application;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class QuestService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.noplanb.domain.quest.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequiredArgsConstructor
@RequestMapping("/api/v1")
@Tag(name = "QuestController", description = "QuestControllerController입니다.")
public class QuestController {
}
29 changes: 29 additions & 0 deletions src/main/java/com/noplanb/domain/quest/domain/Quest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.noplanb.domain.quest.domain;

import com.noplanb.domain.character.domain.Character;
import com.noplanb.domain.common.BaseEntity;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static jakarta.persistence.GenerationType.IDENTITY;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Quest extends BaseEntity {
@Id
@GeneratedValue(strategy = IDENTITY)
private Long id;
private String contents;
private Long exp;
private Boolean isComplete;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "character_id")
private Character character;

public void updateCharacter(Character character) {
this.character = character;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.noplanb.domain.quest.repository;

import com.noplanb.domain.quest.domain.Quest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface QuestRepository extends JpaRepository<Quest,Long> {
}
11 changes: 11 additions & 0 deletions src/main/java/com/noplanb/domain/user/application/UserService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.noplanb.domain.user.application;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class UserService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.noplanb.domain.user.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequiredArgsConstructor
@RequestMapping("/api/v1")
@Tag(name = "UserController", description = "UserControllerController입니다.")
public class UserController {
}
26 changes: 26 additions & 0 deletions src/main/java/com/noplanb/domain/user/domain/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.noplanb.domain.user.domain;

import com.noplanb.domain.character.domain.Character;
import com.noplanb.domain.common.BaseEntity;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static jakarta.persistence.GenerationType.IDENTITY;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class User extends BaseEntity {
@Id
@GeneratedValue(strategy = IDENTITY)
private Long id;
private String name;
private String email;
private String password;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "character_id", unique = true)
private Character character;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.noplanb.domain.user.repository;

import com.noplanb.domain.user.domain.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends JpaRepository<User,Long> {
}
Loading

0 comments on commit b22c292

Please sign in to comment.