/
StoreRestService.java
53 lines (45 loc) · 1.75 KB
/
StoreRestService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Most of the code in the Qalingo project is copyrighted Hoteia and licensed
* under the Apache License Version 2.0 (release version 0.8.0)
* http://www.apache.org/licenses/LICENSE-2.0
*
* Copyright (c) Hoteia, 2012-2014
* http://www.hoteia.com - http://twitter.com/hoteia - contact@hoteia.com
*
*/
package org.hoteia.qalingo.core.rest.controller;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.hoteia.qalingo.core.pojo.retailer.StoreListPojoResponse;
import org.hoteia.qalingo.core.pojo.retailer.StorePojoResponse;
import org.hoteia.qalingo.core.pojo.store.StorePojo;
import org.hoteia.qalingo.core.service.pojo.RetailerPojoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Path("/store/")
@Component("storeRestService")
public class StoreRestService {
@Autowired
protected RetailerPojoService retailerPojoService;
@GET
@Produces(MediaType.APPLICATION_JSON)
public StoreListPojoResponse getAllStores() {
StoreListPojoResponse storeListPojoResponse = new StoreListPojoResponse();
List<StorePojo> stores = retailerPojoService.getAllStores();
storeListPojoResponse.setStores(stores);
return storeListPojoResponse;
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{code}")
public StorePojoResponse getStoreByCode(@PathParam("code") final String code) {
StorePojoResponse StorePojoResponse = new StorePojoResponse();
StorePojo store = retailerPojoService.getStoreByCode(code);
StorePojoResponse.setStore(store);
return StorePojoResponse;
}
}