diff --git a/src/main/java/com/totopia/server/init/DbInitializer.java b/src/main/java/com/totopia/server/init/DbInitializer.java index a616780..8ba1f1f 100644 --- a/src/main/java/com/totopia/server/init/DbInitializer.java +++ b/src/main/java/com/totopia/server/init/DbInitializer.java @@ -6,8 +6,8 @@ import com.totopia.server.modules.game.entity.SportsEntity; import com.totopia.server.modules.game.repository.LeagueRepository; import com.totopia.server.modules.game.repository.SportsRepository; import com.totopia.server.modules.game.type.SportsName; -import com.totopia.server.modules.site.entity.BankInfoEntity; -import com.totopia.server.modules.site.repository.BankInfoRepository; +import com.totopia.server.modules.site.entity.BankAccountsEntity; +import com.totopia.server.modules.site.repository.BankAccountsRepository; import com.totopia.server.modules.user.entity.GradeEntity; import com.totopia.server.modules.user.entity.RoleEntity; import com.totopia.server.modules.user.entity.UserEntity; @@ -54,7 +54,7 @@ public class DbInitializer implements CommandLineRunner { LeagueRepository leagueRepository; @Autowired - BankInfoRepository bankInfoRepository; + BankAccountsRepository bankInfoRepository; @Override public void run(String... strings) throws Exception { @@ -414,9 +414,9 @@ public class DbInitializer implements CommandLineRunner { } private void initDbBankInfo() { - BankInfoEntity bankInfoEntity; + BankAccountsEntity bankInfoEntity; - bankInfoEntity = BankInfoEntity.builder() + bankInfoEntity = BankAccountsEntity.builder() .name("국민은행") .number("11111-11-11111") .holder("테스트1") @@ -424,7 +424,7 @@ public class DbInitializer implements CommandLineRunner { .build(); bankInfoRepository.save(bankInfoEntity); - bankInfoEntity = BankInfoEntity.builder() + bankInfoEntity = BankAccountsEntity.builder() .name("우리은행") .number("22222-22-22222") .holder("테스트2") @@ -432,7 +432,7 @@ public class DbInitializer implements CommandLineRunner { .build(); bankInfoRepository.save(bankInfoEntity); - bankInfoEntity = BankInfoEntity.builder() + bankInfoEntity = BankAccountsEntity.builder() .name("기업은행") .number("33333-33-33333") .holder("테스트3") @@ -440,7 +440,7 @@ public class DbInitializer implements CommandLineRunner { .build(); bankInfoRepository.save(bankInfoEntity); - bankInfoEntity = BankInfoEntity.builder() + bankInfoEntity = BankAccountsEntity.builder() .name("신한은행") .number("44444-44-444444") .holder("테스트4") @@ -448,7 +448,7 @@ public class DbInitializer implements CommandLineRunner { .build(); bankInfoRepository.save(bankInfoEntity); - bankInfoEntity = BankInfoEntity.builder() + bankInfoEntity = BankAccountsEntity.builder() .name("국민은행") .number("55555-55-55555") .holder("테스트5") diff --git a/src/main/java/com/totopia/server/modules/site/controller/BankInfoController.java b/src/main/java/com/totopia/server/modules/site/controller/BankAccountsController.java similarity index 62% rename from src/main/java/com/totopia/server/modules/site/controller/BankInfoController.java rename to src/main/java/com/totopia/server/modules/site/controller/BankAccountsController.java index ca25753..7c41fb2 100644 --- a/src/main/java/com/totopia/server/modules/site/controller/BankInfoController.java +++ b/src/main/java/com/totopia/server/modules/site/controller/BankAccountsController.java @@ -1,9 +1,8 @@ package com.totopia.server.modules.site.controller; import com.totopia.server.commons.data.payload.ApiResponse; -import com.totopia.server.modules.game.entity.LeagueEntity; -import com.totopia.server.modules.site.entity.BankInfoEntity; -import com.totopia.server.modules.site.service.BankInfoService; +import com.totopia.server.modules.site.entity.BankAccountsEntity; +import com.totopia.server.modules.site.service.BankAccountsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -17,38 +16,38 @@ import javax.validation.Valid; import java.util.List; @RestController -public class BankInfoController { +public class BankAccountsController { @Autowired - BankInfoService bankInfoService; + BankAccountsService bankAccountsService; @GetMapping(value = "/bank_info") - public Page all( + public Page all( @SortDefault.SortDefaults({ @SortDefault( sort = "id", direction = Sort.Direction.ASC) }) Pageable pageable) { - return this.bankInfoService.getAllBankInfo(pageable); + return this.bankAccountsService.getAllBankInfo(pageable); } @GetMapping(value = "/bank_info/test") - public List allTest() { + public List allTest() { - return this.bankInfoService.getAllBankInfoTest(); + return this.bankAccountsService.getAllBankInfoTest(); } @PostMapping(value = "/bank_info") @ResponseStatus(code = HttpStatus.CREATED) - public ResponseEntity save(@Valid @RequestBody BankInfoEntity bankInfoEntity) throws Exception{ - this.bankInfoService.save(bankInfoEntity); + public ResponseEntity save(@Valid @RequestBody BankAccountsEntity bankInfoEntity) throws Exception{ + this.bankAccountsService.save(bankInfoEntity); return ResponseEntity.ok().body(new ApiResponse(true, "BankInfo registered successfully")); } @PutMapping(value = "/bank_info/{bankInfoId}") - public ResponseEntity updateLeague(@PathVariable Long bankInfoId, BankInfoEntity bankInfoEntity) throws Exception { - BankInfoEntity leagueEntity1 = this.bankInfoService.modify(bankInfoEntity); + public ResponseEntity updateLeague(@PathVariable Long bankInfoId, BankAccountsEntity bankInfoEntity) throws Exception { + BankAccountsEntity leagueEntity1 = this.bankAccountsService.modify(bankInfoEntity); return ResponseEntity.ok(leagueEntity1); } } diff --git a/src/main/java/com/totopia/server/modules/site/entity/BankInfoEntity.java b/src/main/java/com/totopia/server/modules/site/entity/BankAccountsEntity.java similarity index 76% rename from src/main/java/com/totopia/server/modules/site/entity/BankInfoEntity.java rename to src/main/java/com/totopia/server/modules/site/entity/BankAccountsEntity.java index 217d997..05e0020 100644 --- a/src/main/java/com/totopia/server/modules/site/entity/BankInfoEntity.java +++ b/src/main/java/com/totopia/server/modules/site/entity/BankAccountsEntity.java @@ -14,10 +14,10 @@ import javax.persistence.*; @AllArgsConstructor @EqualsAndHashCode(callSuper = false) @Builder -public class BankInfoEntity extends DateAuditEntity { +public class BankAccountsEntity extends DateAuditEntity { @Id - @GeneratedValue(generator = "bank_info_generator") - @SequenceGenerator(name = "bank_info_generator", sequenceName = "bank_info_sequence", initialValue = 1) + @GeneratedValue(generator = "bank_accounts_generator") + @SequenceGenerator(name = "bank_accounts_generator", sequenceName = "bank_accounts_sequence", initialValue = 1) private Short id; @Basic diff --git a/src/main/java/com/totopia/server/modules/site/repository/BankAccountsRepository.java b/src/main/java/com/totopia/server/modules/site/repository/BankAccountsRepository.java new file mode 100644 index 0000000..bb447ec --- /dev/null +++ b/src/main/java/com/totopia/server/modules/site/repository/BankAccountsRepository.java @@ -0,0 +1,7 @@ +package com.totopia.server.modules.site.repository; + +import com.totopia.server.modules.site.entity.BankAccountsEntity; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface BankAccountsRepository extends JpaRepository { +} diff --git a/src/main/java/com/totopia/server/modules/site/repository/BankInfoRepository.java b/src/main/java/com/totopia/server/modules/site/repository/BankInfoRepository.java deleted file mode 100644 index 73e8e40..0000000 --- a/src/main/java/com/totopia/server/modules/site/repository/BankInfoRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.totopia.server.modules.site.repository; - -import com.totopia.server.modules.site.entity.BankInfoEntity; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface BankInfoRepository extends JpaRepository { -} diff --git a/src/main/java/com/totopia/server/modules/site/service/BankAccountsService.java b/src/main/java/com/totopia/server/modules/site/service/BankAccountsService.java new file mode 100644 index 0000000..b8fae02 --- /dev/null +++ b/src/main/java/com/totopia/server/modules/site/service/BankAccountsService.java @@ -0,0 +1,54 @@ +package com.totopia.server.modules.site.service; + +import com.totopia.server.commons.exception.ResourceNotFoundException; +import com.totopia.server.modules.site.entity.BankAccountsEntity; +import com.totopia.server.modules.site.repository.BankAccountsRepository; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@Slf4j +public class BankAccountsService { + + @Autowired + BankAccountsRepository bankAccountsRepository; + + public BankAccountsEntity save(BankAccountsEntity entity) { + return this.bankAccountsRepository.save(entity); + } + + public BankAccountsEntity modify(BankAccountsEntity entity) { + if(entity == null || entity.getId() == 0) { + log.error("id is not null"); + } + + return this.bankAccountsRepository.save(entity); + } + + public Short removeById(Short bankInfoId) { + return bankAccountsRepository.findById(bankInfoId).map(bankInfo -> { + bankAccountsRepository.delete(bankInfo); + return bankInfoId; + }).orElseThrow(() -> new ResourceNotFoundException("BankInfoEntity", "bankInfoId", bankInfoId)); + } + + public Page getAllBankInfo(Pageable pageable) { + + return this.bankAccountsRepository.findAll(pageable); + } + + public List getAllBankInfoTest() { + + + return this.bankAccountsRepository.findAll(); + } + + public BankAccountsEntity getBankInfoById(Short bankInfoId) { + return this.bankAccountsRepository.findById(bankInfoId).orElseThrow(null); + } +} diff --git a/src/main/java/com/totopia/server/modules/site/service/BankInfoService.java b/src/main/java/com/totopia/server/modules/site/service/BankInfoService.java deleted file mode 100644 index 0775bd0..0000000 --- a/src/main/java/com/totopia/server/modules/site/service/BankInfoService.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.totopia.server.modules.site.service; - -import com.totopia.server.commons.exception.ResourceNotFoundException; -import com.totopia.server.modules.site.entity.BankInfoEntity; -import com.totopia.server.modules.site.repository.BankInfoRepository; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -@Slf4j -public class BankInfoService { - - @Autowired - BankInfoRepository bankInfoRepository; - - public BankInfoEntity save(BankInfoEntity entity) { - return this.bankInfoRepository.save(entity); - } - - public BankInfoEntity modify(BankInfoEntity entity) { - if(entity == null || entity.getId() == 0) { - log.error("id is not null"); - } - - return this.bankInfoRepository.save(entity); - } - - public Short removeById(Short bankInfoId) { - return bankInfoRepository.findById(bankInfoId).map(bankInfo -> { - bankInfoRepository.delete(bankInfo); - return bankInfoId; - }).orElseThrow(() -> new ResourceNotFoundException("BankInfoEntity", "bankInfoId", bankInfoId)); - } - - public Page getAllBankInfo(Pageable pageable) { - - return this.bankInfoRepository.findAll(pageable); - } - - public List getAllBankInfoTest() { - - - return this.bankInfoRepository.findAll(); - } - - public BankInfoEntity getBankInfoById(Short bankInfoId) { - return this.bankInfoRepository.findById(bankInfoId).orElseThrow(null); - } -} diff --git a/src/main/java/com/totopia/server/modules/user/entity/BankEntity.java b/src/main/java/com/totopia/server/modules/user/entity/BankEntity.java index 0b324b7..fc774de 100644 --- a/src/main/java/com/totopia/server/modules/user/entity/BankEntity.java +++ b/src/main/java/com/totopia/server/modules/user/entity/BankEntity.java @@ -1,6 +1,6 @@ package com.totopia.server.modules.user.entity; -import com.totopia.server.commons.data.entity.UserDateAuditEntity; +import com.totopia.server.commons.data.entity.DateAuditEntity; import com.totopia.server.modules.user.type.StatusName; import lombok.*; import lombok.experimental.SuperBuilder; @@ -14,7 +14,7 @@ import javax.persistence.*; @AllArgsConstructor @EqualsAndHashCode(callSuper = false) @Builder -public class BankEntity extends UserDateAuditEntity { +public class BankEntity extends DateAuditEntity { private static final long serialVersionUID = -8628291684559836128L; @@ -24,7 +24,7 @@ public class BankEntity extends UserDateAuditEntity { private Long id; @Basic - @Column(name = "userId", nullable = false) + @Column(name = "user_id", nullable = false) private Long userId; @Basic diff --git a/src/main/java/com/totopia/server/modules/user/entity/CommissionEntity.java b/src/main/java/com/totopia/server/modules/user/entity/CommissionEntity.java new file mode 100644 index 0000000..9f78b77 --- /dev/null +++ b/src/main/java/com/totopia/server/modules/user/entity/CommissionEntity.java @@ -0,0 +1,54 @@ +package com.totopia.server.modules.user.entity; + +import com.totopia.server.commons.data.entity.UserDateAuditEntity; +import com.totopia.server.modules.user.type.CommissionName; +import lombok.*; +import lombok.experimental.SuperBuilder; + +import javax.persistence.*; + +@Entity(name = "commission") +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +@Builder +public class CommissionEntity extends UserDateAuditEntity { + @Id + @GeneratedValue(generator = "commission_generator") + @SequenceGenerator(name = "commission_generator", sequenceName = "commission_sequence", initialValue = 1) + private Long id; + + @Basic + @Column(name = "user_id", nullable = false) + private Long userId; + + @Basic + @Column(name = "banking_fees", nullable = false) + private Float bankingFees; + + @Basic + @Column(name = "sports_fees", nullable = false) + private Float sportsFees; + + @Basic + @Column(name = "mini_game_fees", nullable = false, length = 100) + private Float miniGameFees; + + @Basic + @Column(name = "rotus_fees", nullable = false, length = 100) + private Float rotusFees; + + @Basic + @Column(name = "sports_raffle_fees", nullable = false, length = 100) + private Float sportsRaffleFees; + + @Basic + @Column(name = "mini_game_raffle_fees", nullable = false, length = 100) + private String miniGameRaffleFees; + + @Enumerated(EnumType.STRING) + @Column(name = "type", length = 60) + private CommissionName type; +} diff --git a/src/main/java/com/totopia/server/modules/user/entity/ConnectHistoryEntity.java b/src/main/java/com/totopia/server/modules/user/entity/ConnectHistoryEntity.java index 6e98b89..6190030 100644 --- a/src/main/java/com/totopia/server/modules/user/entity/ConnectHistoryEntity.java +++ b/src/main/java/com/totopia/server/modules/user/entity/ConnectHistoryEntity.java @@ -23,6 +23,15 @@ public class ConnectHistoryEntity extends DateAuditEntity implements Serializabl private Long id; @Basic - @Column(name = "activation", nullable = true, length = 100) + @Column(name = "user_id", nullable = false) + private Long userId; + + @Basic + @Column(name = "ip", nullable = true, length = 100) private String ip; + + @Basic + @Column(name = "location", nullable = true, length = 100) + private String location; + } diff --git a/src/main/java/com/totopia/server/modules/user/entity/DepositEntity.java b/src/main/java/com/totopia/server/modules/user/entity/DepositEntity.java index f004b72..df1400d 100644 --- a/src/main/java/com/totopia/server/modules/user/entity/DepositEntity.java +++ b/src/main/java/com/totopia/server/modules/user/entity/DepositEntity.java @@ -24,18 +24,23 @@ public class DepositEntity extends DateAuditEntity implements Serializable { @SequenceGenerator(name = "deposit_generator", sequenceName = "deposit_sequence", initialValue = 1) private Long id; + @Basic @Column(name = "price", nullable = false) private Integer price; - @Column(name = "approve_id", nullable = false) - private Long approve; + @Basic + @Column(name = "approve_user_id", nullable = false) + private Long approveUser; + @Basic @Column(name = "bank_id", nullable = false) private Long bank; + @Basic @Column(name = "bank_account", nullable = false) private Short bankAccount; + @Basic @Enumerated(EnumType.STRING) @Column(name = "status", length = 60) private BankingName status; diff --git a/src/main/java/com/totopia/server/modules/user/entity/PayDoneEntity.java b/src/main/java/com/totopia/server/modules/user/entity/PayDoneEntity.java new file mode 100644 index 0000000..c87be85 --- /dev/null +++ b/src/main/java/com/totopia/server/modules/user/entity/PayDoneEntity.java @@ -0,0 +1,31 @@ +package com.totopia.server.modules.user.entity; + +import com.totopia.server.commons.data.entity.UserDateAuditEntity; +import lombok.*; +import lombok.experimental.SuperBuilder; + +import javax.persistence.*; + +@Entity(name = "pay_done") +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +@Builder +@AttributeOverrides({ + @AttributeOverride(name = "createdAt", column = @Column(name = "payments_date")), + @AttributeOverride(name = "createdBy", column = @Column(name = "approve_user_id")), +}) +public class PayDoneEntity extends UserDateAuditEntity { + + @Id + @GeneratedValue(generator = "pay_done_generator") + @SequenceGenerator(name = "pay_done_generator", sequenceName = "pay_done_sequence", initialValue = 1) + private Long id; + + @Basic + @Column(name = "settle_user_id", nullable = false) + private Long settleUser; + +} diff --git a/src/main/java/com/totopia/server/modules/user/entity/PayEntity.java b/src/main/java/com/totopia/server/modules/user/entity/PayEntity.java new file mode 100644 index 0000000..93e0d6b --- /dev/null +++ b/src/main/java/com/totopia/server/modules/user/entity/PayEntity.java @@ -0,0 +1,41 @@ +package com.totopia.server.modules.user.entity; + +import com.totopia.server.commons.data.entity.UserDateAuditEntity; +import com.totopia.server.modules.user.type.BankingName; +import lombok.*; +import lombok.experimental.SuperBuilder; + +import javax.persistence.*; + +@Entity(name = "pay") +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +@Builder +public class PayEntity extends UserDateAuditEntity { + + @Id + @GeneratedValue(generator = "pay_generator") + @SequenceGenerator(name = "pay_generator", sequenceName = "pay_sequence", initialValue = 1) + private Long id; + + @Basic + @Column(name = "belong_user_id", nullable = false) + private Long belongUser; + + @Basic + @Column(name = "banking_user_id", nullable = false) + private Long bankingUser; + + @Basic + @Column(name = "price", nullable = false) + private Integer price; + + @Basic + @Enumerated(EnumType.STRING) + @Column(name = "banking_type", length = 60) + private BankingName bankingType; + +} diff --git a/src/main/java/com/totopia/server/modules/user/entity/WithdrawEntity.java b/src/main/java/com/totopia/server/modules/user/entity/WithdrawEntity.java index 67f8847..18ee1a7 100644 --- a/src/main/java/com/totopia/server/modules/user/entity/WithdrawEntity.java +++ b/src/main/java/com/totopia/server/modules/user/entity/WithdrawEntity.java @@ -23,18 +23,23 @@ public class WithdrawEntity extends DateAuditEntity implements Serializable { @SequenceGenerator(name = "withdraw_generator", sequenceName = "withdraw_sequence", initialValue = 1) private Long id; + @Basic @Column(name = "price", nullable = false) private Integer price; - @Column(name = "approve_id", nullable = false) - private Long approve; + @Basic + @Column(name = "approve_user_id", nullable = false) + private Long approveUser; + @Basic @Column(name = "bank_id", nullable = false) private Long bank; + @Basic @Column(name = "bank_account", nullable = false) private Short bankAccount; + @Basic @Enumerated(EnumType.STRING) @Column(name = "status", length = 60) private BankingName status; diff --git a/src/main/java/com/totopia/server/modules/user/type/BankingName.java b/src/main/java/com/totopia/server/modules/user/type/BankingName.java index 059c7b6..56ab675 100644 --- a/src/main/java/com/totopia/server/modules/user/type/BankingName.java +++ b/src/main/java/com/totopia/server/modules/user/type/BankingName.java @@ -1,5 +1,5 @@ package com.totopia.server.modules.user.type; public enum BankingName { - BANKING_WAITING, BANKING_HOLD, BANKING_COMPLETE + BANKING_WAITING, BANKING_HOLD, BANKING_COMPLETE, BANKING_DEPOSIT, BANKING_WITHDRAW } diff --git a/src/main/java/com/totopia/server/modules/user/type/CommissionName.java b/src/main/java/com/totopia/server/modules/user/type/CommissionName.java new file mode 100644 index 0000000..aa21a59 --- /dev/null +++ b/src/main/java/com/totopia/server/modules/user/type/CommissionName.java @@ -0,0 +1,7 @@ +package com.totopia.server.modules.user.type; + +public enum CommissionName { + COMMISSION_BANKING, // 충환 방식 + COMMISSION_BETTING, // 베팅 방식 + COMMISSION_RAFFLE // 낙첨 방식 +} diff --git a/src/test/java/com/totopia/server/modules/site/service/BankInfoServiceTest.java b/src/test/java/com/totopia/server/modules/site/service/BankInfoServiceTest.java index 16c99c0..18ad8ec 100644 --- a/src/test/java/com/totopia/server/modules/site/service/BankInfoServiceTest.java +++ b/src/test/java/com/totopia/server/modules/site/service/BankInfoServiceTest.java @@ -1,20 +1,18 @@ package com.totopia.server.modules.site.service; -import com.totopia.server.modules.site.repository.BankInfoRepository; +import com.totopia.server.modules.site.repository.BankAccountsRepository; 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 static org.junit.Assert.*; - @RunWith(SpringRunner.class) @SpringBootTest public class BankInfoServiceTest { @Autowired - BankInfoRepository bankInfoRepository; + BankAccountsRepository bankAccountsRepository; @Test diff --git a/src/test/java/com/totopia/server/modules/user/repository/DepositRepositoryTest.java b/src/test/java/com/totopia/server/modules/user/repository/DepositRepositoryTest.java index 8fbd561..dd27604 100644 --- a/src/test/java/com/totopia/server/modules/user/repository/DepositRepositoryTest.java +++ b/src/test/java/com/totopia/server/modules/user/repository/DepositRepositoryTest.java @@ -41,7 +41,7 @@ public class DepositRepositoryTest { DepositEntity en = DepositEntity.builder() .price(10000) .bankAccount((short) 1) - .approve(accounts.get(0).getId()) + .approveUser(accounts.get(0).getId()) .bank(accounts.get(2).getId()) .status(BankingName.BANKING_WAITING) diff --git a/src/test/java/com/totopia/server/modules/user/repository/WithdrawRepositoryTest.java b/src/test/java/com/totopia/server/modules/user/repository/WithdrawRepositoryTest.java index 23fd828..2d0bffc 100644 --- a/src/test/java/com/totopia/server/modules/user/repository/WithdrawRepositoryTest.java +++ b/src/test/java/com/totopia/server/modules/user/repository/WithdrawRepositoryTest.java @@ -38,7 +38,7 @@ public class WithdrawRepositoryTest { WithdrawEntity en = WithdrawEntity.builder() .price(10000) .bankAccount((short) 2) - .approve(accounts.get(0).getId()) + .approveUser(accounts.get(0).getId()) .bank(accounts.get(2).getId()) .status(BankingName.BANKING_WAITING) .build();