Added flaging assignment. Coumetr froup infor needs to be added
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.plannaplan.services;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.plannaplan.entities.Assignment;
|
||||
import com.plannaplan.entities.Commision;
|
||||
@ -17,8 +18,8 @@ public class AssignmentService {
|
||||
public AssignmentService() {
|
||||
}
|
||||
|
||||
public void save(Assignment assignment) {
|
||||
this.repo.save(assignment);
|
||||
public Assignment save(Assignment assignment) {
|
||||
return this.repo.save(assignment);
|
||||
}
|
||||
|
||||
public List<Assignment> getCommisionAssignments(Commision com) {
|
||||
@ -28,4 +29,8 @@ public class AssignmentService {
|
||||
public long getAssignmentsAmmount() {
|
||||
return this.repo.count();
|
||||
}
|
||||
|
||||
public Optional<Assignment> getById(Long id) {
|
||||
return this.repo.findById(id);
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import java.util.Optional;
|
||||
|
||||
import com.plannaplan.entities.Commision;
|
||||
import com.plannaplan.entities.User;
|
||||
import com.plannaplan.repositories.AssignmentRepository;
|
||||
import com.plannaplan.repositories.CommisionRepository;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -14,11 +15,21 @@ import org.springframework.stereotype.Service;
|
||||
public class CommisionService {
|
||||
@Autowired
|
||||
private CommisionRepository repo;
|
||||
@Autowired
|
||||
private AssignmentRepository aRepository;
|
||||
|
||||
public CommisionService() {
|
||||
}
|
||||
|
||||
public Commision save(Commision commision) {
|
||||
Optional<Commision> lastCommision = this.getNewestCommision(commision.getCommisionOwner());
|
||||
if (lastCommision.isPresent()) {
|
||||
final Commision lastCom = lastCommision.get();
|
||||
lastCom.getAssignments().forEach(assignment -> {
|
||||
assignment.setPastAssignment(true);
|
||||
this.aRepository.save(assignment);
|
||||
});
|
||||
}
|
||||
this.repo.save(commision);
|
||||
return commision;
|
||||
|
||||
|
Reference in New Issue
Block a user