ViSnezh
This commit is contained in:
1 parent
9d2f8c8b04
commit
0cac9c872e
13 files changed
+205
-6
No files matched your search
@@ -2,6 +2,7 @@ package site.easystartup.easystartupcore;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
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;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package site.easystartup.easystartupcore.config;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -16,4 +17,8 @@ public class AppConfig {
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
@Bean
|
||||
public ModelMapper modelMapper(){
|
||||
return new ModelMapper();
|
||||
}
|
||||
}
|
||||
+79
-1
@@ -1,13 +1,91 @@
|
||||
package site.easystartup.easystartupcore.project.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import site.easystartup.easystartupcore.project.domain.model.Project;
|
||||
import site.easystartup.easystartupcore.project.domain.validation.ResponseErrorValidation;
|
||||
import site.easystartup.easystartupcore.project.dto.ProjectDto;
|
||||
import site.easystartup.easystartupcore.project.service.ProjectService;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/project")
|
||||
public class ProjectController {
|
||||
private final ProjectService projectService;
|
||||
private final ResponseErrorValidation responseErrorValidation;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
// @PostMapping("/create")
|
||||
// public ModelAndView createProject(@ModelAttribute("project") ProjectDto projectDto,
|
||||
// BindingResult bindingResult,
|
||||
// Principal principal) {
|
||||
// ModelAndView modelAndView = new ModelAndView();
|
||||
//
|
||||
// if (bindingResult.hasErrors()) {
|
||||
// Map<String, String> errors = responseErrorValidation.mapValidationService(bindingResult);
|
||||
// return modelAndView.addObject("errors", errors);
|
||||
// }
|
||||
//
|
||||
// Project project = projectService.createProject(modelMapper.map(projectDto, Project.class), principal);
|
||||
// modelAndView.addObject("project", project);
|
||||
// modelAndView.setViewName("project");
|
||||
// return modelAndView;
|
||||
// }
|
||||
//
|
||||
// @PatchMapping("/{projectId}/update")
|
||||
// public ModelAndView updateProject() {
|
||||
// ModelAndView modelAndView = new ModelAndView();
|
||||
//
|
||||
// return modelAndView;
|
||||
// }
|
||||
//
|
||||
// @DeleteMapping("/{projectId}/delete")
|
||||
// public ModelAndView deleteProject() {
|
||||
// ModelAndView modelAndView = new ModelAndView();
|
||||
//
|
||||
// return modelAndView;
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/{projectId}")
|
||||
// public ModelAndView getProject() {
|
||||
// ModelAndView modelAndView = new ModelAndView();
|
||||
//
|
||||
// return modelAndView;
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/{userId}")
|
||||
// public ModelAndView getAllProjectsForUser() {
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/{technology}")
|
||||
// public ModelAndView getAllProjectsWithTechnology() {
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/my")
|
||||
// public ModelAndView getAllProjectsForCurrentUser() {
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/{projectId}/applay")
|
||||
// public ModelAndView applayOnProject() {
|
||||
// ModelAndView modelAndView = new ModelAndView();
|
||||
//
|
||||
// return modelAndView;
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/{projectId}/{participantId}")
|
||||
// public ModelAndView confirmParticipant() {
|
||||
// ModelAndView modelAndView = new ModelAndView();
|
||||
//
|
||||
// return modelAndView;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class Participant {
|
||||
private Long participantId;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "project_id")
|
||||
@JoinColumn(name = "project_id", updatable = false)
|
||||
private Project project;
|
||||
|
||||
@Column(name = "technology")
|
||||
|
||||
@@ -29,6 +29,7 @@ public class Project {
|
||||
|
||||
@Column(name = "description")
|
||||
@Size(min = 50, message = "Description should be no less 50 signs")
|
||||
@NotNull
|
||||
private String description;
|
||||
|
||||
@Column(name = "commercial_status") // 1 - commercial, 0 - non-commercial
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package site.easystartup.easystartupcore.project.domain.validation;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.validation.ObjectError;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class ResponseErrorValidation {
|
||||
|
||||
public Map<String, String> mapValidationService(BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
Map<String, String> errorMap = new HashMap<>();
|
||||
|
||||
if (!CollectionUtils.isEmpty(result.getAllErrors())) {
|
||||
for (ObjectError error : result.getAllErrors()) {
|
||||
errorMap.put(error.getCode(), error.getDefaultMessage());
|
||||
}
|
||||
}
|
||||
|
||||
for (FieldError error : result.getFieldErrors()) {
|
||||
errorMap.put(error.getCode(), error.getDefaultMessage());
|
||||
}
|
||||
|
||||
return errorMap;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package site.easystartup.easystartupcore.project.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
public class ParticipantDto implements Serializable {
|
||||
private final Long participantId;
|
||||
@NotNull
|
||||
private final String technology;
|
||||
private final String nameOfPosition;
|
||||
private final UserDto userId;
|
||||
private final Set<UserDto> requests;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package site.easystartup.easystartupcore.project.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ProjectDto implements Serializable {
|
||||
private final Long projectId;
|
||||
private final String coverLink;
|
||||
@Size(min = 3, max = 100, message = "Title should be no less 3 and no more 100 signs")
|
||||
@NotNull
|
||||
private final String title;
|
||||
@Size(min = 50, message = "Description should be no less 50 signs")
|
||||
@NotNull
|
||||
private final String description;
|
||||
private final int commercialStatus;
|
||||
@NotNull
|
||||
private final String technology;
|
||||
private final List<ParticipantDto> participants;
|
||||
private final LocalDateTime createdDate;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package site.easystartup.easystartupcore.project.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import site.easystartup.easystartupcore.domain.Role;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
public class UserDto implements Serializable {
|
||||
private final long id;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final boolean active;
|
||||
private final String full_name;
|
||||
private final String status;
|
||||
private final String iconPath;
|
||||
private final String email;
|
||||
private final Set<String> tags;
|
||||
private final Set<String> professions;
|
||||
private final Set<Long> projects;
|
||||
private final Set<Role> roles;
|
||||
}
|
||||
@@ -2,14 +2,18 @@ package site.easystartup.easystartupcore.project.service;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import site.easystartup.easystartupcore.project.domain.model.Project;
|
||||
import site.easystartup.easystartupcore.project.repo.ProjectRepo;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ProjectService {
|
||||
private final ProjectRepo projectRepo;
|
||||
|
||||
|
||||
|
||||
|
||||
public Project createProject(Project project, Principal principal) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,6 @@ spring.sql.init.mode=always
|
||||
spring.sql.init.platform=postgres
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/testdb
|
||||
spring.datasource.username=postgres
|
||||
#spring.datasource.password=root
|
||||
spring.datasource.password=postgres
|
||||
spring.datasource.password=root
|
||||
#spring.datasource.password=postgres
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user