1 Commits

Author SHA1 Message Date
0fdefe614b SpringFramework課題Q1です 2026-10-08 16:17:42 +09:00
44 changed files with 523 additions and 615 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/.metadata/

3
Q1/.gitattributes vendored Normal file
View File

@@ -0,0 +1,3 @@
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary

37
Q1/.gitignore vendored Normal file
View File

@@ -0,0 +1,37 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/

28
Q1/build.gradle Normal file
View File

@@ -0,0 +1,28 @@
plugins {
id 'java'
id 'org.springframework.boot' version '4.1.1'
id 'io.spring.dependency-management' version '1.1.7'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
}

BIN
Q1/gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

248
Q1/gradlew vendored Normal file
View File

@@ -0,0 +1,248 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# gradlew start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh gradlew
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

82
Q1/gradlew.bat vendored Normal file
View File

@@ -0,0 +1,82 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem gradlew startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables, and ensure extensions are enabled
setlocal EnableExtensions
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
"%COMSPEC%" /c exit 1
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
"%COMSPEC%" /c exit 1
:execute
@rem Setup the command line
@rem Execute gradlew
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
@rem which allows us to clear the local environment before executing the java command
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
:exitWithErrorLevel
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
"%COMSPEC%" /c exit %ERRORLEVEL%

1
Q1/settings.gradle Normal file
View File

@@ -0,0 +1 @@
rootProject.name = 'Q1'

View File

@@ -0,0 +1,20 @@
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.Q1View;
@SpringBootApplication
@ComponentScan
public class Q1Application {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(Q1Application.class, args);
Q1View Q1 = context.getBean(Q1View.class);
Q1.dummyDisplay();
}
}

View File

@@ -0,0 +1,29 @@
package com.example.demo.application;
import org.springframework.beans.factory.annotation.Autowired;
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 {
@Autowired
Q1Service service;
@Autowired
Q1logic logic;
public String show(String mailAddress, String password) {
if (mailAddress.length() > 256 && password.length() < 8) {
System.out.println("メールアドレスもしくはパスワードが不正です");
}
//データを受け取る
Q1Entity en = service.getUserData(mailAddress, password);
//ロジッククラスにデータを送る
//logic.logic(en.getMailAddress(), en.getPassword());
return logic.logic(en.getMailAddress(), en.getPassword());
}
}

View File

@@ -4,11 +4,6 @@ public class Q1Entity {
private String mailAddress; private String mailAddress;
private String password; private String password;
public Q1Entity(String mail, String pass) {
mailAddress = mail;
password = pass;
}
public String getMailAddress() { public String getMailAddress() {
return mailAddress; return mailAddress;
} }

View File

@@ -0,0 +1,11 @@
package com.example.demo.logic;
import org.springframework.stereotype.Component;
@Component
public class Q1logic {
public String logic(String mailAddress, String password) {
String st ="メールアドレス:" + mailAddress + "\t" +"パスワード:" + password;
return st;
}
}

View File

@@ -0,0 +1,18 @@
package com.example.demo.persistence;
import org.springframework.stereotype.Repository;
import com.example.demo.domain.Q1Entity;
@Repository
public class Q1Dao {
public Q1Entity findAll(String mailAddress, String password) {
Q1Entity mp = new Q1Entity();
//引数を受け取って格納
mp.setMailAddress(mailAddress);
mp.setPassword(password);
return mp;
}
}

View File

@@ -0,0 +1,32 @@
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 cont;
public void dummyDisplay() {
Scanner scanner = new Scanner(System.in);
System.out.println("メールアドレスを入力してください");
String mail = scanner.nextLine();
Scanner scanner2 = new Scanner(System.in);
System.out.println("パスワードを入力してください");
String pass = scanner.nextLine();
scanner.close();
scanner2.close();
String result = cont.show(mail, pass);
System.out.println(result);
}
}

View File

@@ -11,7 +11,7 @@ public class Q1Service {
@Autowired @Autowired
Q1Dao dao; Q1Dao dao;
public Q1Entity getEntity(String mail, String pass) { public Q1Entity getUserData(String mailAddress, String password) {
return dao.newInstance(mail, pass); return dao.findAll(mailAddress, password);
} }
} }

View File

@@ -0,0 +1 @@
spring.application.name=Q1

View File

