| 22981 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import java.util.Map;
|
|
|
4 |
|
|
|
5 |
import javax.servlet.http.HttpServletRequest;
|
|
|
6 |
|
|
|
7 |
import org.slf4j.Logger;
|
|
|
8 |
import org.slf4j.LoggerFactory;
|
|
|
9 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23330 |
ashik.ali |
10 |
import org.springframework.http.ResponseEntity;
|
| 22981 |
ashik.ali |
11 |
import org.springframework.stereotype.Controller;
|
|
|
12 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
13 |
import org.springframework.ui.Model;
|
| 23026 |
ashik.ali |
14 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 22981 |
ashik.ali |
15 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
16 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
17 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
18 |
|
|
|
19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 23026 |
ashik.ali |
21 |
import com.spice.profitmandi.common.model.UpdateRetailerRequest;
|
| 23330 |
ashik.ali |
22 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 22981 |
ashik.ali |
23 |
import com.spice.profitmandi.service.user.RetailerService;
|
|
|
24 |
|
|
|
25 |
@Controller
|
|
|
26 |
@Transactional(rollbackFor=Throwable.class)
|
|
|
27 |
public class RetailerController {
|
|
|
28 |
|
|
|
29 |
private static final Logger LOGGER = LoggerFactory.getLogger(RetailerController.class);
|
|
|
30 |
|
|
|
31 |
@Autowired
|
|
|
32 |
private RetailerService retailerService;
|
|
|
33 |
|
| 23330 |
ashik.ali |
34 |
@Autowired
|
|
|
35 |
private ResponseSender<?> responseSender;
|
|
|
36 |
|
| 22981 |
ashik.ali |
37 |
@RequestMapping(value = "/retailerDetail", method = RequestMethod.GET)
|
|
|
38 |
public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber, Model model) throws ProfitMandiBusinessException{
|
|
|
39 |
LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(), emailIdOrMobileNumber);
|
|
|
40 |
Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
|
|
|
41 |
model.addAllAttributes(map);
|
|
|
42 |
return "retailer-details";
|
|
|
43 |
}
|
|
|
44 |
|
| 23026 |
ashik.ali |
45 |
@RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
|
|
|
46 |
public String updateRetailerDetails(HttpServletRequest request, @RequestBody UpdateRetailerRequest updateRetailerRequest, Model model) throws ProfitMandiBusinessException{
|
|
|
47 |
LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), updateRetailerRequest);
|
|
|
48 |
Map<String, Object> map = retailerService.updateRetailerDetails(updateRetailerRequest);
|
|
|
49 |
model.addAllAttributes(map);
|
|
|
50 |
return "retailer-details";
|
|
|
51 |
}
|
|
|
52 |
|
| 22981 |
ashik.ali |
53 |
|
|
|
54 |
@RequestMapping(value = "/retailerInfo", method = RequestMethod.GET)
|
|
|
55 |
public String retailerInfo(HttpServletRequest request) throws Exception{
|
|
|
56 |
return "retailer-info";
|
|
|
57 |
}
|
| 23330 |
ashik.ali |
58 |
|
|
|
59 |
@RequestMapping(value = "/district/all/stateName", method = RequestMethod.GET)
|
|
|
60 |
public ResponseEntity<?> getAllDistrict(@RequestParam(name = "stateName") String stateName){
|
|
|
61 |
return responseSender.ok(retailerService.getAllDistrictMaster(stateName));
|
|
|
62 |
}
|
| 22981 |
ashik.ali |
63 |
}
|