Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- abstract
- 어윈 사용법
- 참조형변수
- 다형성
- cursor문
- 사용자예외클래스생성
- 예외처리
- 대덕인재개발원
- 오라클
- 제네릭
- 객체 비교
- NestedFor
- 환경설정
- 자바
- 인터페이스
- 집합_SET
- GRANT VIEW
- exception
- 추상메서드
- 컬렉션 타입
- 한국건설관리시스템
- 컬렉션프레임워크
- 생성자오버로드
- 자동차수리시스템
- 메소드오버로딩
- 예외미루기
- 정수형타입
- EnhancedFor
- Java
- oracle
Archives
- Today
- Total
거니의 velog
14. MemberDAO 본문
package firstproject.dao;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import firstproject.util.JDBCUtil;
public class MemberDAO {
private static MemberDAO instance = null;
private MemberDAO() {}
public static MemberDAO getInstance() {
if (instance == null) instance = new MemberDAO();
return instance;
}
JDBCUtil jdbc = JDBCUtil.getInstance();
StringBuilder sb = null;
String sql = null;
// 로그인
public Map<String, Object> login(List<Object> param) {
sb = new StringBuilder();
sb.append(" SELECT * FROM MEMBER ");
sb.append(" WHERE MEMID = ? ");
sb.append(" AND MEMPW = ? ");
sql = sb.toString();
return jdbc.selectOne(sql, param);
}
// 로그인 시 아이디 검증
public Map<String, Object> loginId(List<Object> param) {
String sql = " SELECT * FROM MEMBER WHERE MEMID = ? ";
return jdbc.selectOne(sql, param);
}
// 로그인 시 비밀번호 검증
public Map<String, Object> loginPw(List<Object> param) {
String sql = " SELECT * FROM MEMBER WHERE MEMPW = ? ";
return jdbc.selectOne(sql, param);
}
// 등록된 회원 아이디 조회 후 중복 아이디 체크
public Map<String, Object> isValID(String memID) {
String sql = "SELECT * FROM MEMBER WHERE MEMID='" + memID + "'";
return jdbc.selectOne(sql);
}
// 회원 가입
public int signUp(List<Object> param) {
sb = new StringBuilder();
sb.append(" INSERT INTO MEMBER ");
sb.append(" (MEMID, MEMNM, MEMPW, MEMADD, MEMLV, BALANCE, MEMTEL) ");
sb.append(" VALUES ");
sb.append(" (?, ?, ?, ?, ?, ?, ?) ");
sql = sb.toString();
return jdbc.update(sql, param);
}
// 아이디 찾기
public Map<String, Object> findID(List<Object> param) {
String sql = " SELECT * FROM MEMBER WHERE MEMNM = ? AND MEMTEL = ? ";
return jdbc.selectOne(sql, param);
}
// 비밀번호 찾기
public Map<String, Object> findPW(List<Object> param) {
String sql = " SELECT * FROM MEMBER WHERE MEMID = ? AND MEMTEL = ? ";
return jdbc.selectOne(sql, param);
}
// 잔액 충전 서비스
public long depositPoint(List<Object> param) {
return jdbc.update(" UPDATE MEMBER SET BALANCE = ? WHERE MEMID = ? ", param);
}
public List<Map<String, Object>> searchOrderCode(List<Object> param) {
sb = new StringBuilder();
sb.append(" SELECT ORDERCODE ");
sb.append(" FROM (SELECT TRIM(TO_CHAR(SUBSTR(ORDERCODE, 9, 4)+1, '0000')) AS ORDERCODE ");
sb.append(" FROM ORDERHISTO ");
sb.append(" WHERE ORDERCODE LIKE ? ");
sb.append(" ORDER BY ORDERCODE DESC) ");
sb.append(" WHERE ROWNUM = 1 ");
sql = sb.toString();
return jdbc.selectList(sql, param);
}
public List<Map<String, Object>> orderCode(String userID) {
String sql = " SELECT * FROM ORDERHISTO WHERE MEMID = ? ORDER BY ORDERDATE DESC, ORDERNO DESC ";
List<Object> param = new ArrayList<>();
param.add(userID);
return jdbc.selectList(sql, param);
}
// 유저아이디를 통해 주문코드를 가져오는 쿼리, 주문내역관리
public List<Map<String, Object>> orderCodeSearch(String userID) {
sql = "SELECT DISTINCT A.ORDERCODE AS ORDERCODE " +
" FROM ORDERHISTO A, MEMBER B " +
" WHERE 1=1 " +
" AND A.MEMID = B.MEMID " +
" AND B.MEMID = ? ";
List<Object> param = new ArrayList<>();
param.add(userID);
return jdbc.selectList(sql, param);
}
// 유저아이디를 통해 유저의 orderhisto 테이블의 정보를 가져오는 쿼리, 주문내역관리
public List<Map<String, Object>> orderListStr(String userID, String orderCode) {
String sql = "SELECT A.ORDERNO AS ORDERNO " +
" , A.ORDERCODE AS ORDERCODE " +
" , B.MENUNM AS MENUNM " +
" , A.ORDERQTY AS ORDERQTY " +
" , A.ORDERETA AS ORDERETA " +
" , (A.ORDERQTY * B.MENUPRICE) AS TOTALPRICE " +
" , TO_CHAR(A.ORDERDATE, 'YYYY-MM-DD') AS ORDERDATE " +
" , E.MEMNM AS MEMNM " +
" , E.MEMADD AS MEMADD " +
" , DECODE(A.SELYN, 'Y', '결제완료', 'N', '결제대기', '오류') AS SELYN " +
" , D.DELICOST AS DELICOST " +
" , A.DELIORTAKE AS DELIORTAKE " +
" FROM ORDERHISTO A, MENU B, STORE C, RIDER D, MEMBER E " +
" WHERE 1=1 " +
" AND A.MEMID = E.MEMID " +
" AND A.MENUCODE = B.MENUCODE " +
" AND B.STOCODE = C.STOCODE " +
" AND C.STOCODE = D.STOCODE " +
" AND E.MEMID = ? " +
" AND A.ORDERCODE = ? " +
" ORDER BY A.ORDERDATE DESC, A.ORDERNO ";
List<Object> param = new ArrayList<>();
param.add(userID);
param.add(orderCode);
return jdbc.selectList(sql, param);
}
public List<Map<String, Object>> orderList(String userID ,String orderCode) {
String sql = " SELECT A.ORDERCODE AS ORDERCODE, "
+ " B.MENUNM AS MENUNM, "
+ " B.MENUPRICE AS MENUPRICE, "
+ " C.STONM AS STONM, "
+ " A.ORDERQTY || '개' AS ORDERQTY, "
+ " A.ORDERDATE AS ORDERDATE, "
+ " A.ORDERETA || '분' AS ORDERETA, "
+ " A.ORDERQTY * B.MENUPRICE AS TOTALPRICE, "
+ " E.MEMADD AS MEMADD "
+ " FROM ORDERHISTO A, MENU B, STORE C, RIDER D, MEMBER E "
+ " WHERE 1=1 "
+ " AND A.MEMID = E.MEMID "
+ " AND A.MENUCODE = B.MENUCODE "
+ " AND B.STOCODE = C.STOCODE "
+ " AND C.STOCODE = D.STOCODE "
+ " AND E.MEMID = ? "
+ " AND A.ORDERCODE = ? "
+ " ORDER BY A.ORDERDATE DESC, A.ORDERNO DESC ";
List<Object> param = new ArrayList<>();
param.add(userID);
param.add(orderCode);
return jdbc.selectList(sql, param);
}
// 유저아이디를 통해 유저의 orderhisto 테이블의 정보를 가져오는 쿼리
public List<Map<String, Object>> orderList(String userID) {
String sql = "SELECT A.ORDERNO AS ORDERNO " +
" , A.ORDERCODE AS ORDERCODE " +
" , B.MENUNM AS MENUNM " +
" , A.ORDERQTY AS ORDERQTY " +
" , A.ORDERETA AS ORDERETA " +
" , (A.ORDERQTY * B.MENUPRICE) AS TOTALPRICE " +
" , TO_CHAR(A.ORDERDATE, 'YYYY-MM-DD') AS ORDERDATE " +
" , E.MEMNM AS MEMNM " +
" , E.MEMADD AS MEMADD " +
" , DECODE(A.SELYN, 'Y', '결제완료', 'N', '결제대기', '오류') AS SELYN " +
" , D.DELICOST AS DELICOST " +
" FROM ORDERHISTO A, MENU B, STORE C, RIDER D, MEMBER E " +
" WHERE 1=1 " +
" AND A.MEMID = E.MEMID " +
" AND A.MENUCODE = B.MENUCODE " +
" AND B.STOCODE = C.STOCODE " +
" AND C.STOCODE = D.STOCODE " +
" AND E.MEMID = ? " +
" ORDER BY A.ORDERDATE DESC, A.ORDERNO ";
List<Object> param = new ArrayList<>();
param.add(userID);
return jdbc.selectList(sql, param);
}
// 메뉴명 가져오는 쿼리
public List<Map<String, Object>> menuInfoList(String menucode) {
// String sql = " SELECT M.MENUCODE, M.MENUNM, M.MENUPRICE, M.REMAINQTY, M.STOCODE "
// + " FROM MENU M, ORDERHISTO O " + " WHERE M.MENUCODE = O.MENUCODE " + " AND O.MENUCODE = ? ";
sql = "SELECT M.MENUCODE AS MENUCODE " +
" , M.MENUNM AS MENUNM " +
" , M.MENUPRICE AS MENUPRICE " +
" , M.REMAINQTY AS REMAINQTY " +
" , M.STOCODE AS STOCODE " +
" FROM MENU M, ORDERHISTO O " +
" WHERE M.MENUCODE = O.MENUCODE " +
" AND O.MENUCODE = ? ";
List<Object> param = new ArrayList<>();
param.add(menucode);
return jdbc.selectList(sql, param);
}
}
'대덕인재개발원 > 대덕인재개발원_1st project' 카테고리의 다른 글
13. AdminDeleteDAO (0) | 2023.08.19 |
---|---|
12. AdminUpdateDAO (0) | 2023.08.19 |
11. AdminReadDAO (0) | 2023.08.19 |
10. AdminCreateDAO (0) | 2023.08.19 |
9. 관리자 페이지 (6) : 라이더 관리 (0) | 2023.08.19 |