Skip to content

Commit

Permalink
2020-08-21 김대훈 SalesDao 내용 변경
Browse files Browse the repository at this point in the history
				SalesDaoImpl 생성
				SalesDaoImplTest 생성 이후에 작업 할 예쩡
  • Loading branch information
kimdeahun6317 committed Aug 21, 2020
1 parent 672eab4 commit 737092d
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/hairrang/dao/SalesDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

import java.util.List;

import hairrang.dto.Sales;


public interface SalesDao {

List<SalesDao> selectSalesByAll();
List<Sales> selectSalesByAll();

SalesDao selectSalesByNo(SalesDao sales);
Sales selectSalesByNo(Sales sales);

int insertSales(SalesDao sales);
int insertSales(Sales sales);

int updateSales(SalesDao sales);
int updateSales(Sales sales);

int deleteSales(SalesDao sales);
int deleteSales(Sales sales);

SalesDao selectSameSalesEmployeeBySalesNo(SalesDao sales);
}
74 changes: 74 additions & 0 deletions src/hairrang/dao/impl/SalesDaoImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package hairrang.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import hairrang.conn.JdbcUtil;
import hairrang.dao.SalesDao;
import hairrang.dto.Sales;

public class SalesDaoImpl implements SalesDao{
private static final SalesDaoImpl instance = new SalesDaoImpl();

private SalesDaoImpl() {};

public static SalesDaoImpl getInstace() {
return instance;
}

@Override
public List<Sales> selectSalesByAll() {
String sql = "SELECT * FROM SALES";
try(Connection con = JdbcUtil.getConnection();
PreparedStatement pstmt = con.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery()){
if(rs.next()) {
List<Sales> list = new ArrayList<Sales>();
do {
list.add(getSales(rs));
}while(rs.next());
return list;
}
} catch (SQLException e) {
throw new RuntimeException(e);
}

return null;
}



@Override
public Sales selectSalesByNo(Sales sales) {
// TODO Auto-generated method stub
return null;
}

@Override
public int insertSales(Sales sales) {
// TODO Auto-generated method stub
return 0;
}

@Override
public int updateSales(Sales sales) {
// TODO Auto-generated method stub
return 0;
}

@Override
public int deleteSales(Sales sales) {
// TODO Auto-generated method stub
return 0;
}

private Sales getSales(ResultSet rs) {
// TODO Auto-generated method stub
return null;
}

}
51 changes: 51 additions & 0 deletions test/hairrang/dao/test/SalesDaoTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package hairrang.dao.test;

import static org.junit.Assert.fail;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import hairrang.dao.SalesDao;
import hairrang.dao.impl.SalesDaoImpl;

public class SalesDaoTest {
private SalesDao dao;

@Before
public void setUp() throws Exception {
dao=SalesDaoImpl.getInstace();
}

@After
public void tearDown() throws Exception {
dao=null;
}

@Test
public void testSelectSalesByAll() {
System.out.printf("%s()%n","testSelectSalesByAll()");

}

@Test
public void testSelectSalesByNo() {
fail("Not yet implemented");
}

@Test
public void testInsertSales() {
fail("Not yet implemented");
}

@Test
public void testUpdateSales() {
fail("Not yet implemented");
}

@Test
public void testDeleteSales() {
fail("Not yet implemented");
}

}

0 comments on commit 737092d

Please sign in to comment.