롤 추가 은행정보 추
This commit is contained in:
parent
916dca0207
commit
867fcbfe0a
|
@ -0,0 +1,28 @@
|
||||||
|
package com.totopia.server.commons.base.model;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import org.hibernate.annotations.CreationTimestamp;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
@Data
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public abstract class Base {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
@CreationTimestamp
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@Column(name = "create_date", nullable = false)
|
||||||
|
private Date createDate;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@Column(name = "update_date", nullable = false)
|
||||||
|
private Date updateDate;
|
||||||
|
}
|
39
src/main/java/com/totopia/server/user/model/BankAccount.java
Normal file
39
src/main/java/com/totopia/server/user/model/BankAccount.java
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
package com.totopia.server.user.model;
|
||||||
|
|
||||||
|
import com.totopia.server.commons.base.model.Base;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "TBL_BANK_ACCOUNT")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BankAccount extends Base {
|
||||||
|
// @Id
|
||||||
|
// @GeneratedValue(generator = "bank_account_generator")
|
||||||
|
// @SequenceGenerator(name = "bank_account_generator", sequenceName = "bank_account_sequence", initialValue = 1, allocationSize = 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 = "user_id", nullable = false)
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
}
|
|
@ -11,18 +11,18 @@ import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "TBL_USER_GROUP")
|
@Table(name = "TBL_ROLE")
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class UserGroup implements Serializable {
|
public class Role implements Serializable {
|
||||||
private static final long serialVersionUID = 4801565634000630034L;
|
private static final long serialVersionUID = 4801565634000630034L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(generator = "user_group_generator")
|
@GeneratedValue(generator = "user_group_generator")
|
||||||
@SequenceGenerator(name = "user_group_generator", sequenceName = "user_group_sequence", initialValue = 1, allocationSize = 1)
|
@SequenceGenerator(name = "user_group_generator", sequenceName = "user_group_sequence", initialValue = 1, allocationSize = 1)
|
||||||
private Long id;
|
private Integer id;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "title", nullable = false, length = 100)
|
@Column(name = "title", nullable = false, length = 100)
|
|
@ -7,6 +7,7 @@ import javax.persistence.*;
|
||||||
|
|
||||||
import com.totopia.server.commons.base.gson.annotation.Exclude;
|
import com.totopia.server.commons.base.gson.annotation.Exclude;
|
||||||
|
|
||||||
|
import com.totopia.server.commons.base.model.Base;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -20,13 +21,17 @@ import org.hibernate.annotations.UpdateTimestamp;
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class User implements Serializable {
|
@AttributeOverrides({
|
||||||
|
@AttributeOverride(name = "createDate", column = @Column(name = "registDate")),
|
||||||
|
@AttributeOverride(name = "updateDate", column = @Column(name = "lastvisitDate")),
|
||||||
|
})
|
||||||
|
public class User extends Base implements Serializable {
|
||||||
private static final long serialVersionUID = 2783105197387637187L;
|
private static final long serialVersionUID = 2783105197387637187L;
|
||||||
|
|
||||||
@Id
|
// @Id
|
||||||
@GeneratedValue(generator = "user_generator")
|
// @GeneratedValue(generator = "user_generator")
|
||||||
@SequenceGenerator(name = "user_generator", sequenceName = "user_sequence", initialValue = 1000)
|
// @SequenceGenerator(name = "user_generator", sequenceName = "user_sequence", initialValue = 1000)
|
||||||
private Long id;
|
// private Long id;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "username", unique = true, nullable = false, length = 150)
|
@Column(name = "username", unique = true, nullable = false, length = 150)
|
||||||
|
@ -37,6 +42,9 @@ public class User implements Serializable {
|
||||||
@Exclude
|
@Exclude
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private String passwordConfirm;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "name", nullable = false, length = 255)
|
@Column(name = "name", nullable = false, length = 255)
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
@ -57,24 +65,27 @@ public class User implements Serializable {
|
||||||
@Column(name = "send_email", nullable = true, columnDefinition = "bool default false")
|
@Column(name = "send_email", nullable = true, columnDefinition = "bool default false")
|
||||||
private Boolean sendEmail;
|
private Boolean sendEmail;
|
||||||
|
|
||||||
@Basic
|
// @AttributeOverride(name = "createDate", column = @Column(name = "regist_date"))
|
||||||
@CreationTimestamp
|
// private Date registerDate;
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
//
|
||||||
@Column(name = "register_date", nullable = false)
|
// @AttributeOverride(name = "updateDate", column = @Column(name = "lastvisit_date"))
|
||||||
private Date registerDate;
|
// private Date lastvisitDate;
|
||||||
|
// @Basic
|
||||||
@Basic
|
// @CreationTimestamp
|
||||||
@UpdateTimestamp
|
// @Temporal(TemporalType.TIMESTAMP)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
// @Column(name = "register_date", nullable = false)
|
||||||
@Column(name = "lastvisit_date", nullable = false)
|
// private Date registerDate;
|
||||||
private Date lastvisitDate;
|
//
|
||||||
|
// @Basic
|
||||||
|
// @Temporal(TemporalType.TIMESTAMP)
|
||||||
|
// @Column(name = "lastvisit_date", nullable = false)
|
||||||
|
// private Date lastvisitDate;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "activation", nullable = false, length = 100)
|
@Column(name = "activation", nullable = false, length = 100)
|
||||||
private String activation;
|
private String activation;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@UpdateTimestamp
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
@Column(name = "last_reset_time", nullable = false)
|
@Column(name = "last_reset_time", nullable = false)
|
||||||
private Date lastResetTime;
|
private Date lastResetTime;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.totopia.server.user.repository;
|
||||||
|
|
||||||
|
import com.totopia.server.user.model.BankAccount;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface BankAccountRepository extends JpaRepository<BankAccount, Long> {
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.totopia.server.user.repository;
|
||||||
|
|
||||||
|
import com.totopia.server.user.model.Role;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface RoleRepository extends JpaRepository<Role, Integer> {
|
||||||
|
}
|
|
@ -28,12 +28,12 @@ public interface UserRepository extends JpaRepository<User, Long> {
|
||||||
// 어드민이 펄스이며, 활동중인 현재 회원 리스트
|
// 어드민이 펄스이며, 활동중인 현재 회원 리스트
|
||||||
Page<User> findAllByIsAdminFalseAndActivationEquals(String activation, Pageable pageable) throws Exception;
|
Page<User> findAllByIsAdminFalseAndActivationEquals(String activation, Pageable pageable) throws Exception;
|
||||||
// 날짜 검색
|
// 날짜 검색
|
||||||
Page<User> findAllByRegisterDateBetween(Date starDate, Date endDate, Pageable pageable) throws Exception;
|
Page<User> findAllByCreateDateBetween(Date starDate, Date endDate, Pageable pageable) throws Exception;
|
||||||
Page<User> findAllByLastvisitDateBetween(Date starDate, Date endDate, Pageable pageable) throws Exception;
|
Page<User> findAllByUpdateDateBetween(Date starDate, Date endDate, Pageable pageable) throws Exception;
|
||||||
Page<User> findAllByLastResetTimeBetween(Date starDate, Date endDate, Pageable pageable) throws Exception;
|
Page<User> findAllByLastResetTimeBetween(Date starDate, Date endDate, Pageable pageable) throws Exception;
|
||||||
|
|
||||||
// 현재 날짜 이후 가입된 회원의 총 수 리턴
|
// 현재 날짜 이후 가입된 회원의 총 수 리턴
|
||||||
Long countByRegisterDateGreaterThanEqual(Date date) throws Exception;
|
Long countByCreateDateGreaterThanEqual(Date date) throws Exception;
|
||||||
|
|
||||||
// 유저 그룹별 회원 리스트
|
// 유저 그룹별 회원 리스트
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
insert into public.tbl_user_group
|
insert into public.tbl_role
|
||||||
(id ,title, description, is_default, register_date)
|
(id ,title, description, is_default, register_date)
|
||||||
values
|
values
|
||||||
(1, '관리자', '관리자 그룹', false, '2019-07-20 12:00:30');
|
(1, '관리자', '관리자 그룹', false, '2019-07-20 12:00:30');
|
||||||
|
|
||||||
insert into public.tbl_user_group
|
insert into public.tbl_role
|
||||||
(id ,title, description, is_default, register_date)
|
(id ,title, description, is_default, register_date)
|
||||||
values
|
values
|
||||||
(2, '정회원', '정회원 그룹', true, '2019-07-20 12:00:30');
|
(2, '정회원', '정회원 그룹', true, '2019-07-20 12:00:30');
|
||||||
|
|
||||||
insert into public.tbl_user_group
|
insert into public.tbl_role
|
||||||
(id ,title, description, is_default, register_date)
|
(id ,title, description, is_default, register_date)
|
||||||
values
|
values
|
||||||
(3, '비회원', '비회원 그룹', false, '2019-07-20 12:00:30');
|
(3, '비회원', '비회원 그룹', false, '2019-07-20 12:00:30');
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.totopia.server.user.repository;
|
||||||
|
|
||||||
|
import com.totopia.server.user.model.BankAccount;
|
||||||
|
import com.totopia.server.user.model.User;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
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.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class BankAccountRepositoryTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BankAccountRepository bankAccountRepository;
|
||||||
|
|
||||||
|
List<User> users;
|
||||||
|
List<BankAccount> accounts = new ArrayList<>();
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
users = this.userRepository.findAll();
|
||||||
|
|
||||||
|
if(users == null) {
|
||||||
|
throw new Exception("user list Null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInsert() {
|
||||||
|
|
||||||
|
BankAccount bankAccount = null;
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
for (User user : users) {
|
||||||
|
bankAccount = new BankAccount();
|
||||||
|
|
||||||
|
switch (idx) {
|
||||||
|
case 0:
|
||||||
|
bankAccount.setName("국민은행");
|
||||||
|
bankAccount.setHolder("예금주1");
|
||||||
|
bankAccount.setNumber("123-422-23112");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
bankAccount.setName("우리은행");
|
||||||
|
bankAccount.setHolder("예금주2");
|
||||||
|
bankAccount.setNumber("321-555-3312-21");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
bankAccount.setName("기업은행");
|
||||||
|
bankAccount.setHolder("예금주3");
|
||||||
|
bankAccount.setNumber("832-2392-2392-29829");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
idx++;
|
||||||
|
bankAccount.setUserId(user.getId());
|
||||||
|
bankAccount.setUpdateDate(new Date());
|
||||||
|
this.bankAccountRepository.save(bankAccount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
List<BankAccount> bankAccounts = this.bankAccountRepository.findAll();
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
for (BankAccount account : bankAccounts) {
|
||||||
|
|
||||||
|
switch (idx) {
|
||||||
|
case 0:
|
||||||
|
account.setName("국민은행");
|
||||||
|
account.setHolder("예금주1");
|
||||||
|
account.setNumber("123-422-23112");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
account.setName("우리은행");
|
||||||
|
account.setHolder("예금주2");
|
||||||
|
account.setNumber("321-555-3312-21");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
account.setName("기업은행");
|
||||||
|
account.setHolder("예금주3");
|
||||||
|
account.setNumber("832-2392-2392-29829");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
idx++;
|
||||||
|
account.setUserId(account.getUserId());
|
||||||
|
|
||||||
|
this.bankAccountRepository.save(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,15 +2,21 @@ package com.totopia.server.user.repository;
|
||||||
|
|
||||||
import com.totopia.server.user.model.User;
|
import com.totopia.server.user.model.User;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class UserRepositoryTest {
|
public class UserRepositoryTest {
|
||||||
|
@ -18,11 +24,13 @@ public class UserRepositoryTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserRepository userRepository;
|
private UserRepository userRepository;
|
||||||
|
|
||||||
private User.UserBuilder user;
|
// private User.UserBuilder user;
|
||||||
|
|
||||||
|
private List<User> userList = new ArrayList<>();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
user = User.builder()
|
User.UserBuilder user = User.builder()
|
||||||
.activation("Y")
|
.activation("Y")
|
||||||
.block(false)
|
.block(false)
|
||||||
.email("geekdev@naver.com")
|
.email("geekdev@naver.com")
|
||||||
|
@ -33,25 +41,66 @@ public class UserRepositoryTest {
|
||||||
.password("qwer5795")
|
.password("qwer5795")
|
||||||
.username("admin")
|
.username("admin")
|
||||||
.requireReset(false)
|
.requireReset(false)
|
||||||
.resetCount(Long.valueOf(0));
|
.resetCount(Long.valueOf(0))
|
||||||
|
.lastResetTime(new Date());
|
||||||
|
|
||||||
|
User temp = user.build();
|
||||||
|
temp.setUpdateDate(new Date());
|
||||||
|
userList.add(temp);
|
||||||
|
|
||||||
|
user = User.builder()
|
||||||
|
.activation("Y")
|
||||||
|
.block(false)
|
||||||
|
.email("geektest1@naver.com")
|
||||||
|
.isAdmin(false)
|
||||||
|
.nickname("test1")
|
||||||
|
.otep("")
|
||||||
|
.otpKey("")
|
||||||
|
.password("qwer5795")
|
||||||
|
.username("test1")
|
||||||
|
.requireReset(false)
|
||||||
|
.resetCount(Long.valueOf(0))
|
||||||
|
.lastResetTime(new Date());
|
||||||
|
|
||||||
|
temp = user.build();
|
||||||
|
temp.setUpdateDate(new Date());
|
||||||
|
userList.add(temp);
|
||||||
|
|
||||||
|
user = User.builder()
|
||||||
|
.activation("Y")
|
||||||
|
.block(false)
|
||||||
|
.email("geektest2@naver.com")
|
||||||
|
.isAdmin(false)
|
||||||
|
.nickname("test2")
|
||||||
|
.otep("")
|
||||||
|
.otpKey("")
|
||||||
|
.password("qwer5795")
|
||||||
|
.username("test2")
|
||||||
|
.requireReset(false)
|
||||||
|
.resetCount(Long.valueOf(0))
|
||||||
|
.lastResetTime(new Date());
|
||||||
|
|
||||||
|
temp = user.build();
|
||||||
|
temp.setUpdateDate(new Date());
|
||||||
|
userList.add(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findByUsername() throws Exception {
|
public void findByUsername() {
|
||||||
User admin = this.userRepository.findByUsername("admin");
|
User admin = this.getAdmin();
|
||||||
if (admin == null) {
|
if (admin == null) {
|
||||||
User tempUser = user.build();
|
this.userRepository.saveAll(userList);
|
||||||
|
assertEquals("Equlas", userList.get(0).getNickname(), "admin");
|
||||||
this.userRepository.save(tempUser);
|
|
||||||
|
|
||||||
User user1 = this.userRepository.findByUsername(tempUser.getUsername());
|
|
||||||
|
|
||||||
assertEquals("Equlas", user.build().getUsername(), user1.getUsername());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findByEmail() {
|
public void findByEmail() {
|
||||||
|
User admin = this.getAdmin();
|
||||||
|
|
||||||
|
if(admin != null) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -93,4 +142,13 @@ public class UserRepositoryTest {
|
||||||
@Test
|
@Test
|
||||||
public void countByRegisterDateGreaterThanEqual() {
|
public void countByRegisterDateGreaterThanEqual() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private User getAdmin() {
|
||||||
|
try {
|
||||||
|
return this.userRepository.findByUsername("admin");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user