Added commisions endponts

This commit is contained in:
Filip Izydorczyk
2020-09-30 17:46:04 +02:00
parent b4d1c87461
commit b503ebcbcc
6 changed files with 58 additions and 22 deletions

View File

@ -29,6 +29,9 @@ public class Commision {
this.commisionOwner = user;
}
public Commision() {
}
public Long getId() {
return this.id;
}

View File

@ -68,4 +68,8 @@ public class User {
public void setName(String name) {
this.name = name;
}
public Long getId() {
return this.id;
}
}

View File

@ -1,11 +1,17 @@
package com.plannaplan.repositories;
import java.util.List;
import com.plannaplan.entities.Commision;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface CommisionRepository extends JpaRepository<Commision, Long> {
@Query("FROM Commision WHERE owner_id = ?1")
List<Commision> getUsers(@Param("owner_id") Long id);
}

View File

@ -1,6 +1,9 @@
package com.plannaplan.services;
import java.util.List;
import com.plannaplan.entities.Commision;
import com.plannaplan.entities.User;
import com.plannaplan.repositories.CommisionRepository;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,4 +22,9 @@ public class CommisionService {
return commision;
}
public List<Commision> getUsersCommisions(User user) {
Long id = user.getId();
return this.repo.getUsers(id);
}
}