Q1完了
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
package com.example.demo;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
import com.example.demo.presentaiton.Q1View;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class SpringQuestionApplication {
|
||||||
|
|
||||||
|
public static void main(String[] 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user