Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34d68e34b2 |
@@ -1,112 +1,42 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import com.example.demo.entity.Employee;
|
||||
import com.example.demo.form.EmployeeForm;
|
||||
import com.example.demo.form.LoginForm;
|
||||
import com.example.demo.service.EmployeeService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@Controller
|
||||
public class MainController {
|
||||
@RequestMapping(value = "/",method = RequestMethod.GET)
|
||||
public String loin() {
|
||||
return"login";
|
||||
}
|
||||
@RequestMapping(value = "/doLogin",method = RequestMethod.POST)
|
||||
public String doLoin() {
|
||||
return"menu";
|
||||
}
|
||||
@RequestMapping(value = "/logout",method = RequestMethod.POST)
|
||||
public String logout() {
|
||||
return "login";
|
||||
}
|
||||
@RequestMapping(value = "/select",method = RequestMethod.POST)
|
||||
public String select() {
|
||||
return "select";
|
||||
}
|
||||
@RequestMapping(value = "/back",method = RequestMethod.POST)
|
||||
public String back() {
|
||||
return "menu";
|
||||
}
|
||||
@RequestMapping(value = "/insert",method = RequestMethod.POST)
|
||||
public String insert() {
|
||||
return "insert";
|
||||
}
|
||||
@RequestMapping(value = "/update",method = RequestMethod.POST)
|
||||
public String update() {
|
||||
return "update";
|
||||
}
|
||||
@RequestMapping(value = "/delete",method = RequestMethod.POST)
|
||||
public String delete() {
|
||||
return "delete";
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private HttpSession session;
|
||||
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
|
||||
@GetMapping("/")
|
||||
public String login(Model model) {
|
||||
model.addAttribute("loginForm", new LoginForm());
|
||||
return "login";
|
||||
}
|
||||
|
||||
@PostMapping("/doLogin")
|
||||
public String doLogin(@ModelAttribute LoginForm form, Model model) {
|
||||
var employeeOpt = employeeService.login(form.getMail(), form.getPass());
|
||||
if (employeeOpt.isPresent()) {
|
||||
session.setAttribute("login_emp", employeeOpt.get());
|
||||
return "menu";
|
||||
}
|
||||
model.addAttribute("error", "メールアドレスまたはパスワードが違います");
|
||||
return "login";
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
public String logout() {
|
||||
session.invalidate(); // Session ကို ဖျက်ပစ်ခြင်း
|
||||
return "redirect:/";
|
||||
}
|
||||
|
||||
@PostMapping("/back")
|
||||
public String back() {
|
||||
return "menu";
|
||||
}
|
||||
|
||||
// --- ရှာဖွေခြင်း (select) ---
|
||||
@PostMapping("/select")
|
||||
public String select(Model model) {
|
||||
List<Employee> list = employeeService.getAllEmployee();
|
||||
model.addAttribute("employeeList",list);
|
||||
return "select";
|
||||
}
|
||||
|
||||
// --- သစ်ထည့်ခြင်း (insert) ---
|
||||
@PostMapping("/insert")
|
||||
public String insert(Model model) {
|
||||
model.addAttribute("employeeForm", new EmployeeForm());
|
||||
return "insert";
|
||||
}
|
||||
|
||||
@PostMapping("/insertConfirm")
|
||||
public String insertConfirm(@ModelAttribute EmployeeForm form, Model model) {
|
||||
model.addAttribute("employeeForm", form);
|
||||
return "insertConfirm";
|
||||
}
|
||||
|
||||
@PostMapping("/insertResult")
|
||||
public String insertResult(@ModelAttribute EmployeeForm form) {
|
||||
// Form -> Entity သို့ ပြောင်းပြီး Save လုပျရပါမညျ
|
||||
return "insertResult";
|
||||
}
|
||||
|
||||
// --- ပြင်ဆင်ခြင်း (update) ---
|
||||
@PostMapping("/update")
|
||||
public String update(Model model) {
|
||||
model.addAttribute("employeeForm", new EmployeeForm());
|
||||
return "update";
|
||||
}
|
||||
|
||||
@PostMapping("/updateConfirm")
|
||||
public String updateConfirm(@ModelAttribute EmployeeForm form, Model model) {
|
||||
model.addAttribute("employeeForm", form);
|
||||
return "updateConfirm";
|
||||
}
|
||||
|
||||
@PostMapping("/updateResult")
|
||||
public String updateResult(@ModelAttribute EmployeeForm form) {
|
||||
return "updateResult";
|
||||
}
|
||||
|
||||
// --- ဖျက်ဆီးခြင်း (delete) ---
|
||||
@PostMapping("/delete")
|
||||
public String delete() {
|
||||
return "delete";
|
||||
}
|
||||
|
||||
@PostMapping("/deleteResult")
|
||||
public String deleteResult(Integer id) {
|
||||
// employeeService.deleteById(id);
|
||||
return "deleteResult";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.example.demo.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="employee")
|
||||
public class Employee {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name ="id_employee", nullable=false)
|
||||
private Integer idEmployee;
|
||||
@Column(name ="nm_employee", nullable=false)
|
||||
private String nmEmployee;
|
||||
@Column(name ="kn_employee", nullable=false)
|
||||
private String knEmployee;
|
||||
@Column(name ="mail_address", nullable=false)
|
||||
private String mailAddress;
|
||||
@Column(name ="password", nullable=false)
|
||||
private String password;
|
||||
@Column(name ="id_department", nullable=false)
|
||||
private Integer idDepartment;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EmployeeForm {
|
||||
|
||||
private String nmEmp;
|
||||
|
||||
private String knEmp;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoginForm {
|
||||
private String mail;
|
||||
private String pass;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.example.demo.repsitory;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.example.demo.entity.Employee;
|
||||
|
||||
public interface EmployeeRepository extends JpaRepository<Employee, Integer> {
|
||||
Optional<Employee> findByMailAddressAndPassword(String mail, String pass);
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.entity.Employee;
|
||||
import com.example.demo.repsitory.EmployeeRepository;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class EmployeeService {
|
||||
@Autowired
|
||||
private EmployeeRepository employeeRepository;
|
||||
|
||||
// Login စစ်ဆေးခြင်း
|
||||
public Optional<Employee> login(String mail, String pass) {
|
||||
return employeeRepository.findByMailAddressAndPassword(mail, pass);
|
||||
}
|
||||
// အချက်အလက်အားလုံး ရှာဖွေခြင်း
|
||||
public List<Employee> getAllEmployee() {
|
||||
return employeeRepository.findAll();
|
||||
}
|
||||
// အချက်အလက် သိမ်းဆည်းခြင်း / ပြင်ဆင်ခြင်း
|
||||
public Employee save(Employee employee) {
|
||||
return employeeRepository.save(employee);
|
||||
}
|
||||
// အချက်အလက် ဖျက်ဆီးခြင်း
|
||||
public void deleteById(Integer id) {
|
||||
employeeRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>削除ページ</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3>削除</h3>
|
||||
<h3> 削除</h3>
|
||||
<form action="logout" method="post">
|
||||
<input type="submit" value="ログアウト">
|
||||
</form>
|
||||
|
||||
<!-- ID တစ်ခုတည်း ရိုက်ထည့်ရန် Form -->
|
||||
<form action="deleteResult" method="post">
|
||||
<div><label>id: <input type="number" name="idEmployee"></label></div>
|
||||
<br>
|
||||
<input type="submit" value="削除">
|
||||
</form>
|
||||
|
||||
<br>
|
||||
<form action="back" method="post">
|
||||
<input type="submit" value="戻る">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,20 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>削除確認ページ</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3> 削除完了しました。</h3>
|
||||
<form action="logout" method="post">
|
||||
<input type="submit" value="ログアウト">
|
||||
</form>
|
||||
<form action="back" method="post">
|
||||
<input type="submit" value="戻る">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -11,17 +11,6 @@
|
||||
<form action="logout" method="post">
|
||||
<input type="submit" value="ログアウト">
|
||||
</form>
|
||||
<!-- Input Form များ -->
|
||||
<form action="insertConfirm" method="post">
|
||||
<div><label>name: <input type="text" name="nmEmp"></label></div>
|
||||
<div><label>kana: <input type="text" name="knEmp"></label></div>
|
||||
<div><label>mail: <input type="email" name="mail"></label></div>
|
||||
<div><label>pass: <input type="password" name="pass"></label></div>
|
||||
<div><label>id_dep: <input type="number" name="idDepartment"></label></div>
|
||||
<br>
|
||||
<input type="submit" value="登録">
|
||||
</form>
|
||||
<br>
|
||||
<form action="back" method="post">
|
||||
<input type="submit" value="戻る">
|
||||
</form>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>insert Result</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>登録完了しました。</h3>
|
||||
<form action="logout" method="post">
|
||||
<input type="submit" value="ログアウト">
|
||||
</form>
|
||||
<form action="back" method="post">
|
||||
<input type="submit" value="戻る">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
<body>
|
||||
<form action="doLogin" method="post">
|
||||
<input type="email"name="mail"placeholder="メールアドレス">
|
||||
<input type="password"name="pass"placeholder="パスワード">
|
||||
<input type="submit" value="ログイン">
|
||||
|
||||
</form>
|
||||
|
||||
@@ -21,13 +21,7 @@
|
||||
</form>
|
||||
<form action="delete" method="post">
|
||||
<input type="submit" value="削除">
|
||||
|
||||
</form>
|
||||
|
||||
<!-- ログイン者情報の表示(キー名を login_emp に修正) -->
|
||||
<div th:if="${session.login_emp != null}">
|
||||
<span th:text="|ログイン者:${session.login_emp.nmEmployee}|"></span>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
@@ -6,32 +6,15 @@
|
||||
<title>検索ページ</title>
|
||||
</head>
|
||||
|
||||
<brbody>
|
||||
<h3> 検索</h3>
|
||||
<body>
|
||||
<h3> 検索</h3>
|
||||
<form action="logout" method="post">
|
||||
<input type="submit" value="ログアウト">
|
||||
</form>
|
||||
|
||||
<!-- ဇယားဖြင့် အချက်အလက်များ ပြသခြင်း -->
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>名前</th>
|
||||
<th>カナ</th>
|
||||
<th>メールアドレス</th>
|
||||
</tr>
|
||||
<tr th:each="emp : ${employeeList}">
|
||||
<td th:text="${emp.idEmployee}"></td>
|
||||
<td th:text="${emp.nmEmployee}"></td>
|
||||
<td th:text="${emp.knEmployee}"></td>
|
||||
<td th:text="${emp.mailAddress}"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<form action="back" method="post">
|
||||
<input type="submit" value="戻る">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -11,18 +11,6 @@
|
||||
<form action="logout" method="post">
|
||||
<input type="submit" value="ログアウト">
|
||||
</form>
|
||||
<!-- Input Form များ -->
|
||||
<form action="updateConfirm" method="post">
|
||||
<div><label>id: <input type="number" name="idEmployee"></label></div>
|
||||
<div><label>name: <input type="text" name="nmEmp"></label></div>
|
||||
<div><label>kana: <input type="text" name="knEmp"></label></div>
|
||||
<div><label>mail: <input type="email" name="mail"></label></div>
|
||||
<div><label>pass: <input type="password" name="pass"></label></div>
|
||||
<div><label>id_dep: <input type="number" name="idDepartment"></label></div>
|
||||
<br>
|
||||
<input type="submit" value="更新">
|
||||
</form>
|
||||
<br>
|
||||
<form action="back" method="post">
|
||||
<input type="submit" value="戻る">
|
||||
</form>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>更新ページ</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3> 更新完了しました。</h3>
|
||||
<form action="logout" method="post">
|
||||
<input type="submit" value="ログアウト">
|
||||
</form>
|
||||
<br>
|
||||
<form action="back" method="post">
|
||||
<input type="submit" value="戻る">
|
||||
</form>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,10 +9,10 @@
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>spring-lesson</artifactId>
|
||||
<artifactId>Spring-lesson</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>spring-lesson</name>
|
||||
<name>Spring-lesson</name>
|
||||
<description/>
|
||||
<url/>
|
||||
<licenses>
|
||||
@@ -31,10 +31,7 @@
|
||||
<java.version>21</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||
@@ -46,38 +43,20 @@
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>Spring-lesson-Q2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.example.demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
import com.example.demo.presentation.Q1View;
|
||||
|
||||
@@ -10,9 +10,9 @@ import com.example.demo.presentation.Q1View;
|
||||
public class SpringLessonApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext context = SpringApplication.run(SpringLessonApplication.class, args);
|
||||
|
||||
// Q1View Bean ကို ရယူပြီး Execute လုပ်ခြင်း
|
||||
ApplicationContext context = SpringApplication.run(SpringLessonApplication.class, args);
|
||||
|
||||
Q1View view = context.getBean(Q1View.class);
|
||||
view.display();
|
||||
}
|
||||
|
||||
@@ -9,15 +9,21 @@ import com.example.demo.service.Q1Service;
|
||||
|
||||
@Controller
|
||||
public class Q1Controller {
|
||||
|
||||
@Autowired
|
||||
private Q1Service q1Service;
|
||||
@Autowired
|
||||
private Q1Logic q1Logic;
|
||||
|
||||
public String execute (String mailAddress, String password) {
|
||||
Q1Entity entity =q1Service.processService(mailAddress, password);
|
||||
|
||||
return q1Logic.formatUserDetail(entity);
|
||||
Q1Service service;
|
||||
|
||||
Q1Logic logic = new Q1Logic();
|
||||
|
||||
public Q1Entity show(String mailAddress, String password) {
|
||||
String result = logic.check(mailAddress, password);
|
||||
|
||||
if (!result.equals("OK")) {
|
||||
System.out.println(result);
|
||||
return null;
|
||||
}
|
||||
|
||||
return service.getUserData(mailAddress, password);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
package com.example.demo.domain;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Q1Entity {
|
||||
@Id
|
||||
|
||||
private String mailAddress;
|
||||
private String password;
|
||||
|
||||
//↓これなんでいるんやろう
|
||||
public Q1Entity() {
|
||||
}
|
||||
|
||||
// Constructor
|
||||
public Q1Entity(String mailAddress, String password) {
|
||||
this.mailAddress = mailAddress;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
// Getter & Setter
|
||||
//getter・setter
|
||||
public String getMailAddress() {
|
||||
return mailAddress;
|
||||
}
|
||||
@@ -34,4 +30,5 @@ public class Q1Entity {
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.example.demo.logic;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
|
||||
@Component
|
||||
public class Q1Logic {
|
||||
public String formatUserDetail(Q1Entity entity) {
|
||||
return"メールアドレス:"+entity.getMailAddress()+" パスワード:"+entity.getPassword();
|
||||
public String check(String mailAddress, String password) {
|
||||
|
||||
//メールアドレスが256文字より大きい
|
||||
if (mailAddress.length() > 256) {
|
||||
return "メールアドレスもしくはパスワードが不正です";
|
||||
}
|
||||
|
||||
//パスワードが8文字より小さい
|
||||
if (password.length() < 8) {
|
||||
return "メールアドレスもしくはパスワードが不正です";
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
|
||||
@Repository
|
||||
@Repository //←「このクラスはDAOとして使います」
|
||||
public class Q1Dao {
|
||||
private Q1Dao q1Dao;
|
||||
public Q1Entity createEntity (String mailAddress, String password) {
|
||||
return new Q1Entity(mailAddress, password);
|
||||
public Q1Entity findData(String mailAddress, String password) {
|
||||
|
||||
}
|
||||
Q1Entity entity = new Q1Entity();
|
||||
|
||||
entity.setMailAddress(mailAddress);
|
||||
entity.setPassword(password);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//メールアドレスとパスワードを入力する
|
||||
package com.example.demo.presentation;
|
||||
|
||||
import java.util.Scanner;
|
||||
@@ -6,21 +7,31 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.example.demo.application.Q1Controller;
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
|
||||
@Component
|
||||
public class Q1View {
|
||||
@Autowired
|
||||
private Q1Controller q1Controller;
|
||||
|
||||
public void display() {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
System.out.println("メールアドレス入力してください。");
|
||||
String mailAdress = scanner.nextLine();
|
||||
System.out.println("パスワード入力してください。");
|
||||
String password = scanner.nextLine();
|
||||
@Autowired
|
||||
Q1Controller controller;
|
||||
|
||||
String result = q1Controller.execute(mailAdress, password);
|
||||
System.out.println("======結果=====");
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
public void display() {
|
||||
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
System.out.println("メールアドレス:");
|
||||
String mailAddress = scanner.nextLine();
|
||||
|
||||
System.out.println("パスワード:");
|
||||
String password = scanner.nextLine();
|
||||
|
||||
Q1Entity entity = controller.show(mailAddress, password);
|
||||
|
||||
if (entity != null) {
|
||||
System.out.println("メールアドレス:" + entity.getMailAddress());
|
||||
System.out.println("パスワード:" + entity.getPassword());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,10 +8,13 @@ import com.example.demo.persistence.Q1Dao;
|
||||
|
||||
@Service
|
||||
public class Q1Service {
|
||||
@Autowired
|
||||
private Q1Dao q1Dao;
|
||||
public Q1Entity processService(String mailAdress, String password) {
|
||||
return q1Dao.createEntity(mailAdress,password);
|
||||
}
|
||||
|
||||
//Q1ServiceがQ1Daoを使いたい→Q1Daoを渡しておくね
|
||||
@Autowired
|
||||
Q1Dao dao;
|
||||
|
||||
public Q1Entity getUserData(String mailAddress, String password) {
|
||||
|
||||
return dao.findData(mailAddress, password);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user