Added controller for FileUpload, refactor of main package, try to add forum system.
This commit is contained in:
1 parent
cf24d07a78
commit
4a9efbb06d
38 files changed
+165
-78
No files matched your search
@@ -1,5 +0,0 @@
|
|||||||
package site.easystartup.easystartupcore.forum.domain;
|
|
||||||
|
|
||||||
public enum DiscussionStatus {
|
|
||||||
OPEN, CLOSED;
|
|
||||||
}
|
|
||||||
+1
-7
@@ -1,15 +1,9 @@
|
|||||||
package site.easystartup.easystartupcore;
|
package site.easystartup.web;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class EasyStartupApplication {
|
public class EasyStartupApplication {
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore;
|
package site.easystartup.web;
|
||||||
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.auth.config;
|
package site.easystartup.web.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;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.auth.config;
|
package site.easystartup.web.auth.config;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.auth.controller;
|
package site.easystartup.web.auth.controller;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -7,9 +7,9 @@ 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 org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import site.easystartup.easystartupcore.domain.Role;
|
import site.easystartup.web.domain.Role;
|
||||||
import site.easystartup.easystartupcore.domain.User;
|
import site.easystartup.web.domain.User;
|
||||||
import site.easystartup.easystartupcore.repo.UserRepo;
|
import site.easystartup.web.repo.UserRepo;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
+2
-3
@@ -1,15 +1,14 @@
|
|||||||
package site.easystartup.easystartupcore.config;
|
package site.easystartup.web.config;
|
||||||
|
|
||||||
import org.modelmapper.ModelMapper;
|
import org.modelmapper.ModelMapper;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages = {"site.easystartup.easystartupcore"})
|
@ComponentScan(basePackages = {"site.easystartup.web"})
|
||||||
public class AppConfig {
|
public class AppConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
package site.easystartup.easystartupcore.controller;
|
package site.easystartup.web.controller;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.domain;
|
package site.easystartup.web.domain;
|
||||||
|
|
||||||
public enum Role {
|
public enum Role {
|
||||||
USER, PREMIUM, MODER, ADMIN;
|
USER, PREMIUM, MODER, ADMIN;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.domain;
|
package site.easystartup.web.domain;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.forum.controller;
|
package site.easystartup.web.forum.controller;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
@@ -11,9 +11,9 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import site.easystartup.easystartupcore.forum.domain.Topic;
|
import site.easystartup.web.forum.domain.Topic;
|
||||||
import site.easystartup.easystartupcore.forum.filter.ForumFilterService;
|
import site.easystartup.web.forum.filter.ForumFilterService;
|
||||||
import site.easystartup.easystartupcore.forum.repo.TopicRepo;
|
import site.easystartup.web.forum.repo.TopicRepo;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.forum.domain;
|
package site.easystartup.web.forum.domain;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.forum.domain;
|
package site.easystartup.web.forum.domain;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package site.easystartup.web.forum.domain;
|
||||||
|
|
||||||
|
public enum DiscussionStatus {
|
||||||
|
OPEN, CLOSED;
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.forum.domain;
|
package site.easystartup.web.forum.domain;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
+5
-5
@@ -1,13 +1,13 @@
|
|||||||
package site.easystartup.easystartupcore.forum.filter;
|
package site.easystartup.web.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.forum.domain.Discussion;
|
import site.easystartup.web.forum.domain.Discussion;
|
||||||
import site.easystartup.easystartupcore.forum.domain.DiscussionMessage;
|
import site.easystartup.web.forum.domain.DiscussionMessage;
|
||||||
import site.easystartup.easystartupcore.forum.repo.DiscussionMessageRepo;
|
import site.easystartup.web.forum.repo.DiscussionMessageRepo;
|
||||||
import site.easystartup.easystartupcore.forum.repo.DiscussionRepo;
|
import site.easystartup.web.forum.repo.DiscussionRepo;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package site.easystartup.easystartupcore.forum.repo;
|
package site.easystartup.web.forum.repo;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import site.easystartup.easystartupcore.forum.domain.DiscussionMessage;
|
import site.easystartup.web.forum.domain.DiscussionMessage;
|
||||||
|
|
||||||
public interface DiscussionMessageRepo extends CrudRepository<DiscussionMessage, Long> {
|
public interface DiscussionMessageRepo extends CrudRepository<DiscussionMessage, Long> {
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package site.easystartup.easystartupcore.forum.repo;
|
package site.easystartup.web.forum.repo;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import site.easystartup.easystartupcore.forum.domain.Discussion;
|
import site.easystartup.web.forum.domain.Discussion;
|
||||||
|
|
||||||
public interface DiscussionRepo extends CrudRepository<Discussion, Long> {
|
public interface DiscussionRepo extends CrudRepository<Discussion, Long> {
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package site.easystartup.easystartupcore.forum.repo;
|
package site.easystartup.web.forum.repo;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import site.easystartup.easystartupcore.forum.domain.Topic;
|
import site.easystartup.web.forum.domain.Topic;
|
||||||
|
|
||||||
public interface TopicRepo extends CrudRepository<Topic, Long> {
|
public interface TopicRepo extends CrudRepository<Topic, Long> {
|
||||||
}
|
}
|
||||||
+5
-7
@@ -1,17 +1,15 @@
|
|||||||
package site.easystartup.easystartupcore.project.controller;
|
package site.easystartup.web.project.controller;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.modelmapper.ModelMapper;
|
import org.modelmapper.ModelMapper;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import site.easystartup.easystartupcore.project.domain.model.Project;
|
import site.easystartup.web.project.domain.model.Project;
|
||||||
import site.easystartup.easystartupcore.project.domain.payload.response.ResponseMessage;
|
import site.easystartup.web.project.domain.validation.ResponseErrorValidation;
|
||||||
import site.easystartup.easystartupcore.project.domain.validation.ResponseErrorValidation;
|
import site.easystartup.web.project.dto.ProjectDto;
|
||||||
import site.easystartup.easystartupcore.project.dto.ProjectDto;
|
import site.easystartup.web.project.service.ProjectService;
|
||||||
import site.easystartup.easystartupcore.project.service.ProjectService;
|
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package site.easystartup.easystartupcore.project.domain.model;
|
package site.easystartup.web.project.domain.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import site.easystartup.easystartupcore.domain.User;
|
import site.easystartup.web.domain.User;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
package site.easystartup.easystartupcore.project.domain.model;
|
package site.easystartup.web.project.domain.model;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import site.easystartup.easystartupcore.domain.User;
|
import site.easystartup.web.domain.User;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.project.domain.payload.response;
|
package site.easystartup.web.project.domain.payload.response;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.project.domain.validation;
|
package site.easystartup.web.project.domain.validation;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.project.dto;
|
package site.easystartup.web.project.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.project.dto;
|
package site.easystartup.web.project.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package site.easystartup.easystartupcore.project.dto;
|
package site.easystartup.web.project.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import site.easystartup.easystartupcore.domain.Role;
|
import site.easystartup.web.domain.Role;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
package site.easystartup.easystartupcore.project.repo;
|
package site.easystartup.web.project.repo;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
import site.easystartup.easystartupcore.project.domain.model.Project;
|
import site.easystartup.web.project.domain.model.Project;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ProjectRepo extends JpaRepository<Project, Long> {
|
public interface ProjectRepo extends JpaRepository<Project, Long> {
|
||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
package site.easystartup.easystartupcore.project.service;
|
package site.easystartup.web.project.service;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import site.easystartup.easystartupcore.project.domain.model.Project;
|
import site.easystartup.web.project.domain.model.Project;
|
||||||
import site.easystartup.easystartupcore.project.repo.ProjectRepo;
|
import site.easystartup.web.project.repo.ProjectRepo;
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package site.easystartup.easystartupcore.repo;
|
package site.easystartup.web.repo;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import site.easystartup.easystartupcore.domain.User;
|
import site.easystartup.web.domain.User;
|
||||||
|
|
||||||
public interface UserRepo extends JpaRepository<User, Long> {
|
public interface UserRepo extends JpaRepository<User, Long> {
|
||||||
User findByUsername(String username);
|
User findByUsername(String username);
|
||||||
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
package site.easystartup.easystartupcore.storag.config;
|
package site.easystartup.web.storage.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.storag.service.FileLocalStorageService;
|
import site.easystartup.web.storage.service.FileLocalStorageService;
|
||||||
import site.easystartup.easystartupcore.storag.service.StorageService;
|
import site.easystartup.web.storage.service.StorageService;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class FileConfig {
|
public class FileConfig {
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package site.easystartup.web.storage.controller;
|
||||||
|
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder;
|
||||||
|
import site.easystartup.web.storage.service.StorageFileNotFoundException;
|
||||||
|
import site.easystartup.web.storage.service.StorageService;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class FileUploadController {
|
||||||
|
|
||||||
|
private final StorageService storageService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public FileUploadController(StorageService storageService) {
|
||||||
|
this.storageService = storageService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/upload")
|
||||||
|
public String listUploadedFiles(Model model) {
|
||||||
|
if(storageService.loadAll() == null) {
|
||||||
|
model.addAttribute("message",
|
||||||
|
"Storage is emptiy");
|
||||||
|
return "upload";
|
||||||
|
}
|
||||||
|
model.addAttribute("files", storageService.loadAll().map(
|
||||||
|
path -> MvcUriComponentsBuilder.fromMethodName(FileUploadController.class,
|
||||||
|
"serveFile", path.getFileName().toString()).build().toUri().toString())
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
|
return "upload";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@GetMapping("/files/{filename:.+}")
|
||||||
|
@ResponseBody
|
||||||
|
public ResponseEntity<Resource> serveFile(@PathVariable String filename) {
|
||||||
|
Resource file = storageService.load(filename);
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getFilename() + "\"").body(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/upload")
|
||||||
|
public String handleFileUpload(@RequestParam("file") MultipartFile file,
|
||||||
|
Model model) {
|
||||||
|
storageService.save(file);
|
||||||
|
model.addAttribute("message",
|
||||||
|
"You successfully uploaded " + file.getOriginalFilename() + "!");
|
||||||
|
|
||||||
|
return "upload";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ExceptionHandler(StorageFileNotFoundException.class)
|
||||||
|
public ResponseEntity<?> handleStorageFileNotFound(StorageFileNotFoundException exc) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore.storag.service;
|
package site.easystartup.web.storage.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.storag.service;
|
package site.easystartup.web.storage.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.storag.service;
|
package site.easystartup.web.storage.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,27 @@
|
|||||||
|
<html xmlns:th="https://www.thymeleaf.org">
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div th:if="${message}">
|
||||||
|
<h2 th:text="${message}"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<form method="POST" enctype="multipart/form-data" action="/upload">
|
||||||
|
<table>
|
||||||
|
<tr><td>File to upload:</td><td><input type="file" name="file" /></td></tr>
|
||||||
|
<tr><td></td><td><input type="submit" value="Upload" /></td></tr>
|
||||||
|
</table>
|
||||||
|
<input type="hidden" name="_csrf" th:value="${_csrf.token}">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<ul>
|
||||||
|
<li th:each="file : ${files}">
|
||||||
|
<a th:href="${file}" th:text="${file}" />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore;
|
package site.easystartup.web;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
package site.easystartup.easystartupcore;
|
package site.easystartup.web;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
@@ -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.storag.service.StorageFileNotFoundException;
|
import site.easystartup.web.storage.service.StorageFileNotFoundException;
|
||||||
import site.easystartup.easystartupcore.storag.service.StorageService;
|
import site.easystartup.web.storage.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