Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e83ba750db | |||
| a2fe934995 | |||
| ed7b0eacd4 |
@@ -0,0 +1,21 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import com.example.demo.config.Q2Config;
|
||||
import com.example.demo.presentation.Q2View;
|
||||
|
||||
@SpringBootApplication
|
||||
@Import(Q2Config.class)
|
||||
public class SpringQuestion2Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext context = SpringApplication.run(SpringQuestion2Application.class, args);
|
||||
Q2View sample = context.getBean(Q2View.class);
|
||||
sample.Empscan();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.example.demo.application;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.example.demo.domain.Q2Entity;
|
||||
import com.example.demo.logic.Q2Logic;
|
||||
import com.example.demo.service.Q2Service;
|
||||
|
||||
public class Q2Controller {
|
||||
|
||||
@Autowired
|
||||
Q2Service serv;
|
||||
@Autowired
|
||||
Q2Logic logic;
|
||||
|
||||
public String Empjudge(String mailadress, String password) {
|
||||
String message;
|
||||
//パスワードとメールアドレスが正確かジャッジ
|
||||
if (mailadress.length() > 256 || password.length() < 8) {
|
||||
message = "メールアドレスもしくはパスワードが不正です";
|
||||
return message;
|
||||
} else {
|
||||
//サービスメソッドに引数を渡し実行
|
||||
Q2Entity entity = serv.ServeEntity(mailadress, password);
|
||||
//ロジッククラスに引数を渡し実行
|
||||
message = logic.Createmessage(entity);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.example.demo.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.example.demo.application.Q2Controller;
|
||||
import com.example.demo.logic.Q2Logic;
|
||||
import com.example.demo.persistence.Q2Dao;
|
||||
import com.example.demo.presentation.Q2View;
|
||||
import com.example.demo.service.Q2Service;
|
||||
|
||||
@Configuration
|
||||
public class Q2Config {
|
||||
|
||||
@Bean
|
||||
Q2Dao q2dao() {
|
||||
return new Q2Dao();
|
||||
}
|
||||
|
||||
@Bean
|
||||
Q2Service q2service() {
|
||||
return new Q2Service();
|
||||
}
|
||||
|
||||
@Bean
|
||||
Q2Logic q2logic() {
|
||||
return new Q2Logic();
|
||||
}
|
||||
|
||||
@Bean
|
||||
Q2Controller q2controller() {
|
||||
return new Q2Controller();
|
||||
}
|
||||
|
||||
@Bean
|
||||
Q2View q2view() {
|
||||
return new Q2View();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.example.demo.domain;
|
||||
|
||||
|
||||
public class Q2Entity {
|
||||
private String mailAdress;
|
||||
private String password;
|
||||
|
||||
public Q2Entity(String mailAdress, String password) {
|
||||
this.mailAdress = mailAdress;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getMailAdress() {
|
||||
return mailAdress;
|
||||
}
|
||||
|
||||
public void setMailAdress(String mailAdress) {
|
||||
this.mailAdress = mailAdress;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.demo.logic;
|
||||
|
||||
import com.example.demo.domain.Q2Entity;
|
||||
|
||||
public class Q2Logic {
|
||||
public String Createmessage(Q2Entity entity) {
|
||||
//引数をもとにメッセージの作成
|
||||
String message;
|
||||
message = "メールアドレス:" + entity.getMailAdress() + " パスワード:" + entity.getPassword();
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.example.demo.persistence;
|
||||
|
||||
import com.example.demo.domain.Q2Entity;
|
||||
|
||||
public class Q2Dao {
|
||||
//サービスクラスから引数を受け取る
|
||||
public Q2Entity CreateEntity(String mailaddres, String password) {
|
||||
//受け取った引数をエンティティクラス型のインスタンスに格納
|
||||
Q2Entity entity = new Q2Entity(mailaddres, password);
|
||||
//格納したインスタンスをサービスクラスに戻り値として返却
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.example.demo.presentation;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.example.demo.application.Q2Controller;
|
||||
|
||||
public class Q2View {
|
||||
|
||||
@Autowired
|
||||
Q2Controller cont;
|
||||
|
||||
public void Empscan() {
|
||||
//メールアドレスとパスワードの入力
|
||||
System.out.println("メールアドレスを入力してください");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String Mailadress = sc.nextLine();
|
||||
System.out.println("パスワードを入力してください");
|
||||
String Password = sc.nextLine();
|
||||
//入力した値をコントローラークラスのメソッドに引数として渡し、実行
|
||||
String message = cont.Empjudge(Mailadress, Password);
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.example.demo.domain.Q2Entity;
|
||||
import com.example.demo.persistence.Q2Dao;
|
||||
|
||||
public class Q2Service {
|
||||
|
||||
@Autowired
|
||||
Q2Dao dao;
|
||||
//エンティティクラスに引数を渡し実行
|
||||
public Q2Entity ServeEntity(String mailaddres, String password) {
|
||||
Q2Entity entity = dao.CreateEntity(mailaddres, password);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class SpringQ1ApplicationTests {
|
||||
class SpringQuestion2ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
@@ -3,11 +3,14 @@ package com.example.demo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import com.example.demo.presentaiton.Q1View;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringQ1Application {
|
||||
public class SpringQuestionApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringQ1Application.class, args);
|
||||
SpringApplication.run(SpringQuestionApplication.class, args);
|
||||
new Q1View().Empscan();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.example.demo.application;
|
||||
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
import com.example.demo.logic.Q1Logic;
|
||||
import com.example.demo.service.Q1Service;
|
||||
|
||||
public class SampleController {
|
||||
|
||||
public String Empjudge(String mailadress, String password) {
|
||||
String message;
|
||||
//パスワードとメールアドレスが正確かジャッジ
|
||||
if (mailadress.length() > 256 || password.length() < 8) {
|
||||
message = "メールアドレスもしくはパスワードが不正です";
|
||||
return message;
|
||||
} else {
|
||||
//サービスメソッドに引数を渡し実行
|
||||
Q1Entity entity = Q1Service.ServeEntity(mailadress, password);
|
||||
//ロジッククラスに引数を渡し実行
|
||||
message = Q1Logic.Createmessage(entity);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.example.demo.domain;
|
||||
|
||||
public class Q1Entity {
|
||||
private String mailAdress;
|
||||
private String password;
|
||||
|
||||
public Q1Entity(String mailAdress, String password) {
|
||||
this.mailAdress = mailAdress;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getMailAdress() {
|
||||
return mailAdress;
|
||||
}
|
||||
|
||||
public void setMailAdress(String mailAdress) {
|
||||
this.mailAdress = mailAdress;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.demo.logic;
|
||||
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
|
||||
public class Q1Logic {
|
||||
public static String Createmessage(Q1Entity entity) {
|
||||
//引数をもとにメッセージの作成
|
||||
String message;
|
||||
message = "メールアドレス:" + entity.getMailAdress() + " パスワード:" + entity.getPassword();
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.example.demo.persistence;
|
||||
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
|
||||
public class Q1Dao {
|
||||
//サービスクラスから引数を受け取る
|
||||
public static Q1Entity CreateEntity(String mailaddres, String password) {
|
||||
//受け取った引数をエンティティクラス型のインスタンスに格納
|
||||
Q1Entity entity = new Q1Entity(mailaddres, password);
|
||||
//格納したインスタンスをサービスクラスに戻り値として返却
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.example.demo.presentaiton;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import com.example.demo.application.SampleController;
|
||||
|
||||
public class Q1View {
|
||||
SampleController cont = new SampleController();
|
||||
|
||||
public void Empscan() {
|
||||
//メールアドレスとパスワードの入力
|
||||
System.out.println("メールアドレスを入力してください");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String Mailadress = sc.nextLine();
|
||||
System.out.println("パスワードを入力してください");
|
||||
String Password = sc.nextLine();
|
||||
//入力した値をコントローラークラスのメソッドに引数として渡し、実行
|
||||
String message = cont.Empjudge(Mailadress, Password);
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
import com.example.demo.persistence.Q1Dao;
|
||||
|
||||
public class Q1Service {
|
||||
//エンティティクラスに引数を渡し実行
|
||||
public static Q1Entity ServeEntity(String mailaddres, String password) {
|
||||
Q1Entity entity = Q1Dao.CreateEntity(mailaddres, password);
|
||||
return entity;
|
||||
|
||||
}
|
||||
}
|
||||
0
spring-Q1/mvnw → SpringQuestion3/mvnw
vendored
0
spring-Q1/mvnw → SpringQuestion3/mvnw
vendored
@@ -9,10 +9,9 @@
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>spring-Q1</artifactId>
|
||||
<artifactId>SpringQuestion3</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>spring-Q1</name>
|
||||
<name>SpringQuestion3</name>
|
||||
<description/>
|
||||
<url/>
|
||||
<licenses>
|
||||
@@ -33,17 +32,17 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<artifactId>spring-boot-starter-data-jpa-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
import com.example.demo.presentation.Q3View;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan
|
||||
public class SpringQuestion3Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext context =
|
||||
SpringApplication.run(SpringQuestion3Application.class, args);
|
||||
Q3View view = context.getBean(Q3View.class);
|
||||
view.Empscan();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.example.demo.application;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import com.example.demo.domain.Employee;
|
||||
import com.example.demo.logic.Q3Logic;
|
||||
import com.example.demo.service.Q3Service;
|
||||
|
||||
@Controller
|
||||
public class Q3Controller {
|
||||
@Autowired
|
||||
Q3Service serv;
|
||||
@Autowired
|
||||
Q3Logic logic;
|
||||
|
||||
public String Empjudge(String mailadress, String password) {
|
||||
String message;
|
||||
//パスワードとメールアドレスが正確かジャッジ
|
||||
if (mailadress.length() > 256 ) {
|
||||
message = "メールアドレスもしくはパスワードが不正です";
|
||||
return message;
|
||||
} else {
|
||||
//サービスクラスのメソッド実行
|
||||
List<Employee> list= serv.getuserDate();
|
||||
//ロジッククラスに引数を渡し実行
|
||||
message = logic.Createmessage(mailadress, password, list);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.example.demo.logic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.example.demo.domain.Employee;
|
||||
|
||||
@Component
|
||||
public class Q3Logic {
|
||||
|
||||
public String Createmessage(String mailadress, String password, List<Employee> list) {
|
||||
for (Employee emp : list) {
|
||||
if (mailadress.equals(emp.getMailAddress())
|
||||
&& password.equals(emp.getPassword())) {
|
||||
return emp.getNmEmployee();
|
||||
}
|
||||
}
|
||||
return "該当のデータが存在しません。";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.example.demo.persistence;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.demo.domain.Employee;
|
||||
|
||||
@Repository
|
||||
public interface EmployeeRepository extends JpaRepository<Employee, Integer> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.example.demo.presentation;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.example.demo.application.Q3Controller;
|
||||
|
||||
@Component
|
||||
public class Q3View {
|
||||
@Autowired
|
||||
Q3Controller cont;
|
||||
|
||||
public void Empscan() {
|
||||
//メールアドレスとパスワードの入力
|
||||
System.out.println("メールアドレスを入力してください");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String Mailadress = sc.nextLine();
|
||||
System.out.println("パスワードを入力してください");
|
||||
String Password = sc.nextLine();
|
||||
//入力した値をコントローラークラスのメソッドに引数として渡し、実行
|
||||
String message = cont.Empjudge(Mailadress, Password);
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.domain.Employee;
|
||||
import com.example.demo.persistence.EmployeeRepository;
|
||||
|
||||
@Service
|
||||
public class Q3Service {
|
||||
@Autowired
|
||||
EmployeeRepository dao;
|
||||
//エンティティクラスに引数を渡し実行
|
||||
public List<Employee> getuserDate(){
|
||||
return dao.findAll();//インタフェースに搭載されている全検索メソッド
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
spring.application.name=SpringQuestion3
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/rezodb
|
||||
spring.datasource.username=rezouser
|
||||
spring.datasource.password=Rezo_0000
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class SpringQuestion3ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(SpringQ1Application.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.example.demo.application;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
import com.example.demo.logic.Q1Logic;
|
||||
import com.example.demo.service.Q1Service;
|
||||
|
||||
@Controller
|
||||
public class Q1Controller {
|
||||
//sarviceクラスとlogicクラスをコンストラクタ経由で手動
|
||||
private final Q1Service service;
|
||||
private final Q1Logic logic;
|
||||
|
||||
public Q1Controller(Q1Service service, Q1Logic logic) {
|
||||
this.service = service;
|
||||
this.logic = logic;
|
||||
}
|
||||
|
||||
public String checkLogin(String email, String password) {
|
||||
//メールアドレスが256文字より大きい場合のエラーメッセージ
|
||||
if (email.length() > 256) {
|
||||
return "メールアドレスもしくはパスワードが不正です";
|
||||
}
|
||||
//パスワードが8文字より小さい場合のエラーメッセージ
|
||||
if (password.length() < 8) {
|
||||
return "メールアドレスもしくはパスワードが不正です";
|
||||
}
|
||||
//Serviceクラスのメソッドの引数にアドレスとパスワードを渡す
|
||||
Q1Entity serviceResult = service.authenticateUser(email, password);
|
||||
//Serviceクラスのメソッドの戻り値をLogicクラスのメソッドに引数として渡す
|
||||
String logicResult = logic.formatLoginInfo(serviceResult);
|
||||
//Logicクラスのメソッドの戻り値をViewクラスへ返却
|
||||
return logicResult;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.example.demo.domain;
|
||||
|
||||
public class Q1Entity {
|
||||
//フィールド宣言
|
||||
private String mailAddress;
|
||||
private String password;
|
||||
|
||||
// //引数なしのコンストラクタ
|
||||
// public Q1Entity() {
|
||||
// }
|
||||
|
||||
//コンストラクタで上記フィールド初期化
|
||||
public Q1Entity(String mailAddress, String password) {
|
||||
this.mailAddress = mailAddress;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
//ゲッター・セッター作成
|
||||
public String getMailAddress() {
|
||||
return mailAddress;
|
||||
}
|
||||
|
||||
public void setMailAddress(String mailAddress) {
|
||||
this.mailAddress = mailAddress;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.example.demo.logic;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
|
||||
@Component
|
||||
public class Q1Logic {
|
||||
//formatメソッド作成
|
||||
public String formatLoginInfo(Q1Entity entity) {
|
||||
//引数の内容から文字列作成、Controllerクラスへ返却
|
||||
return "メールアドレス:" + entity.getMailAddress() + "パスワード:" + entity.getPassword();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.example.demo.persistence;
|
||||
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
|
||||
public class Q1Dao {
|
||||
//serviceクラスから渡ってきた引数の引き取り
|
||||
public Q1Entity createEntity(String email, String password) {
|
||||
//エンティティのインスタンス化
|
||||
Q1Entity entity = new Q1Entity(email, password);
|
||||
//セッターで引数を格納
|
||||
entity.setMailAddress(email);
|
||||
entity.setPassword(password);
|
||||
//格納したインスタンスをserviceクラスへ戻り値として返却
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.example.demo.presentation;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.example.demo.application.Q1Controller;
|
||||
|
||||
@Component
|
||||
public class Q1View {
|
||||
|
||||
//Controllerクラスコンストラクタ経由で手動注入
|
||||
private final Q1Controller cont;
|
||||
|
||||
public Q1View(Q1Controller cont) {
|
||||
this.cont = cont;
|
||||
}
|
||||
|
||||
//Q1Displayメソッドを定義
|
||||
public void display() {
|
||||
//java.util.Scannerクラスの変数scanner準備
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
//メールアドレス入力、入力受け取り
|
||||
System.out.println("メールアドレスを入力してください");
|
||||
String email = scanner.nextLine();
|
||||
//パスワード入力、入力受け取り
|
||||
System.out.println("パスワードを入力してください");
|
||||
String password = scanner.nextLine();
|
||||
//Controllerクラスのメソッド戻り値
|
||||
String result = cont.checkLogin(email, password);
|
||||
//Controllerクラスの戻り値を出力
|
||||
System.out.println(result);
|
||||
//Scanner終了
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.domain.Q1Entity;
|
||||
import com.example.demo.persistence.Q1Dao;
|
||||
|
||||
@Service
|
||||
public class Q1Service {
|
||||
//daoクラスをコンストラクタ経由で手動注入
|
||||
private final Q1Dao dao;
|
||||
|
||||
public Q1Service(Q1Dao dao) {
|
||||
this.dao = dao;
|
||||
}
|
||||
|
||||
//controllerクラスからの引数受け取り
|
||||
public Q1Entity authenticateUser(String email, String password) {
|
||||
//daoクラスのメソッドへ引数として渡す
|
||||
Q1Entity checkLogin = dao.createEntity(email, password);
|
||||
//Daoクラスからの戻り値をControllerクラスへ返却
|
||||
return checkLogin;
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
spring.application.name=spring-Q1
|
||||
Reference in New Issue
Block a user