Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- 코딩
- CSS
- Javascript
- 처음만나는자바스크립트
- 웹
- 자바
- Spring Boot
- react
- 자바스크립트
- 마이바티스
- mybatis
- 스프링부트
- 리액트세팅
- java
- spring
- 구글캘린더api
- 리액트프로젝트세팅
- 기초 코딩
- 리액트초기세팅
- HTML
- 자바스크립트 기초
- springboot
- javaspring
- 전자정부 서버세팅
- 자바스크립트기초
- 자바스크립트기초문법
- 웹앱
- js
- 기초코딩
- 구글 oauth
Archives
- Today
- Total
인생 디벨로퍼
[Bank App] 2강 모델링 본문
728x90
2강 모델링 (1)
DB 모델링
table.sql
CREATE TABLE user_tb(
id int auto_increment primary key,
username varchar unique not null,
password varchar not null,
fullname varchar not null,
created_at timestamp not null
);
CREATE TABLE account_tb(
id int auto_increment primary key,
number varchar unique not null,
password varchar not null,
balance bigint not null,
user_id int,
created_at timestamp not null
);
CREATE TABLE history_tb(
id int auto_increment primary key,
amount bigint not null,
w_balance bigint,
d_balance bigint,
w_account_id int,
d_account_id int,
created_at timestamp not null
);
테이블 설계
data.sql
INSERT INTO user_tb(username, password, fullname, created_at) values('ssar', '1234',
'쌀', now());
INSERT INTO user_tb(username, password, fullname, created_at) values('cos', '1234',
'코스', now());
INSERT INTO account_tb(number, password, balance, user_id, created_at)
values('1111', '1234', 1000, 1, now());
INSERT INTO account_tb(number, password, balance, user_id, created_at)
values('2222', '1234', 1000, 2, now());
INSERT INTO history_tb(amount, w_balance, d_balance, w_account_id, d_account_id,
created_at) values(100, 900, 1100, 1, 2, now());
INSERT INTO history_tb(amount, w_balance, d_balance, w_account_id, d_account_id,
created_at) values(100, 800, null, 1, null, now());
INSERT INTO history_tb(amount, w_balance, d_balance, w_account_id, d_account_id,
created_at) values(100, null, 900, null, 1, now());
commit;
더미데이터 추가
자바 모델링
User.java
import lombok.Setter;
@Setter
@Getter
public class User {
private Integer id;
private String username;
private String password;
private String fullname;
private Timestamp createdAt;
}
Account.java
package shop.mtcoding.bankapp.model.user;
import java.sql.Timestamp;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class Account {
private Integer id;
private String number;
private String password;
private Long balance;
private Integer userId;
private Timestamp createdAt;
}
History.java
package shop.mtcoding.bankapp.model.history;
import java.sql.Timestamp;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class History {
private Integer id;
private Long amount;
private Long wBalance;
private Long dBalance;
private Integer wAccountId;
private Integer dAccountId;
private Timestamp createdAt;
}
UserRepository.java
package shop.mtcoding.bankapp.model.user;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserRepository {
public int insert(User user);
public int updateById(User user);
public int deleteById(int id);
public List<User> findAll();
public User findById(int id);
}
AccountRepository.java
package shop.mtcoding.bankapp.model.accout;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AccountRepository {
public int insert(Account account);
public int updateById(Account account);
public int deleteById(int id);
public List<Account> findAll();
public Account findById(int id);
}
HistoryRepository.java
package shop.mtcoding.bankapp.model.history;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface HistoryRepository {
public int insert(History history);
public int updateById(History history);
public int deleteById(int id);
public List<History> findAll();
public History findById(int id);
}
user.xml
http://mybatis.org/dtd/mybatis-3-mapper.dtd>">
select * from user_tb
select * from user_tb where id = #{id}
select * from user_tb where username = #{username} and password = #{password}
insert into user_tb (username, password, fullname, created_at) values(#{username}, #{password}, #{fullname}, now())
delete from user_tb where id = #{id}
update user_tb set username= #{username}, password= #{password}, fullname= #{fullname} where id = #{id}
history.xml
http://mybatis.org/dtd/mybatis-3-mapper.dtd>">
select * from history_tb
select * from history_tb where id = #{id}
insert into history_tb(amount, w_balance, d_balance, w_account_id, d_account_id, created_at)
values(#{amount}, #{wBalance}, #{dBalance}, #{wAccountId}, #{dAccountId}, now())
delete from history_tb where id = #{id}
update history_tb
set amount= #{amount}, w_balance= #{wBalance}, d_balance= #{dBalance}, w_account_id = #{wAccountId}, d_account_id = #{dAccountId} where id = #{id}
account.xml
http://mybatis.org/dtd/mybatis-3-mapper.dtd>">
select * from account_tb
select * from account_tb where id = #{id}
insert into account_tb (number, password, balance, user_id, created_at) values(#{number}, #{password}, #{balance}, #{userId}, now())
delete from account_tb where id = #{id}
update account_tb set number= #{number}, password= #{password}, balance= #{balance}, user_id= #{userId} where id = #{id}
서버 체크
tomcat 8080 이 나오는지 확인하자!
Tomcat
💡 스프링 애플리케이션 서버(Spring Application Server)
- 웹 서버(Web Server) : 스프링 어플리케이션을 실행, 웹 서버와 스프링 어플리케이션을 함께 사용하여 동적인 웹 페이지를 생성하고 제공
- 웹 컨테이너(Web Container) : 웹 컨테이너는 동적인 웹 페이지를 생성하기 위해 서블릿(Servlet)과 JSP(JavaServer Pages)를 실행하고, HTTP 요청을 처리하는 등의 역할을 담당
728x90
'Project > 개인 Project - Bank App' 카테고리의 다른 글
[Bank App] 6강 회원가입 만들기 (0) | 2023.06.10 |
---|---|
[Bank App] 5강 익셉션 핸들러 만들기 (0) | 2023.06.10 |
[Bank App] 4강 JSP 파일 세팅 (0) | 2023.06.10 |
[Bank App] 3강 화면 구현 (0) | 2023.06.09 |
[Bank App] 1강 초기 세팅 (0) | 2023.06.09 |