работает Артём говноед и Коля тоже

This commit is contained in:
maxnes3 2023-05-11 21:56:05 +04:00
parent c8e62cbc4f
commit 059729f986
10 changed files with 118 additions and 217 deletions

View File

@ -16,7 +16,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'com.h2database:h2:2.1.210'
implementation 'org.hibernate.validator:hibernate-validator:7.0.1.Final'
implementation 'org.hibernate.validator:hibernate-validator:6.0.17.Final'
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

Binary file not shown.

View File

@ -1288,3 +1288,119 @@ GROUP BY a.id [90079-210]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:1589)
2023-05-11 21:51:50 database: wrong user or password; user: "SA"
org.h2.message.DbException: Неверное имя пользователя или пароль
Wrong user name or password [28000-210]
at org.h2.message.DbException.get(DbException.java:227)
at org.h2.message.DbException.get(DbException.java:203)
at org.h2.message.DbException.get(DbException.java:192)
at org.h2.engine.Engine.openSession(Engine.java:154)
at org.h2.engine.Engine.openSession(Engine.java:222)
at org.h2.engine.Engine.createSession(Engine.java:201)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288)
at org.h2.server.web.WebServer.getConnection(WebServer.java:807)
at org.h2.server.web.WebApp.login(WebApp.java:1033)
at org.h2.server.web.WebApp.process(WebApp.java:226)
at org.h2.server.web.WebApp.processRequest(WebApp.java:176)
at org.h2.server.web.WebServlet.doGet(WebServlet.java:129)
at org.h2.server.web.WebServlet.doPost(WebServlet.java:166)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль
Wrong user name or password [28000-210]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:529)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
... 50 more
2023-05-11 21:51:59 database: wrong user or password; user: "SA"
org.h2.message.DbException: Неверное имя пользователя или пароль
Wrong user name or password [28000-210]
at org.h2.message.DbException.get(DbException.java:227)
at org.h2.message.DbException.get(DbException.java:203)
at org.h2.message.DbException.get(DbException.java:192)
at org.h2.engine.Engine.openSession(Engine.java:154)
at org.h2.engine.Engine.openSession(Engine.java:222)
at org.h2.engine.Engine.createSession(Engine.java:201)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288)
at org.h2.server.web.WebServer.getConnection(WebServer.java:807)
at org.h2.server.web.WebApp.login(WebApp.java:1033)
at org.h2.server.web.WebApp.process(WebApp.java:226)
at org.h2.server.web.WebApp.processRequest(WebApp.java:176)
at org.h2.server.web.WebServlet.doGet(WebServlet.java:129)
at org.h2.server.web.WebServlet.doPost(WebServlet.java:166)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль
Wrong user name or password [28000-210]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:529)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
... 50 more

View File

@ -8,7 +8,7 @@ import java.io.IOException;
import java.util.List;
@RestController
@RequestMapping("/post")
@RequestMapping("/book")
public class BookController {
private final BookService bookService;

View File

@ -1,35 +0,0 @@
package ru.ip.labworks.labworks.calculator.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ru.ip.labworks.labworks.calculator.service.CalculatorService;
@RestController
public class UserController {
private CalculatorService calculatorService;
public UserController(CalculatorService calculatorService){
this.calculatorService = calculatorService;
}
@GetMapping("/+")
public String workPlus(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){
return (String) calculatorService.Plus(type, arg1, arg2);
}
@GetMapping("/-")
public String workMinus(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){
return (String) calculatorService.Minus(type, arg1, arg2);
}
@GetMapping("/*")
public String workMulti(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){
return (String) calculatorService.Multi(type, arg1, arg2);
}
@GetMapping("/:")
public String workDiv(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){
return (String) calculatorService.Div(type, arg1, arg2);
}
}

View File

@ -1,48 +0,0 @@
package ru.ip.labworks.labworks.calculator.domain;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
@Component(value = "array")
public class ArrayCalculator implements ITypeCalculator<ArrayList<String>> {
@Override
public ArrayList<String> Plus(ArrayList<String> arg1, ArrayList<String> arg2) {
ArrayList<String> result = new ArrayList<>();
for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){
result.add(arg1.get(i) + arg2.get(i));
}
return result;
}
@Override
public ArrayList<String> Minus(ArrayList<String> arg1, ArrayList<String> arg2) {
ArrayList<String> result = new ArrayList<>();
for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){
result.add(arg1.get(i).replace(arg2.get(i), ""));
}
return result;
}
@Override
public ArrayList<String> Multi(ArrayList<String> arg1, ArrayList<String> arg2) {
ArrayList<String> result = new ArrayList<>();
for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){
String temp = "";
for (int j = 0; j < Integer.parseInt(arg2.get(i)); ++j){
temp += arg1.get(i);
}
result.add(temp);
}
return result;
}
@Override
public ArrayList<String> Div(ArrayList<String> arg1, ArrayList<String> arg2) {
ArrayList<String> result = new ArrayList<>();
for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){
result.add(arg1.get(i).substring(0, Integer.parseInt(arg2.get(i))));
}
return result;
}
}

