Subversion Repositories SmartDukaan

Rev

Rev 23273 | Rev 23568 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23273 Rev 23360
Line 23... Line 23...
23
import org.springframework.web.bind.annotation.RequestParam;
23
import org.springframework.web.bind.annotation.RequestParam;
24
 
24
 
25
import com.google.gson.Gson;
25
import com.google.gson.Gson;
26
import com.spice.profitmandi.common.model.ProfitMandiConstants;
26
import com.spice.profitmandi.common.model.ProfitMandiConstants;
27
import com.spice.profitmandi.common.web.util.ResponseSender;
27
import com.spice.profitmandi.common.web.util.ResponseSender;
-
 
28
import com.spice.profitmandi.dao.entity.catalog.Item;
28
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
29
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
29
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
30
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
30
import com.spice.profitmandi.dao.model.ProductPojo;
31
import com.spice.profitmandi.dao.model.ProductPojo;
31
import com.spice.profitmandi.dao.model.UserCart;
32
import com.spice.profitmandi.dao.model.UserCart;
-
 
33
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
32
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
34
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
33
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
35
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
34
import com.spice.profitmandi.dao.util.LogisticsService;
36
import com.spice.profitmandi.dao.util.LogisticsService;
35
import com.spice.profitmandi.thrift.clients.UserClient;
37
import com.spice.profitmandi.thrift.clients.UserClient;
36
import com.spice.profitmandi.web.req.AddCartRequest;
38
import com.spice.profitmandi.web.req.AddCartRequest;
Line 59... Line 61...
59
	private UserAccountRepository userAccountRepository;
61
	private UserAccountRepository userAccountRepository;
60
	
62
	
61
	@Autowired
63
	@Autowired
62
	private ContentPojoPopulator contentPojoPopulator;
64
	private ContentPojoPopulator contentPojoPopulator;
63
	
65
	
-
 
66
	@Autowired
-
 
67
	private ItemRepository itemRepository;
-
 
68
	
64
 
69
 
65
	@RequestMapping(value = ProfitMandiConstants.URL_CART, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
70
	@RequestMapping(value = ProfitMandiConstants.URL_CART, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
66
	@ApiImplicitParams({
71
	@ApiImplicitParams({
67
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
72
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
68
				required = true, dataType = "string", paramType = "header")
73
				required = true, dataType = "string", paramType = "header")
Line 124... Line 129...
124
						messagesArray.put(message);
129
						messagesArray.put(message);
125
						cartObj.put("cartMessagesMerged", cartObj.getInt("cartMessagesMerged") + 1);
130
						cartObj.put("cartMessagesMerged", cartObj.getInt("cartMessagesMerged") + 1);
126
					}
131
					}
127
				}
132
				}
128
			}
133
			}
-
 
134
			try {
129
			ProductPojo pp = contentPojoPopulator.getShortContent(itemObj.getLong("catalogItemId"));
135
			ProductPojo pp = contentPojoPopulator.getShortContent(itemObj.getLong("catalogItemId"));
130
//			String productProperties = ContentServingService.getSnippet(Utils.PRODUCT_PROPERTIES_SNIPPET, pp.getId() +"", -1);
136
//			String productProperties = ContentServingService.getSnippet(Utils.PRODUCT_PROPERTIES_SNIPPET, pp.getId() +"", -1);
131
//			JSONObject productPropertiesInJson = new JSONObject(productProperties);
137
//			JSONObject productPropertiesInJson = new JSONObject(productProperties);
132
//			pp.setCategoryName(productPropertiesInJson.getString("categoryName"));
138
//			pp.setCategoryName(productPropertiesInJson.getString("categoryName"));
133
 
139
 
Line 137... Line 143...
137
				}
143
				}
138
				if(itemObj.getInt("estimate") > maxEstimate){
144
				if(itemObj.getInt("estimate") > maxEstimate){
139
					maxEstimate = itemObj.getInt("estimate");
145
					maxEstimate = itemObj.getInt("estimate");
140
				}
146
				}
141
			}
147
			}
142
			itemObj.put("imageUrl", pp.getImageUrl());
148
				itemObj.put("imageUrl", pp.getImageUrl());
143
			itemObj.put("title", pp.getTitle());
149
				itemObj.put("title", pp.getTitle());
-
 
150
			} catch (Throwable t) {
-
 
151
				Item item = itemRepository.selectById(itemObj.getInt("itemId"));
-
 
152
				itemObj.put("imageUrl", "");
-
 
153
				itemObj.put("title", item.getBrand() + " " + item.getModelName() + "" + item.getModelNumber());
-
 
154
			}
144
		}
155
		}
145
 
156
 
146
		ArrayList<JSONObject> listdata = new ArrayList<JSONObject>();     
157
		ArrayList<JSONObject> listdata = new ArrayList<JSONObject>();     
147
		if (arr != null) { 
158
		if (arr != null) { 
148
			for (int i=0;i<arr.length();i++){
159
			for (int i=0;i<arr.length();i++){