@@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest @SpringBootTest
class SpringExampleApplicationTests { class Q1ApplicationTests {
@Test @Test
void contextLoads() { void contextLoads() {

View File

@@ -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);
}
}

View File

@@ -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();
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -1,28 +0,0 @@
package com.example.demo.application;
import org.springframework.stereotype.Controller;
import com.example.demo.logic.Q3Logic;
import com.example.demo.service.Q3Service;
@Controller
public class Q3Controller {
private final Q3Service ser;
private final Q3Logic log;
public Q3Controller(Q3Service ser, Q3Logic log) {
this.ser = ser;
this.log = 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);
}
}

View File

@@ -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();
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -1,7 +0,0 @@
package com.example.demo.logic;
public class Q2Logic {
public String stringCreate(String mail, String pass) {
return ("Q2 メールアドレス:" + mail + " パスワード:" + pass);
}
}

View File

@@ -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 "該当のデータが存在しません。";
}
}

View File

@@ -1,14 +0,0 @@
package com.example.demo.persistence;
import java.util.List;
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> {
public List<Employee> findAll();
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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));
}
}

View File

@@ -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));
}
}

View File

@@ -1,29 +0,0 @@
package com.example.demo.presentation;
import java.util.Scanner;
import org.springframework.stereotype.Component;
import com.example.demo.application.Q3Controller;
@Component
public class Q3View {
private final Q3Controller con;
public Q3View(Q3Controller con) {
this.con = 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));
}
}

View File

@@ -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);
}
}

View File

@@ -1,21 +0,0 @@
package com.example.demo.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.example.demo.domain.Employee;
import com.example.demo.persistence.EmployeeRepository;
@Service
public class Q3Service {
EmployeeRepository empre;
public Q3Service(EmployeeRepository empre) {
this.empre = empre;
}
public List<Employee> allDateGet() {
return empre.findAll();
}
}

View File

@@ -1,43 +0,0 @@
package com.example.demo.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class InitialController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index() {
return "login";// login+html
}
@RequestMapping(value = "/doLogout", method = RequestMethod.POST)
public String doLogout() {
return "login";
}
@RequestMapping(value = "/doLogin", method = RequestMethod.POST)
public String doLogin() {
return "menu";
}
@RequestMapping(value = "/doSelect", method = RequestMethod.POST)
public String doSelect() {
return "select";
}
@RequestMapping(value = "/doInsert", method = RequestMethod.POST)
public String doInsert() {
return "insert";
}
@RequestMapping(value = "/doUpdate", method = RequestMethod.POST)
public String doUpdate() {
return "update";
}
@RequestMapping(value = "/doDelete", method = RequestMethod.POST)
public String doDelete() {
return "delete";
}
}

View File

@@ -1,16 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>デリートページ</title>
</head>
<body>
<h1>デリートページ</h1>
<form action="doLogin" method="POST">
<input type="submit" value="戻る">
</form>
<form action="doLogout" method="POST">
<input type="submit" value="ログアウト">
</form>
</body>
</html>

View File

@@ -1,16 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>インサートページ</title>
</head>
<body>
<h1>インサートページ</h1>
<form action="doLogin" method="POST">
<input type="submit" value="戻る">
</form>
<form action="doLogout" method="POST">
<input type="submit" value="ログアウト">
</form>
</body>
</html>

View File

@@ -1,13 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>ログインページ</title>
</head>
<body>
<h1>ログインページ</h1>
<form action="doLogin" method="POST">
<input type="submit" value="ログイン">
</form>
</body>
</html>

View File

@@ -1,26 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>メニューページ</title>
</head>
<body>
<h1>メニューページ</h1>
<form action="doSelect" method="POST">
<input type="submit" value="検索">
</form>
<form action="doInsert" method="POST">
<input type="submit" value="登録">
</form>
<form action="doUpdate" method="POST">
<input type="submit" value="更新">
</form>
<form action="doDelete" method="POST">
<input type="submit" value="削除">
</form>
<form action="doLogout" method="POST">
<input type="submit" value="ログアウト">
</form>
</body>
</html>

View File

@@ -1,16 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>セレクトページ</title>
</head>
<body>
<h1>セレクトページ</h1>
<form action="doLogin" method="POST">
<input type="submit" value="戻る">
</form>
<form action="doLogout" method="POST">
<input type="submit" value="ログアウト">
</form>
</body>
</html>

View File

@@ -1,16 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>アップデートページ</title>
</head>
<body>
<h1>アップデートページ</h1>
<form action="doLogin" method="POST">
<input type="submit" value="戻る">
</form>
<form action="doLogout" method="POST">
<input type="submit" value="ログアウト">
</form>
</body>
</html>