Merge with assign

This commit is contained in:
Filip Izydorczyk
2020-10-01 16:46:45 +02:00
14 changed files with 395 additions and 32 deletions

View File

@ -0,0 +1,28 @@
package com.plannaplan.services;
import java.util.List;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Commision;
import com.plannaplan.repositories.AssignmentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AssignmentService {
@Autowired
private AssignmentRepository repo;
public AssignmentService() {
super();
}
public void save(Assignment assignment) {
this.repo.save(assignment);
}
public List<Assignment> getCommisionAssignments(Commision com) {
return this.repo.getByCommision(com.getId());
}
}

View File

@ -0,0 +1,35 @@
package com.plannaplan.services;
import java.util.List;
import java.util.Optional;
import com.plannaplan.entities.Commision;
import com.plannaplan.entities.User;
import com.plannaplan.repositories.CommisionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CommisionService {
@Autowired
private CommisionRepository repo;
public CommisionService() {
}
public Commision save(Commision commision) {
this.repo.save(commision);
return commision;
}
public List<Commision> getUsersCommisions(User user) {
Long id = user.getId();
return this.repo.getUsers(id);
}
public Optional<Commision> getNewestCommision(User user) {
return Optional.of(this.repo.getNewestCommision(user.getId()).get(0));
}
}

View File

@ -37,4 +37,8 @@ public class GroupService {
public int getGroupsAmmount() {
return (int) this.repo.count();
}
public Optional<Groups> getGroupById(Long id) {
return this.repo.findById(id);
}
}