Compare commits
1 Commits
85e95d5104
...
a-takayama
| Author | SHA1 | Date | |
|---|---|---|---|
| 880d91f71d |
Binary file not shown.
@@ -1,12 +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(SpringExampleApplication.class);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
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.Q3View;
|
||||
|
||||
@SpringBootApplication
|
||||
//@Import(Q2Config.class)//Q2
|
||||
public class SpringExampleApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//Q1
|
||||
// ConfigurableApplicationContext context = SpringApplication.run(SpringExampleApplication.class, args);
|
||||
// Q1View view = context.getBean(Q1View.class);
|
||||
// view.mailpassPrint();
|
||||
//Q2
|
||||
// ConfigurableApplicationContext context = SpringApplication.run(SpringExampleApplication.class, args);
|
||||
// Q2View view = context.getBean(Q2View.class);
|
||||
// view.mailpassPrint();
|
||||
//Q3
|
||||
ConfigurableApplicationContext context = SpringApplication.run(SpringExampleApplication.class, args);
|
||||
Q3View view = context.getBean(Q3View.class);
|
||||
view.usernameSearch();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.example.demo.application;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import com.example.demo.logic.Q3Logic;
|
||||
import com.example.demo.service.Q3Service;
|
||||
|
||||
@Controller
|
||||
public class Q3Controller {
|
||||
@Autowired
|
||||
Q3Service ser;
|
||||
@Autowired
|
||||
Q3Logic log;
|
||||
|
||||
public String usernameSearch(String mail, String pass) {
|
||||
if (mail.length() > 256) {
|
||||
return "メールアドレスもしくはパスワードが不正です";
|
||||
}
|
||||
if (pass.length() < 8) {
|
||||
return "メールアドレスもしくはパスワードが不正です";
|
||||
}
|
||||
|
||||
return log.match(ser.allDateGet(), mail, pass);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.example.demo.domain;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@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;
|
||||
|
||||
public Integer getIdEmployee() {
|
||||
return idEmployee;
|
||||
}
|
||||
|
||||
public void setIdEmployee(Integer idEmployee) {
|
||||
this.idEmployee = idEmployee;
|
||||
}
|
||||
|
||||
public String getNmEmployee() {
|
||||
return nmEmployee;
|
||||
}
|
||||
|
||||
public void setNmEmployee(String nmEmployee) {
|
||||
this.nmEmployee = nmEmployee;
|
||||
}
|
||||
|
||||
public String getKnEmployee() {
|
||||
return knEmployee;
|
||||
}
|
||||
|
||||
public void setKnEmployee(String knEmployee) {
|
||||
this.knEmployee = knEmployee;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Integer getIdDepartment() {
|
||||
return idDepartment;
|
||||
}
|
||||
|
||||
public void setIdDepartment(Integer idDepartment) {
|
||||
this.idDepartment = idDepartment;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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,10 +0,0 @@
|
||||
package com.example.demo.logic;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Q1Logic {
|
||||
public String stringCreate(String mail, String pass) {
|
||||
return ("メールアドレス:" + mail + " パスワード:" + pass);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.example.demo.logic;
|
||||
|
||||
public class Q2Logic {
|
||||
public String stringCreate(String mail, String pass) {
|
||||
return ("Q2 メールアドレス:" + mail + " パスワード:" + pass);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
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 match(List<Employee> list, String mail, String pass) {
|
||||
|
||||
for (Employee emp : list) {
|
||||
if (emp.getMailAddress().equals(mail) && emp.getPassword().equals(pass)) {
|
||||
return emp.getNmEmployee();
|
||||
}
|
||||
}
|
||||
|
||||
return "該当のデータが存在しません。";
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
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> {
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
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 con;
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
public void usernameSearch() {
|
||||
//入力
|
||||
System.out.println("メールアドレスを入力");
|
||||
String mail = scan.nextLine().strip();
|
||||
System.out.println("パスワードを入力");
|
||||
String pass = scan.nextLine().strip();
|
||||
|
||||
System.out.println(con.usernameSearch(mail, pass));
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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 empre;
|
||||
|
||||
public List<Employee> allDateGet() {
|
||||
return empre.findAll();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
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