Collector

This commit is contained in:
insanity 2016-11-16 17:19:59 +09:00
parent c782dcd20c
commit fb7c3d2e23
2 changed files with 20 additions and 1 deletions

View File

@ -1,7 +1,23 @@
package com.loafle.bridge.collector; package com.loafle.bridge.collector;
import com.loafle.bridge.discoveryservice.entity.DiscoveryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/** /**
* Created by root on 16. 11. 15. * Created by root on 16. 11. 15.
*/ */
public class CollectorController { public class CollectorController {
@Autowired
private CollectorRepository repository;
@RequestMapping(value = "/collector/{productId}", method = RequestMethod.GET)
public Collector get(@PathVariable(value = "productId") long productId) {
return repository.findByPID(productId);
}
} }

View File

@ -1,7 +1,8 @@
package com.loafle.bridge.collector; package com.loafle.bridge.collector;
import com.loafle.bridge.collector.Collector;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;
/** /**
@ -10,4 +11,6 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "collector", path = "collector") @RepositoryRestResource(collectionResourceRel = "collector", path = "collector")
public interface CollectorRepository extends JpaRepository<Collector, Long> { public interface CollectorRepository extends JpaRepository<Collector, Long> {
@Query("SELECT c FROM Collector c where c.productId = :productId")
Collector findByPID(@Param("productId") Long productId);
} }