기존 엔티티 수정

This commit is contained in:
byung eun park 2019-10-04 16:00:49 +09:00
parent e42d1b1908
commit 38b39255bf
21 changed files with 241 additions and 293 deletions

View File

@ -1,132 +0,0 @@
package com.totopia.server.modules.user.entity;
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
@Entity(name = "bank_account")
@SuperBuilder
public class BankAccountEntity extends UserDateAuditEntity {
private static final long serialVersionUID = -8628291684559836128L;
@Id
@GeneratedValue(generator = "bank_account_generator")
@SequenceGenerator(name = "bank_account_generator", sequenceName = "bank_account_sequence", initialValue = 1)
private Long id;
@Basic
@Column(name = "name", nullable = false, length = 100)
private String name;
@Basic
@Column(name = "number", nullable = false, length = 100)
private String number;
@Basic
@Column(name = "holder", nullable = false, length = 100)
private String holder;
@Basic
@Column(name = "userId", nullable = false)
private Long userId;
public BankAccountEntity(Long id, String name, String number, String holder, Long userId) {
this.id = id;
this.name = name;
this.number = number;
this.holder = holder;
this.userId = userId;
}
public BankAccountEntity() {
}
public Long getId() {
return this.id;
}
public String getName() {
return this.name;
}
public String getNumber() {
return this.number;
}
public String getHolder() {
return this.holder;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setNumber(String number) {
this.number = number;
}
public void setHolder(String holder) {
this.holder = holder;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String toString() {
return "BankAccountEntity(id=" + this.getId() + ", name=" + this.getName() + ", number=" + this.getNumber() + ", holder=" + this.getHolder() + ", username=" + this.getUserId() + ")";
}
public boolean equals(final Object o) {
if (o == this) return true;
if (!(o instanceof BankAccountEntity)) return false;
final BankAccountEntity other = (BankAccountEntity) o;
if (!other.canEqual((Object) this)) return false;
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) return false;
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false;
final Object this$number = this.getNumber();
final Object other$number = other.getNumber();
if (this$number == null ? other$number != null : !this$number.equals(other$number)) return false;
final Object this$holder = this.getHolder();
final Object other$holder = other.getHolder();
if (this$holder == null ? other$holder != null : !this$holder.equals(other$holder)) return false;
final Object this$userId = this.getUserId();
final Object other$userId = other.getUserId();
if (this$userId == null ? other$userId != null : !this$userId.equals(other$userId)) return false;
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof BankAccountEntity;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
final Object $number = this.getNumber();
result = result * PRIME + ($number == null ? 43 : $number.hashCode());
final Object $holder = this.getHolder();
result = result * PRIME + ($holder == null ? 43 : $holder.hashCode());
final Object $username = this.getUserId();
result = result * PRIME + ($username == null ? 43 : $username.hashCode());
return result;
}
}

View File

@ -0,0 +1,56 @@
package com.totopia.server.modules.user.entity;
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
import com.totopia.server.modules.user.type.StatusName;
import lombok.*;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
@Entity(name = "bank")
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Builder
public class BankEntity extends UserDateAuditEntity {
private static final long serialVersionUID = -8628291684559836128L;
@Id
@GeneratedValue(generator = "bank_generator")
@SequenceGenerator(name = "bank_generator", sequenceName = "bank_sequence", initialValue = 1)
private Long id;
@Basic
@Column(name = "userId", nullable = false)
private Long userId;
@Basic
@Column(name = "bank_account_id", nullable = false)
private Long bankAccountId;
@Basic
@Column(name = "name", nullable = false, length = 100)
private String name;
@Basic
@Column(name = "number", nullable = false, length = 100)
private String number;
@Basic
@Column(name = "holder", nullable = false, length = 100)
private String holder;
@Basic
@Column(name = "password", nullable = false, length = 100)
private String password;
@Basic
@Column(name = "status", nullable = false, length = 100)
private StatusName status;
}

View File

@ -7,7 +7,7 @@ import lombok.experimental.SuperBuilder;
import javax.persistence.*;
import java.io.Serializable;
@Entity(name = "deposit")
@Entity(name = "connection_history")
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor

View File

@ -1,13 +1,12 @@
package com.totopia.server.modules.user.entity;
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
import com.totopia.server.modules.user.type.ProcessingStatus;
import com.totopia.server.commons.data.entity.DateAuditEntity;
import com.totopia.server.modules.user.type.BankingName;
import lombok.*;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
@Entity(name = "deposit")
@SuperBuilder
@ -17,27 +16,28 @@ import java.util.Objects;
@Setter
@ToString
@Data
public class DepositEntity extends UserDateAuditEntity implements Serializable {
@Builder
public class DepositEntity extends DateAuditEntity implements Serializable {
@Id
@GeneratedValue(generator = "deposit_generator")
@SequenceGenerator(name = "deposit_generator", sequenceName = "deposit_sequence", initialValue = 1)
private Long id;
@Column(name = "amount_of_money", nullable = false)
private Integer amountOfMoney;
@Column(name = "price", nullable = false)
private Integer price;
@Column(name = "deposit_user", nullable = false)
private Long depositUser;
@Column(name = "approve_id", nullable = false)
private Long approve;
@Column(name = "confirm_user", nullable = false)
private Long confirmUser;
@Column(name = "bank_id", nullable = false)
private Long bank;
@Column(name = "bank_account", nullable = false)
private Long bankAccount;
private Short bankAccount;
@Enumerated(EnumType.STRING)
@Column(name = "status", length = 60)
private ProcessingStatus status;
private BankingName status;
}

View File

@ -2,6 +2,8 @@ package com.totopia.server.modules.user.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.totopia.server.commons.data.entity.DateAuditEntity;
import com.totopia.server.modules.user.type.LevelName;
import com.totopia.server.modules.user.type.StatusName;
import lombok.*;
import lombok.experimental.SuperBuilder;
@ -46,12 +48,16 @@ public class UserEntity extends DateAuditEntity {
private Boolean block = false;
@Basic
@Column(name = "send_email", nullable = false)
private Boolean sendEmail = true;
@Column(name = "ref_enable", nullable = false)
private Boolean refEnable = false;
@Basic
@Column(name = "activation", nullable = true, length = 100)
private String activation;
@Column(name = "ref_id", nullable = false)
private Long ref;
@Basic
@Column(name = "send_email", nullable = false)
private Boolean sendEmail = true;
@Basic
@Temporal(TemporalType.TIMESTAMP)
@ -75,10 +81,6 @@ public class UserEntity extends DateAuditEntity {
@Column(name = "otep", nullable = true, length = 1000)
private String otep;
@Basic
@Column(name = "require_reset", nullable = true)
private Boolean requireReset = false;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
private Set<RoleEntity> roles;
@ -88,8 +90,8 @@ public class UserEntity extends DateAuditEntity {
private Set<ConnectHistoryEntity> connectHistoryEntities;
@Basic
@Column(name = "grade", nullable = true)
private Short grade;
@Column(name = "grade_id", nullable = true)
private GradeEntity grade;
@Basic
@Column(name = "phone", nullable = true)
@ -98,6 +100,15 @@ public class UserEntity extends DateAuditEntity {
@Basic
@Column(name = "descriptions", nullable = true, length = 1000)
private String descriptions;
@Enumerated(EnumType.STRING)
@Column(name = "status_name", length = 60)
private StatusName statusName;
@Enumerated(EnumType.STRING)
@Column(name = "level_name", length = 60)
private LevelName levelName;
}
// 아이디

View File

@ -0,0 +1,41 @@
package com.totopia.server.modules.user.entity;
import com.totopia.server.commons.data.entity.DateAuditEntity;
import com.totopia.server.modules.user.type.BankingName;
import lombok.*;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
import java.io.Serializable;
@Entity(name = "withdrawal")
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
@Data
@Builder
public class WithdrawEntity extends DateAuditEntity implements Serializable {
@Id
@GeneratedValue(generator = "withdraw_generator")
@SequenceGenerator(name = "withdraw_generator", sequenceName = "withdraw_sequence", initialValue = 1)
private Long id;
@Column(name = "price", nullable = false)
private Integer price;
@Column(name = "approve_id", nullable = false)
private Long approve;
@Column(name = "bank_id", nullable = false)
private Long bank;
@Column(name = "bank_account", nullable = false)
private Short bankAccount;
@Enumerated(EnumType.STRING)
@Column(name = "status", length = 60)
private BankingName status;
}

View File

@ -1,40 +0,0 @@
package com.totopia.server.modules.user.entity;
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
import com.totopia.server.modules.user.type.ProcessingStatus;
import lombok.*;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
import java.io.Serializable;
@Entity(name = "withdrawal")
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
@Data
public class WithdrawalEntity extends UserDateAuditEntity implements Serializable {
@Id
@GeneratedValue(generator = "withdrawal_generator")
@SequenceGenerator(name = "withdrawal_generator", sequenceName = "withdrawal_sequence", initialValue = 1)
private Long id;
@Column(name = "amount_of_money", nullable = false)
private Integer amountOfMoney;
@Column(name = "deposit_user", nullable = false)
private Long withdrawalUser;
@Column(name = "confirm_user", nullable = false)
private Long confirmUser;
@Column(name = "bank_account", nullable = false)
private Long bankAccount;
@Enumerated(EnumType.STRING)
@Column(name = "status", length = 60)
private ProcessingStatus status;
}

View File

@ -1,8 +0,0 @@
package com.totopia.server.modules.user.repository;
import com.totopia.server.modules.user.entity.BankAccountEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface BankAccountRepository extends JpaRepository<BankAccountEntity, Long> {
}

View File

@ -0,0 +1,8 @@
package com.totopia.server.modules.user.repository;
import com.totopia.server.modules.user.entity.BankEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface BankRepository extends JpaRepository<BankEntity, Long> {
}

View File

@ -0,0 +1,7 @@
package com.totopia.server.modules.user.repository;
import com.totopia.server.modules.user.entity.WithdrawEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface WithdrawRepository extends JpaRepository<WithdrawEntity, Long> {
}

View File

@ -1,7 +0,0 @@
package com.totopia.server.modules.user.repository;
import com.totopia.server.modules.user.entity.WithdrawalEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface WithdrawalRepository extends JpaRepository<WithdrawalEntity, Long> {
}

View File

@ -0,0 +1,5 @@
package com.totopia.server.modules.user.type;
public enum BankingName {
BANKING_WAITING, BANKING_HOLD, BANKING_COMPLETE
}

View File

@ -0,0 +1,9 @@
package com.totopia.server.modules.user.type;
public enum LevelName {
LEVEL_1,
LEVEL_2,
LEVEL_3,
LEVEL_4,
LEVEL_5
}

View File

@ -1,5 +0,0 @@
package com.totopia.server.modules.user.type;
public enum ProcessingStatus {
PROCESSING_WAITING, PROCESSING_HOLD, PROCESSING_COMPLETE
}

View File

@ -0,0 +1,7 @@
package com.totopia.server.modules.user.type;
public enum StatusName {
USER_BLOCK, // 정지
USER_NORMAL, // 정상
USER_WITHDRAW // 탈퇴
}

View File

@ -26,7 +26,7 @@ spring:
initialization-mode: never
jpa:
hibernate:
ddl-auto: update
ddl-auto: create-drop
database: postgresql
show-sql: true
database-platform: org.hibernate.dialect.PostgreSQLDialect

View File

@ -1,6 +1,6 @@
package com.totopia.server.modules.user.repository;
import com.totopia.server.modules.user.entity.BankAccountEntity;
import com.totopia.server.modules.user.entity.BankEntity;
import com.totopia.server.modules.user.entity.UserEntity;
import org.junit.Before;
import org.junit.Ignore;
@ -14,19 +14,19 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
//@Ignore
@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest
public class BankAccountRepositoryTest {
public class BankRepositoryTest {
@Autowired
private UserRepository userRepository;
@Autowired
private BankAccountRepository bankAccountRepository;
private BankRepository bankRepository;
List<UserEntity> users;
List<BankAccountEntity> accounts = new ArrayList<>();
List<BankEntity> accounts = new ArrayList<>();
@Before
public void setUp() throws Exception {
@ -40,11 +40,11 @@ public class BankAccountRepositoryTest {
@Test
public void testInsert() {
BankAccountEntity bankAccount = null;
BankEntity bankAccount = null;
int idx = 0;
for (UserEntity user : users) {
bankAccount = new BankAccountEntity();
bankAccount = new BankEntity();
switch (idx) {
case 0:
@ -66,16 +66,16 @@ public class BankAccountRepositoryTest {
idx++;
bankAccount.setUserId(user.getId());
bankAccount.setUpdatedAt(new Date());
this.bankAccountRepository.save(bankAccount);
this.bankRepository.save(bankAccount);
}
}
@Test
public void testUpdate() {
List<BankAccountEntity> bankAccounts = this.bankAccountRepository.findAll();
List<BankEntity> bankAccounts = this.bankRepository.findAll();
int idx = 0;
for (BankAccountEntity account : bankAccounts) {
for (BankEntity account : bankAccounts) {
switch (idx) {
case 0:
@ -97,7 +97,7 @@ public class BankAccountRepositoryTest {
idx++;
account.setUserId(account.getId());
this.bankAccountRepository.save(account);
this.bankRepository.save(account);
}
}
}

View File

@ -1,9 +1,9 @@
package com.totopia.server.modules.user.repository;
import com.totopia.server.modules.user.entity.BankAccountEntity;
import com.totopia.server.modules.user.entity.BankEntity;
import com.totopia.server.modules.user.entity.DepositEntity;
import com.totopia.server.modules.user.entity.UserEntity;
import com.totopia.server.modules.user.type.ProcessingStatus;
import com.totopia.server.modules.user.type.BankingName;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@ -12,11 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest
@ -25,28 +22,29 @@ public class DepositRepositoryTest {
@Autowired
private UserRepository userRepository;
@Autowired
private BankAccountRepository bankAccountRepository;
private BankRepository bankRepository;
@Autowired
private DepositRepository depositRepository;
List<UserEntity> users;
List<BankAccountEntity> accounts;
List<BankEntity> accounts;
@Before
public void setUp() throws Exception {
users = this.userRepository.findAll();
accounts = this.bankAccountRepository.findAll();
accounts = this.bankRepository.findAll();
}
@Test
public void insertTest() throws Exception {
DepositEntity en = DepositEntity.builder()
.amountOfMoney(10000)
.bankAccount(accounts.get(2).getId())
.confirmUser(accounts.get(0).getId())
.depositUser(accounts.get(2).getId())
.status(ProcessingStatus.PROCESSING_HOLD)
.price(10000)
.bankAccount((short) 1)
.approve(accounts.get(0).getId())
.bank(accounts.get(2).getId())
.status(BankingName.BANKING_WAITING)
.build();
// DepositEntity entity = new DepositEntity();
@ -65,8 +63,8 @@ public class DepositRepositoryTest {
@Test
public void updateTest() throws Exception {
DepositEntity entity = this.depositRepository.findById(1L).orElse(null);
entity.setStatus(ProcessingStatus.PROCESSING_COMPLETE);
entity.setStatus(BankingName.BANKING_COMPLETE);
this.depositRepository.save(entity);
assertEquals(entity.getDepositUser().longValue(), 2L);
// assertEquals(entity.getDepositUser().longValue(), 2L);
}
}

View File

@ -17,7 +17,7 @@ import java.util.Optional;
import static org.junit.Assert.assertEquals;
//@Ignore
@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest
public class UserRepositoryTest {

View File

@ -0,0 +1,48 @@
package com.totopia.server.modules.user.repository;
import com.totopia.server.modules.user.entity.BankEntity;
import com.totopia.server.modules.user.entity.UserEntity;
import com.totopia.server.modules.user.entity.WithdrawEntity;
import com.totopia.server.modules.user.type.BankingName;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
public class WithdrawRepositoryTest {
@Autowired
private UserRepository userRepository;
@Autowired
private BankRepository bankRepository;
@Autowired
private WithdrawRepository withdrawRepository;
List<UserEntity> users;
List<BankEntity> accounts;
@Before
public void setUp() throws Exception {
users = this.userRepository.findAll();
accounts = this.bankRepository.findAll();
}
@Test
public void insertTest() throws Exception {
WithdrawEntity en = WithdrawEntity.builder()
.price(10000)
.bankAccount((short) 2)
.approve(accounts.get(0).getId())
.bank(accounts.get(2).getId())
.status(BankingName.BANKING_WAITING)
.build();
this.withdrawRepository.save(en);
}
}

View File

@ -1,50 +0,0 @@
package com.totopia.server.modules.user.repository;
import com.totopia.server.modules.user.entity.BankAccountEntity;
import com.totopia.server.modules.user.entity.UserEntity;
import com.totopia.server.modules.user.entity.WithdrawalEntity;
import com.totopia.server.modules.user.type.ProcessingStatus;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest
public class WithdrawalRepositoryTest {
@Autowired
private UserRepository userRepository;
@Autowired
private BankAccountRepository bankAccountRepository;
@Autowired
private WithdrawalRepository withdrawalRepository;
List<UserEntity> users;
List<BankAccountEntity> accounts;
@Before
public void setUp() throws Exception {
users = this.userRepository.findAll();
accounts = this.bankAccountRepository.findAll();
}
@Test
public void insertTest() throws Exception {
WithdrawalEntity en = WithdrawalEntity.builder()
.amountOfMoney(10000)
.bankAccount(accounts.get(2).getId())
.confirmUser(accounts.get(0).getId())
.withdrawalUser(accounts.get(2).getId())
.status(ProcessingStatus.PROCESSING_WAITING)
.build();
this.withdrawalRepository.save(en);
}
}