Q2
This commit is contained in:
@@ -3,16 +3,23 @@ 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.presentation.Q1View;
|
||||
import com.example.demo.config.Q2Config;
|
||||
import com.example.demo.presentation.Q2View;
|
||||
|
||||
@SpringBootApplication
|
||||
@Import(Q2Config.class)
|
||||
public class SpringExampleApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// ConfigurableApplicationContext context = SpringApplication.run(SpringExampleApplication.class, args);
|
||||
// Q1View view = context.getBean(Q1View.class);
|
||||
// view.mailpassPrint();
|
||||
ConfigurableApplicationContext context = SpringApplication.run(SpringExampleApplication.class, args);
|
||||
Q1View view = context.getBean(Q1View.class);
|
||||
Q2View view = context.getBean(Q2View.class);
|
||||
view.mailpassPrint();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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 ser;
|
||||
@Autowired
|
||||
Q2Logic log;
|
||||
|
||||
public String displaySentence(String mail, String pass) {
|
||||
if (mail.length() > 256) {
|
||||
return "メールアドレスもしくはパスワードが不正です";
|
||||
}
|
||||
if (pass.length() < 8) {
|
||||
return "メールアドレスもしくはパスワードが不正です";
|
||||
}
|
||||
Q2Entity ent = ser.getEntity(mail, pass);
|
||||
|
||||
return log.stringCreate(ent.getMailAddress(), ent.getPassword());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.example.demo.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.example.demo.SpringExampleApplication;
|
||||
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 {
|
||||
|
||||
private final SpringExampleApplication springExampleApplication;
|
||||
|
||||
Q2Config(SpringExampleApplication springExampleApplication) {
|
||||
this.springExampleApplication = springExampleApplication;
|
||||
}
|
||||
|
||||
@Bean
|
||||
Q2View q2View() {
|
||||
return new Q2View();
|
||||
}
|
||||
|
||||
@Bean
|
||||
Q2Controller q2Controller() {
|
||||
return new Q2Controller();
|
||||
}
|
||||
|
||||
@Bean
|
||||
Q2Service q2Service() {
|
||||
return new Q2Service();
|
||||
}
|
||||
|
||||
@Bean
|
||||
Q2Dao q2Dao() {
|
||||
return new Q2Dao();
|
||||
}
|
||||
|
||||
@Bean
|
||||
Q2Logic q2Logic() {
|
||||
return new Q2Logic();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.example.demo.domain;
|
||||
|
||||
public class Q2Entity {
|
||||
private String mailAddress;
|
||||
private String password;
|
||||
|
||||
public Q2Entity(String mail, String pass) {
|
||||
mailAddress = mail;
|
||||
password = pass;
|
||||
}
|
||||
|
||||
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,8 +1,8 @@
|
||||
package com.example.demo.logic;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Controller
|
||||
@Component
|
||||
public class Q1Logic {
|
||||
public String stringCreate(String mail, String pass) {
|
||||
return ("メールアドレス:" + mail + " パスワード:" + pass);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.example.demo.logic;
|
||||
|
||||
public class Q2Logic {
|
||||
public String stringCreate(String mail, String pass) {
|
||||
return ("Q2 メールアドレス:" + mail + " パスワード:" + pass);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.example.demo.persistence;
|
||||
|
||||
import com.example.demo.domain.Q2Entity;
|
||||
|
||||
public class Q2Dao {
|
||||
public Q2Entity newInstance(String mail, String pass) {
|
||||
Q2Entity entity = new Q2Entity(mail, pass);
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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 con;
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
public void mailpassPrint() {
|
||||
//入力
|
||||
String mail = scan.nextLine().strip();
|
||||
String pass = scan.nextLine().strip();
|
||||
|
||||
System.out.println(con.displaySentence(mail, pass));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
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 getEntity(String mail, String pass) {
|
||||
return dao.newInstance(mail, pass);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user