Q1
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
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(SpringExampleApplication.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.example.demo;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
|
||||||
|
import com.example.demo.presentation.Q1View;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class SpringExampleApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ConfigurableApplicationContext context = SpringApplication.run(SpringExampleApplication.class, args);
|
||||||
|
Q1View view = context.getBean(Q1View.class);
|
||||||
|
view.mailpassPrint();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.example.demo.application;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import com.example.demo.domain.Q1Entity;
|
||||||
|
import com.example.demo.logic.Q1Logic;
|
||||||
|
import com.example.demo.service.Q1Service;
|
||||||
|
|
||||||
|
@org.springframework.stereotype.Controller
|
||||||
|
public class Q1Controller {
|
||||||
|
@Autowired
|
||||||
|
Q1Service ser;
|
||||||
|
@Autowired
|
||||||
|
Q1Logic log;
|
||||||
|
|
||||||
|
public String displaySentence(String mail, String pass) {
|
||||||
|
if (mail.length() > 256) {
|
||||||
|
return "メールアドレスもしくはパスワードが不正です";
|
||||||
|
}
|
||||||
|
if (pass.length() < 8) {
|
||||||
|
return "メールアドレスもしくはパスワードが不正です";
|
||||||
|
}
|
||||||
|
Q1Entity ent = ser.getEntity(mail, pass);
|
||||||
|
|
||||||
|
return log.stringCreate(ent.getMailAddress(), ent.getPassword());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.example.demo.domain;
|
||||||
|
|
||||||
|
public class Q1Entity {
|
||||||
|
private String mailAddress;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public Q1Entity(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.example.demo.logic;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class Q1Logic {
|
||||||
|
public String stringCreate(String mail, String pass) {
|
||||||
|
return ("メールアドレス:" + mail + " パスワード:" + pass);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.example.demo.persistence;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.example.demo.domain.Q1Entity;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class Q1Dao {
|
||||||
|
public Q1Entity newInstance(String mail, String pass) {
|
||||||
|
Q1Entity entity = new Q1Entity(mail, pass);
|
||||||
|
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
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.Q1Controller;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class Q1View {
|
||||||
|
@Autowired
|
||||||
|
Q1Controller 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,17 @@
|
|||||||
|
package com.example.demo.service;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.domain.Q1Entity;
|
||||||
|
import com.example.demo.persistence.Q1Dao;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class Q1Service {
|
||||||
|
@Autowired
|
||||||
|
Q1Dao dao;
|
||||||
|
|
||||||
|
public Q1Entity getEntity(String mail, String pass) {
|
||||||
|
return dao.newInstance(mail, pass);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.example.demo;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class SpringExampleApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user