6段階目まで完了済

This commit is contained in:
2026-10-28 16:55:56 +09:00
parent 9932633268
commit a7c8e06ddd
11 changed files with 286 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Scanner;
import com.rhizome.example.dao.EmployeeDAO;
import com.rhizome.example.dto.EmployeeDTO;
import com.rhizome.example.util.DbUtil;
/**
@@ -48,15 +49,33 @@ public class Main {
System.out.println("現在のメンテナンス対象テーブル:" + targetTableName(tblFlg));
System.out.println("1:検索 2:登録 3:更新 4:削除 9:テーブル切替 0:終了");
String ope = sc.nextLine();
Connection con = DbUtil.getConnection();
EmployeeDAO empDao = new EmployeeDAO(con);
switch (ope) {
case "1":
empSelect();
break;
case "2":
empDao.empInsert(inputCheck("社員名", false),
inputCheck("フリガナ", false),
inputCheck("メールアドレス", false),
inputCheck("パスワード", false),
Integer.parseInt(inputCheck("部署ID", true)));
break;
case "3":
break;
int id = Integer.parseInt(inputCheck("ID", true));
if (empDao.selectById(id).size()==0) break; // 社員IDの照合に失敗した場合は処理を抜ける
else {
empDao.empUpdate(id,
inputCheck("社員名", false),
inputCheck("フリガナ", false),
inputCheck("メールアドレス", false),
inputCheck("パスワード", false),
Integer.parseInt(inputCheck("部署ID", true)));
break;
}
case "4":
empDao.empDelete(Integer.parseInt(inputCheck("ID", true)));
break;
case "9":
return;
@@ -76,7 +95,7 @@ public class Main {
* @throws SQLException
*/
public static void empSelect() throws ClassNotFoundException, SQLException {
List<String> empList = new ArrayList<>();
List<EmployeeDTO> empList = new ArrayList<>();
Connection con = DbUtil.getConnection();
EmployeeDAO empDao = new EmployeeDAO(con);
System.out.println("1:全検索 2:条件検索 それ以外:戻る");
@@ -86,10 +105,13 @@ public class Main {
case "1":
empList = empDao.selectAll();
break;
case "2":
empList = empDao.selectById(Integer.parseInt(inputCheck("ID", true)));
break;
default:
return;
}
for (String emp : empList) {
for (EmployeeDTO emp : empList) {
System.out.println(emp);
}
} finally {