롤 추가 은행정보 추

This commit is contained in:
byung eun park 2019-08-12 18:10:42 +09:00
parent 916dca0207
commit 867fcbfe0a
10 changed files with 297 additions and 38 deletions

View File

@ -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;
}

View 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;
}

View File

@ -11,18 +11,18 @@ import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name = "TBL_USER_GROUP")
@Table(name = "TBL_ROLE")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserGroup implements Serializable {
public class Role implements Serializable {
private static final long serialVersionUID = 4801565634000630034L;
@Id
@GeneratedValue(generator = "user_group_generator")
@SequenceGenerator(name = "user_group_generator", sequenceName = "user_group_sequence", initialValue = 1, allocationSize = 1)
private Long id;
private Integer id;
@Basic
@Column(name = "title", nullable = false, length = 100)

View File

@ -7,6 +7,7 @@ import javax.persistence.*;
import com.totopia.server.commons.base.gson.annotation.Exclude;
import com.totopia.server.commons.base.model.Base;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -20,13 +21,17 @@ import org.hibernate.annotations.UpdateTimestamp;
@Builder
@NoArgsConstructor
@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;
@Id
@GeneratedValue(generator = "user_generator")
@SequenceGenerator(name = "user_generator", sequenceName = "user_sequence", initialValue = 1000)
private Long id;
// @Id
// @GeneratedValue(generator = "user_generator")
// @SequenceGenerator(name = "user_generator", sequenceName = "user_sequence", initialValue = 1000)
// private Long id;
@Basic
@Column(name = "username", unique = true, nullable = false, length = 150)
@ -37,6 +42,9 @@ public class User implements Serializable {
@Exclude
private String password;
@Transient
private String passwordConfirm;
@Basic
@Column(name = "name", nullable = false, length = 255)
private String nickname;
@ -57,24 +65,27 @@ public class User implements Serializable {
@Column(name = "send_email", nullable = true, columnDefinition = "bool default false")
private Boolean sendEmail;
@Basic
@CreationTimestamp
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "register_date", nullable = false)
private Date registerDate;
@Basic
@UpdateTimestamp
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "lastvisit_date", nullable = false)
private Date lastvisitDate;
// @AttributeOverride(name = "createDate", column = @Column(name = "regist_date"))
// private Date registerDate;
//
// @AttributeOverride(name = "updateDate", column = @Column(name = "lastvisit_date"))
// private Date lastvisitDate;
// @Basic
// @CreationTimestamp
// @Temporal(TemporalType.TIMESTAMP)
// @Column(name = "register_date", nullable = false)
// private Date registerDate;
//
// @Basic
// @Temporal(TemporalType.TIMESTAMP)
// @Column(name = "lastvisit_date", nullable = false)
// private Date lastvisitDate;
@Basic
@Column(name = "activation", nullable = false, length = 100)
private String activation;
@Basic
@UpdateTimestamp
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_reset_time", nullable = false)
private Date lastResetTime;

View File

@ -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> {
}

View File

@ -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> {
}

View File

@ -28,12 +28,12 @@ public interface UserRepository extends JpaRepository<User, Long> {
// 어드민이 펄스이며, 활동중인 현재 회원 리스트
Page<User> findAllByIsAdminFalseAndActivationEquals(String activation, Pageable pageable) throws Exception;
// 날짜 검색
Page<User> findAllByRegisterDateBetween(Date starDate, Date endDate, Pageable pageable) throws Exception;
Page<User> findAllByLastvisitDateBetween(Date starDate, Date endDate, Pageable pageable) throws Exception;
Page<User> findAllByCreateDateBetween(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;
// 현재 날짜 이후 가입된 회원의 리턴
Long countByRegisterDateGreaterThanEqual(Date date) throws Exception;
Long countByCreateDateGreaterThanEqual(Date date) throws Exception;
// 유저 그룹별 회원 리스트

View File

@ -1,14 +1,14 @@
insert into public.tbl_user_group
insert into public.tbl_role
(id ,title, description, is_default, register_date)
values
(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)
values
(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)
values
(3, '비회원', '비회원 그룹', false, '2019-07-20 12:00:30');

View File

@ -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);
}
}
}

View File

@ -2,15 +2,21 @@ package com.totopia.server.user.repository;
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 UserRepositoryTest {
@ -18,11 +24,13 @@ public class UserRepositoryTest {
@Autowired
private UserRepository userRepository;
private User.UserBuilder user;
// private User.UserBuilder user;
private List<User> userList = new ArrayList<>();
@Before
public void setUp() throws Exception {
user = User.builder()
User.UserBuilder user = User.builder()
.activation("Y")
.block(false)
.email("geekdev@naver.com")
@ -33,25 +41,66 @@ public class UserRepositoryTest {
.password("qwer5795")
.username("admin")
.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
public void findByUsername() throws Exception {
User admin = this.userRepository.findByUsername("admin");
public void findByUsername() {
User admin = this.getAdmin();
if (admin == null) {
User tempUser = user.build();
this.userRepository.save(tempUser);
User user1 = this.userRepository.findByUsername(tempUser.getUsername());
assertEquals("Equlas", user.build().getUsername(), user1.getUsername());
this.userRepository.saveAll(userList);
assertEquals("Equlas", userList.get(0).getNickname(), "admin");
}
}
@Test
public void findByEmail() {
User admin = this.getAdmin();
if(admin != null) {
}
}
@Test
@ -93,4 +142,13 @@ public class UserRepositoryTest {
@Test
public void countByRegisterDateGreaterThanEqual() {
}
private User getAdmin() {
try {
return this.userRepository.findByUsername("admin");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}