security
This commit is contained in:
1 parent
6daa2dea77
commit
202ba23b76
11 files changed
+146
-70
No files matched your search
@@ -10,9 +10,7 @@ import site.easystartup.web.project.domain.model.Participant;
|
|||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "usr")
|
@Table(name = "usr")
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import site.easystartup.web.domain.response.MessageResponse;
|
|||||||
import site.easystartup.web.domain.validation.ResponseErrorValidation;
|
import site.easystartup.web.domain.validation.ResponseErrorValidation;
|
||||||
import site.easystartup.web.project.dto.ParticipantDto;
|
import site.easystartup.web.project.dto.ParticipantDto;
|
||||||
import site.easystartup.web.project.dto.ProjectDto;
|
import site.easystartup.web.project.dto.ProjectDto;
|
||||||
|
import site.easystartup.web.project.service.ParticipantService;
|
||||||
import site.easystartup.web.project.service.ProjectService;
|
import site.easystartup.web.project.service.ProjectService;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@@ -22,13 +23,15 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/project")
|
@RequestMapping("/api/project")
|
||||||
public class ProjectController {
|
public class ProjectController {
|
||||||
private final ProjectService projectService;
|
private final ProjectService projectService;
|
||||||
private final ResponseErrorValidation responseErrorValidation;
|
private final ResponseErrorValidation responseErrorValidation;
|
||||||
private final ModelMapper modelMapper;
|
private final ModelMapper modelMapper;
|
||||||
|
|
||||||
@PostMapping("/")
|
private final ParticipantService participantService;
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
public ResponseEntity<Object> createProject(@Valid @RequestBody ProjectRequest projectRequest,
|
public ResponseEntity<Object> createProject(@Valid @RequestBody ProjectRequest projectRequest,
|
||||||
BindingResult bindingResult,
|
BindingResult bindingResult,
|
||||||
Principal principal) {
|
Principal principal) {
|
||||||
@@ -51,6 +54,20 @@ public class ProjectController {
|
|||||||
return ResponseEntity.ok().body(modelMapper.map(projectUpdated, ProjectDto.class));
|
return ResponseEntity.ok().body(modelMapper.map(projectUpdated, ProjectDto.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{projectId}/{partId}/part")
|
||||||
|
public ResponseEntity<Object> editPart(@Valid @RequestBody ParticipantDto participantDto,
|
||||||
|
@PathVariable("projectId") Long projectId,
|
||||||
|
@PathVariable("partId") Long partId,
|
||||||
|
BindingResult bindingResult,
|
||||||
|
Principal principal) {
|
||||||
|
ResponseEntity<Object> errors = responseErrorValidation.mapValidationService(bindingResult);
|
||||||
|
if (!ObjectUtils.isEmpty(errors)) return errors;
|
||||||
|
|
||||||
|
Project projectUpdated = participantService.edit(participantDto, partId, projectId, principal);
|
||||||
|
return ResponseEntity.ok().body(modelMapper.map(projectUpdated, ProjectDto.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@DeleteMapping("/{projectId}")
|
@DeleteMapping("/{projectId}")
|
||||||
public ResponseEntity<Object> deleteProject(@PathVariable("projectId") Long projectId,
|
public ResponseEntity<Object> deleteProject(@PathVariable("projectId") Long projectId,
|
||||||
Principal principal) {
|
Principal principal) {
|
||||||
@@ -64,14 +81,14 @@ public class ProjectController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@GetMapping("/{userId}")
|
@GetMapping("/{userId}/all")
|
||||||
public ResponseEntity<List<ProjectDto>> getAllProjectsForUser(@PathVariable("userId") Long userId) {
|
public ResponseEntity<List<ProjectDto>> getAllProjectsForUser(@PathVariable("userId") Long userId) {
|
||||||
List<ProjectDto> projects = projectService.getAllProjectsForUser(userId)
|
List<ProjectDto> projects = projectService.getAllProjectsForUser(userId)
|
||||||
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
|
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
|
||||||
return ResponseEntity.ok().body(projects);
|
return ResponseEntity.ok().body(projects);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{technology}")
|
@GetMapping("/{technology}/tech")
|
||||||
public ResponseEntity<List<ProjectDto>> getAllProjectsWithTechnology(@PathVariable("technology") String technology) {
|
public ResponseEntity<List<ProjectDto>> getAllProjectsWithTechnology(@PathVariable("technology") String technology) {
|
||||||
List<ProjectDto> projects = projectService.getAllProjectsWithTechnology(technology)
|
List<ProjectDto> projects = projectService.getAllProjectsWithTechnology(technology)
|
||||||
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
|
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
|
||||||
@@ -86,15 +103,15 @@ public class ProjectController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/positions")
|
@GetMapping("/{nameOfPosition}/positions")
|
||||||
public ResponseEntity<List<ProjectDto>> getAllProjectsWithPosition(@RequestBody String nameOfPosition) {
|
public ResponseEntity<List<ProjectDto>> getAllProjectsWithPosition(@PathVariable("nameOfPosition") String nameOfPosition) {
|
||||||
List<ProjectDto> projects = projectService.getAllProjectsWithPosition(nameOfPosition)
|
List<ProjectDto> projects = projectService.getAllProjectsWithPosition(nameOfPosition)
|
||||||
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
|
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
|
||||||
return ResponseEntity.ok().body(projects);
|
return ResponseEntity.ok().body(projects);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/commercial_status")
|
@GetMapping("/{commercialStatus}/commercial_status")
|
||||||
public ResponseEntity<List<ProjectDto>> getAllProjectsWithCommercialStatus(@RequestBody int commercialStatus) {
|
public ResponseEntity<List<ProjectDto>> getAllProjectsWithCommercialStatus(@PathVariable("commercialStatus") int commercialStatus) {
|
||||||
List<ProjectDto> projects = projectService.getAllProjectsWithCommercialStatus(commercialStatus)
|
List<ProjectDto> projects = projectService.getAllProjectsWithCommercialStatus(commercialStatus)
|
||||||
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
|
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
|
||||||
return ResponseEntity.ok().body(projects);
|
return ResponseEntity.ok().body(projects);
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ import org.hibernate.Hibernate;
|
|||||||
import site.easystartup.web.domain.model.User;
|
import site.easystartup.web.domain.model.User;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "participant")
|
@Table(name = "participant")
|
||||||
@@ -25,6 +24,7 @@ public class Participant {
|
|||||||
private Project project;
|
private Project project;
|
||||||
|
|
||||||
@Column(name = "name_of_position")
|
@Column(name = "name_of_position")
|
||||||
|
@NotNull
|
||||||
private String nameOfPosition;
|
private String nameOfPosition;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "user_id")
|
@JoinColumn(name = "user_id")
|
||||||
@@ -37,16 +37,16 @@ public class Participant {
|
|||||||
@ToString.Exclude
|
@ToString.Exclude
|
||||||
private List<User> requests;
|
private List<User> requests;
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public boolean equals(Object o) {
|
// public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
// if (this == o) return true;
|
||||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
// if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||||
Participant that = (Participant) o;
|
// Participant that = (Participant) o;
|
||||||
return participantId != null && Objects.equals(participantId, that.participantId);
|
// return participantId != null && Objects.equals(participantId, that.participantId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public int hashCode() {
|
// public int hashCode() {
|
||||||
return getClass().hashCode();
|
// return getClass().hashCode();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "project")
|
@Table(name = "project")
|
||||||
@@ -53,7 +51,7 @@ public class Project {
|
|||||||
private User owner;
|
private User owner;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "project", cascade = {CascadeType.ALL})
|
@OneToMany(mappedBy = "project", cascade = {CascadeType.ALL})
|
||||||
@ToString.Exclude
|
// @ToString.Exclude
|
||||||
private List<Participant> participants;
|
private List<Participant> participants;
|
||||||
|
|
||||||
@Column(name = "created_date", updatable = false)
|
@Column(name = "created_date", updatable = false)
|
||||||
@@ -65,16 +63,16 @@ public class Project {
|
|||||||
this.createdDate = LocalDateTime.now();
|
this.createdDate = LocalDateTime.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public boolean equals(Object o) {
|
// public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
// if (this == o) return true;
|
||||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
// if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||||
Project project = (Project) o;
|
// Project project = (Project) o;
|
||||||
return projectId != null && Objects.equals(projectId, project.projectId);
|
// return projectId != null && Objects.equals(projectId, project.projectId);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public int hashCode() {
|
// public int hashCode() {
|
||||||
return getClass().hashCode();
|
// return getClass().hashCode();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package site.easystartup.web.project.domain.requst;
|
package site.easystartup.web.project.domain.requst;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import site.easystartup.web.project.domain.model.Tag;
|
import site.easystartup.web.project.domain.model.Tag;
|
||||||
@@ -11,10 +12,10 @@ import javax.validation.constraints.Size;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@RequiredArgsConstructor
|
@NoArgsConstructor
|
||||||
public class ProjectRequest {
|
public class ProjectRequest {
|
||||||
|
|
||||||
private MultipartFile cover;
|
// private MultipartFile cover;
|
||||||
|
|
||||||
@Size(min = 3, max = 100, message = "Title should be no less 3 and no more 100 signs")
|
@Size(min = 3, max = 100, message = "Title should be no less 3 and no more 100 signs")
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
package site.easystartup.web.project.dto;
|
package site.easystartup.web.project.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
public class ParticipantDto implements Serializable {
|
public class ParticipantDto implements Serializable {
|
||||||
private final Long participantId;
|
private Long participantId;
|
||||||
@NotNull
|
@NotNull
|
||||||
private final String technology;
|
private String nameOfPosition;
|
||||||
private final String nameOfPosition;
|
private UserDto user;
|
||||||
private final UserDto user;
|
private Set<UserDto> requests;
|
||||||
private final Set<UserDto> requests;
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package site.easystartup.web.project.dto;
|
package site.easystartup.web.project.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
@@ -9,18 +10,19 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
public class ProjectDto implements Serializable {
|
public class ProjectDto implements Serializable {
|
||||||
private final Long projectId;
|
private Long projectId;
|
||||||
private final String coverLink;
|
private String coverLink;
|
||||||
@Size(min = 3, max = 100, message = "Title should be no less 3 and no more 100 signs")
|
@Size(min = 3, max = 100, message = "Title should be no less 3 and no more 100 signs")
|
||||||
@NotNull
|
@NotNull
|
||||||
private final String title;
|
private String title;
|
||||||
@Size(min = 50, message = "Description should be no less 50 signs")
|
@Size(min = 50, message = "Description should be no less 50 signs")
|
||||||
@NotNull
|
@NotNull
|
||||||
private final String description;
|
private String description;
|
||||||
private final int commercialStatus;
|
private int commercialStatus;
|
||||||
@NotNull
|
@NotNull
|
||||||
private final String technology;
|
private String technology;
|
||||||
private final List<ParticipantDto> participants;
|
private List<ParticipantDto> participants;
|
||||||
private final LocalDateTime createdDate;
|
private LocalDateTime createdDate;
|
||||||
}
|
}
|
||||||
@@ -8,9 +8,11 @@ import site.easystartup.web.project.domain.model.Participant;
|
|||||||
import site.easystartup.web.project.domain.model.Project;
|
import site.easystartup.web.project.domain.model.Project;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ParticipantRepo extends JpaRepository<Participant, Long> {
|
public interface ParticipantRepo extends JpaRepository<Participant, Long> {
|
||||||
@Query ("SELECT p FROM Participant p WHERE p.nameOfPosition = :nameOfPosition")
|
|
||||||
LinkedHashSet<Project> findAllByNameOfPosition(@Param("nameOfPosition") String name);
|
List<Participant> findAllByNameOfPositionIgnoreCase(String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package site.easystartup.web.project.service;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.modelmapper.ModelMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import site.easystartup.web.project.domain.model.Participant;
|
||||||
|
import site.easystartup.web.project.domain.model.Project;
|
||||||
|
import site.easystartup.web.project.domain.requst.ProjectRequest;
|
||||||
|
import site.easystartup.web.project.dto.ParticipantDto;
|
||||||
|
import site.easystartup.web.project.repo.ParticipantRepo;
|
||||||
|
|
||||||
|
import java.security.Principal;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ParticipantService {
|
||||||
|
private final ParticipantRepo participantRepo;
|
||||||
|
private final ModelMapper modelMapper;
|
||||||
|
private final ProjectService projectService;
|
||||||
|
|
||||||
|
public Project edit(ParticipantDto participantDto,
|
||||||
|
Long partId,
|
||||||
|
Long projectId,
|
||||||
|
Principal principal) {
|
||||||
|
Project project = projectService.getProjectById(projectId);
|
||||||
|
if (!projectService.projectIsBelongUser(project, principal))
|
||||||
|
throw new RuntimeException("This project cannot be changed");
|
||||||
|
Participant participantOld = participantRepo.findById(partId).orElseThrow(() -> new RuntimeException());
|
||||||
|
if (!partIsBelongProject(project, participantOld))
|
||||||
|
throw new RuntimeException("This participant cannot be changed");
|
||||||
|
|
||||||
|
Participant participant = modelMapper.map(participantDto, Participant.class);
|
||||||
|
participant.setParticipantId(partId);
|
||||||
|
participantRepo.save(participant);
|
||||||
|
return projectService.getProjectById(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean partIsBelongProject(Project project, Participant participant) {
|
||||||
|
return project.equals(participant.getProject());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,8 +14,7 @@ import site.easystartup.web.service.UserService;
|
|||||||
import site.easystartup.web.storage.service.StorageService;
|
import site.easystartup.web.storage.service.StorageService;
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -29,21 +28,36 @@ public class ProjectService {
|
|||||||
private final TagService tagService;
|
private final TagService tagService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Project createProject(ProjectRequest projectRequest, Principal principal) {
|
public Project createProject(ProjectRequest projectRequest, Principal principal) {
|
||||||
Project project = projectRequestToProject(projectRequest, principal);
|
Project project = projectRepo.save(projectRequestToProject(projectRequest, principal));
|
||||||
|
project.setParticipants(getParticipantForProject(projectRequest, project));
|
||||||
return projectRepo.save(project);
|
return projectRepo.save(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project editProject(ProjectRequest projectRequest, Long projectId, Principal principal) {
|
public Project editProject(ProjectRequest projectRequest, Long projectId, Principal principal) {
|
||||||
if (!projectIsBelongUser(getProjectById(projectId), principal))
|
Project projectOld = getProjectById(projectId);
|
||||||
|
if (!projectIsBelongUser(projectOld, principal))
|
||||||
throw new RuntimeException("This project cannot be changed");
|
throw new RuntimeException("This project cannot be changed");
|
||||||
|
|
||||||
Project project = projectRequestToProject(projectRequest, principal);
|
Project project = projectRequestToProject(projectRequest, principal);
|
||||||
|
project.setParticipants(projectOld.getParticipants());
|
||||||
project.setProjectId(projectId);
|
project.setProjectId(projectId);
|
||||||
|
|
||||||
return projectRepo.save(project);
|
return projectRepo.save(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Participant> getParticipantForProject(ProjectRequest projectRequest, Project project) {
|
||||||
|
List<Participant> part = new ArrayList<>();
|
||||||
|
projectRequest.getParticipants().forEach(participantDto -> {
|
||||||
|
Participant participant = new Participant();
|
||||||
|
participant.setProject(project);
|
||||||
|
participant.setNameOfPosition(participantDto.getNameOfPosition());
|
||||||
|
part.add(participant);
|
||||||
|
});
|
||||||
|
return part;
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteProject(Long projectId, Principal principal) {
|
public void deleteProject(Long projectId, Principal principal) {
|
||||||
Project project = getProjectById(projectId);
|
Project project = getProjectById(projectId);
|
||||||
if (!projectIsBelongUser(project, principal))
|
if (!projectIsBelongUser(project, principal))
|
||||||
@@ -74,7 +88,11 @@ public class ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LinkedHashSet<Project> getAllProjectsWithPosition(String nameOfPosition) {
|
public LinkedHashSet<Project> getAllProjectsWithPosition(String nameOfPosition) {
|
||||||
return participantRepo.findAllByNameOfPosition(nameOfPosition.trim());
|
List<Participant> parts = participantRepo.findAllByNameOfPositionIgnoreCase(nameOfPosition.trim());
|
||||||
|
LinkedHashSet<Project> projects = new LinkedHashSet<>();
|
||||||
|
parts.forEach(part -> projects.add(part.getProject()));
|
||||||
|
|
||||||
|
return projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project applyOnProject(Long projectId, String nameOfPosition, Principal principal) {
|
public Project applyOnProject(Long projectId, String nameOfPosition, Principal principal) {
|
||||||
@@ -112,20 +130,16 @@ public class ProjectService {
|
|||||||
private Project projectRequestToProject(ProjectRequest projectRequest, Principal principal) {
|
private Project projectRequestToProject(ProjectRequest projectRequest, Principal principal) {
|
||||||
Project project = new Project();
|
Project project = new Project();
|
||||||
|
|
||||||
project.setParticipants(projectRequest.getParticipants()
|
|
||||||
.stream().map(part -> modelMapper.map(part, Participant.class)).collect(Collectors.toList()));
|
|
||||||
project.setTitle(projectRequest.getTitle());
|
project.setTitle(projectRequest.getTitle());
|
||||||
project.setDescription(projectRequest.getDescription());
|
project.setDescription(projectRequest.getDescription());
|
||||||
project.setTechnology(tagService.convertTechnology(projectRequest.getTechnology()));
|
project.setTechnology(tagService.convertTechnology(projectRequest.getTechnology()));
|
||||||
project.setCommercialStatus(project.getCommercialStatus());
|
project.setCommercialStatus(project.getCommercialStatus());
|
||||||
project.setCoverLink(projectRequest.getCover().getName());
|
// project.setCoverLink(projectRequest.getCover().getName());
|
||||||
project.setOwner(userService.getUserByPrincipal(principal));
|
project.setOwner(userService.getUserByPrincipal(principal));
|
||||||
storageService.save(projectRequest.getCover());
|
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean projectIsBelongUser(Project project, Principal principal) {
|
public boolean projectIsBelongUser(Project project, Principal principal) {
|
||||||
return project.getOwner().equals(userService.getUserByPrincipal(principal));
|
return project.getOwner().equals(userService.getUserByPrincipal(principal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
server.port=80
|
server.port=80
|
||||||
|
|
||||||
spring.jpa.hibernate.ddl-auto=create
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
|
||||||
spring.sql.init.mode=always
|
spring.sql.init.mode=always
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user