View File

@ -1,9 +0,0 @@
package ru.ip.labworks.labworks.calculator.domain;
public interface ITypeCalculator<T> {
T Plus(T arg1, T arg2);
T Minus(T arg1, T arg2);
T Multi(T arg1, T arg2);
T Div(T arg1, T arg2);
}

View File

@ -1,26 +0,0 @@
package ru.ip.labworks.labworks.calculator.domain;
import org.springframework.stereotype.Component;
@Component(value = "int")
public class IntCalculator implements ITypeCalculator<Integer>{
@Override
public Integer Plus(Integer arg1, Integer arg2) {
return arg1 + arg2;
}
@Override
public Integer Minus(Integer arg1, Integer arg2) {
return arg1 - arg2;
}
@Override
public Integer Multi(Integer arg1, Integer arg2) {
return arg1 * arg2;
}
@Override
public Integer Div(Integer arg1, Integer arg2) {
return arg1 / arg2;
}
}

View File

@ -1,31 +0,0 @@
package ru.ip.labworks.labworks.calculator.domain;
import org.springframework.stereotype.Component;
@Component(value = "string")
public class StringCalculator implements ITypeCalculator<String>{
@Override
public String Plus(String arg1, String arg2) {
return arg1 + arg2;
}
@Override
public String Minus(String arg1, String arg2) {
return arg1.replaceAll(arg2, "");
}
@Override
public String Multi(String arg1, String arg2) {
String result = "";
for (int i = 0; i < Integer.parseInt(arg2); ++i){
result += arg1;
}
return result;
}
@Override
public String Div(String arg1, String arg2) {
String result = arg1.substring(0, arg1.length() / Integer.parseInt(arg2));
return result;
}
}

View File

@ -1,66 +0,0 @@
package ru.ip.labworks.labworks.calculator.service;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import ru.ip.labworks.labworks.calculator.domain.ITypeCalculator;
import java.util.ArrayList;
import java.util.Arrays;
@Service
public class CalculatorService {
private final ApplicationContext applicationContext;
private ITypeCalculator typeCalculator;
private Object arg1;
private Object arg2;
public CalculatorService(ApplicationContext applicationContext){
this.applicationContext = applicationContext;
}
private boolean ValidateParams(Object value1, Object value2, String type){
typeCalculator = (ITypeCalculator)applicationContext.getBean(type);
try {
switch (type) {
case "int" -> {
arg1 = Integer.valueOf(value1.toString());
arg2 = Integer.valueOf(value2.toString());
}
case "array" -> {
arg1 = new ArrayList<>(Arrays.asList(value1.toString().split(",")));
arg2 = new ArrayList<>(Arrays.asList(value2.toString().split(",")));
}
case "string" -> {
arg1 = value1.toString();
arg2 = value2.toString();
}
}
}
catch (Exception ex){
return false;
}
return true;
}
public Object Plus(String type, Object arg1, Object arg2){
if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные");
return String.format("%s", typeCalculator.Plus(this.arg1, this.arg2));
}
public Object Minus(String type, Object arg1, Object arg2){
if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные");
return String.format("%s", typeCalculator.Minus(this.arg1, this.arg2));
}
public Object Multi(String type, Object arg1, Object arg2){
if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные");
return String.format("%s", typeCalculator.Multi(this.arg1, this.arg2));
}
public Object Div(String type, Object arg1, Object arg2){
if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные");
return String.format("%s", typeCalculator.Div(this.arg1, this.arg2));
}
}