Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
d6368cf5bb
22 files changed
+115
-54
No files matched your search
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
package site.easystartup.easystartupcore.config;
|
package site.easystartup.easystartupcore.auth.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class MvcConfig implements WebMvcConfigurer {
|
public class LoginMvcConfig implements WebMvcConfigurer {
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
registry.addViewController("/login").setViewName("login");
|
registry.addViewController("/login").setViewName("login");
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.config;
|
package site.easystartup.easystartupcore.auth.config;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.controller;
|
package site.easystartup.easystartupcore.auth.controller;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import site.easystartup.easystartupcore.domain.Role;
|
import site.easystartup.easystartupcore.domain.Role;
|
||||||
import site.easystartup.easystartupcore.domain.User;
|
import site.easystartup.easystartupcore.domain.User;
|
||||||
import site.easystartup.easystartupcore.repos.UserRepo;
|
import site.easystartup.easystartupcore.repo.UserRepo;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package site.easystartup.easystartupcore.domain.forum;
|
|
||||||
|
|
||||||
public enum DiscussionStatus {
|
|
||||||
OPEN, CLOSED;
|
|
||||||
}
|
|
||||||
+8
-9
@@ -1,21 +1,15 @@
|
|||||||
package site.easystartup.easystartupcore.controller;
|
package site.easystartup.easystartupcore.forum.controller;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.core.userdetails.User;
|
import org.springframework.security.core.userdetails.User;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import site.easystartup.easystartupcore.domain.forum.Discussion;
|
import site.easystartup.easystartupcore.forum.filter.FilterService;
|
||||||
import site.easystartup.easystartupcore.domain.forum.Topic;
|
import site.easystartup.easystartupcore.forum.repo.TopicRepo;
|
||||||
import site.easystartup.easystartupcore.filter.FilterService;
|
|
||||||
import site.easystartup.easystartupcore.repos.forum.TopicRepo;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@@ -38,4 +32,9 @@ public class ForumController {
|
|||||||
model.addAttribute("discussions", discussions);
|
model.addAttribute("discussions", discussions);
|
||||||
return "my-discussions";
|
return "my-discussions";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/forum/new")
|
||||||
|
public String forumNew() {
|
||||||
|
return "topic-new";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.domain.forum;
|
package site.easystartup.easystartupcore.forum.domain;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.domain.forum;
|
package site.easystartup.easystartupcore.forum.domain;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package site.easystartup.easystartupcore.forum.domain;
|
||||||
|
|
||||||
|
public enum DiscussionStatus {
|
||||||
|
OPEN, CLOSED;
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.domain.forum;
|
package site.easystartup.easystartupcore.forum.domain;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
+5
-5
@@ -1,13 +1,13 @@
|
|||||||
package site.easystartup.easystartupcore.filter;
|
package site.easystartup.easystartupcore.forum.filter;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import site.easystartup.easystartupcore.domain.forum.Discussion;
|
import site.easystartup.easystartupcore.forum.domain.Discussion;
|
||||||
import site.easystartup.easystartupcore.domain.forum.DiscussionMessage;
|
import site.easystartup.easystartupcore.forum.domain.DiscussionMessage;
|
||||||
import site.easystartup.easystartupcore.repos.forum.DiscussionMessageRepo;
|
import site.easystartup.easystartupcore.forum.repo.DiscussionMessageRepo;
|
||||||
import site.easystartup.easystartupcore.repos.forum.DiscussionRepo;
|
import site.easystartup.easystartupcore.forum.repo.DiscussionRepo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package site.easystartup.easystartupcore.forum.repo;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import site.easystartup.easystartupcore.forum.domain.DiscussionMessage;
|
||||||
|
|
||||||
|
public interface DiscussionMessageRepo extends CrudRepository<DiscussionMessage, Long> {
|
||||||
|
}
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package site.easystartup.easystartupcore.repos.forum;
|
package site.easystartup.easystartupcore.forum.repo;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import site.easystartup.easystartupcore.domain.forum.Discussion;
|
import site.easystartup.easystartupcore.forum.domain.Discussion;
|
||||||
|
|
||||||
public interface DiscussionRepo extends CrudRepository<Discussion, Long> {
|
public interface DiscussionRepo extends CrudRepository<Discussion, Long> {
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package site.easystartup.easystartupcore.forum.repo;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import site.easystartup.easystartupcore.forum.domain.Topic;
|
||||||
|
|
||||||
|
public interface TopicRepo extends CrudRepository<Topic, Long> {
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.repos;
|
package site.easystartup.easystartupcore.repo;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import site.easystartup.easystartupcore.domain.User;
|
import site.easystartup.easystartupcore.domain.User;
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package site.easystartup.easystartupcore.repos.forum;
|
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
|
||||||
import site.easystartup.easystartupcore.domain.forum.Discussion;
|
|
||||||
import site.easystartup.easystartupcore.domain.forum.DiscussionMessage;
|
|
||||||
|
|
||||||
public interface DiscussionMessageRepo extends CrudRepository<DiscussionMessage, Long> {
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package site.easystartup.easystartupcore.repos.forum;
|
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
|
||||||
import site.easystartup.easystartupcore.domain.forum.Discussion;
|
|
||||||
import site.easystartup.easystartupcore.domain.forum.Topic;
|
|
||||||
|
|
||||||
public interface TopicRepo extends CrudRepository<Topic, Long> {
|
|
||||||
}
|
|
||||||
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
package site.easystartup.easystartupcore.config;
|
package site.easystartup.easystartupcore.storag.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import site.easystartup.easystartupcore.storage.FileLocalStorageService;
|
import site.easystartup.easystartupcore.storag.service.FileLocalStorageService;
|
||||||
import site.easystartup.easystartupcore.storage.StorageService;
|
import site.easystartup.easystartupcore.storag.service.StorageService;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class FileConfig {
|
public class FileConfig {
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.storage;
|
package site.easystartup.easystartupcore.storag.service;
|
||||||
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.storage;
|
package site.easystartup.easystartupcore.storag.service;
|
||||||
|
|
||||||
public class StorageFileNotFoundException extends RuntimeException {
|
public class StorageFileNotFoundException extends RuntimeException {
|
||||||
public StorageFileNotFoundException(String filename) {
|
public StorageFileNotFoundException(String filename) {
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.storage;
|
package site.easystartup.easystartupcore.storag.service;
|
||||||
|
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org"
|
||||||
|
xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Вход</title>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div.error {
|
||||||
|
color: #ff5967;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.logout {
|
||||||
|
color: #2c84ec;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
|
||||||
|
<form th:action="/forum/new" method="post">
|
||||||
|
<h1>Пожалуйста, введите данные новой темы</h1>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<input type="text" class="form-control" minlength="3" size="25" id="username" name="username" required placeholder="UserName">
|
||||||
|
<label for="username">Логин</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="password" name="password" minlength="3" id="password" required placeholder="Password123">
|
||||||
|
<label for="password">Пароль</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="remember-me"> Запомнить меня
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit">Войти</button>
|
||||||
|
|
||||||
|
<div th:if="${param.error}" class="error">
|
||||||
|
Неправильный логин или пароль.
|
||||||
|
</div>
|
||||||
|
<div th:if="${param.logout}" class="logout">
|
||||||
|
Вы вышли из аккаунта.
|
||||||
|
</div>
|
||||||
|
<input type="hidden" name="_csrf" th:value="${_csrf.token}">
|
||||||
|
<p>© 2022</p>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -10,8 +10,8 @@ import org.springframework.boot.test.mock.mockito.MockBean;
|
|||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.mock.web.MockMultipartFile;
|
import org.springframework.mock.web.MockMultipartFile;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import site.easystartup.easystartupcore.storage.StorageFileNotFoundException;
|
import site.easystartup.easystartupcore.storag.service.StorageFileNotFoundException;
|
||||||
import site.easystartup.easystartupcore.storage.StorageService;
|
import site.easystartup.easystartupcore.storag.service.StorageService;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|||||||
Reference in new issue
Block a user