Subversion Repositories SmartDukaan

Rev

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

Rev 23955 Rev 24123
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.spice.profitmandi.common.enumuration.ContentType;
25
import com.spice.profitmandi.common.enumuration.ContentType;
26
import com.spice.profitmandi.common.enumuration.CounterSize;
26
import com.spice.profitmandi.common.enumuration.CounterSize;
27
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
27
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
-
 
28
import com.spice.profitmandi.common.model.AddLocationModel;
28
import com.spice.profitmandi.common.model.ProfitMandiConstants;
29
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
30
import com.spice.profitmandi.common.model.SendNotificationModel;
29
import com.spice.profitmandi.common.model.UpdateRetailerRequest;
31
import com.spice.profitmandi.common.model.UpdateRetailerRequest;
-
 
32
import com.spice.profitmandi.common.util.Utils;
30
import com.spice.profitmandi.common.web.util.ResponseSender;
33
import com.spice.profitmandi.common.web.util.ResponseSender;
31
import com.spice.profitmandi.dao.entity.dtr.Document;
34
import com.spice.profitmandi.dao.entity.dtr.Document;
32
import com.spice.profitmandi.dao.entity.dtr.Retailer;
35
import com.spice.profitmandi.dao.entity.dtr.Retailer;
33
import com.spice.profitmandi.dao.entity.dtr.Shop;
36
import com.spice.profitmandi.dao.entity.dtr.Shop;
-
 
37
import com.spice.profitmandi.dao.entity.user.User;
-
 
38
import com.spice.profitmandi.dao.entity.user.Location;
34
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
39
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
35
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
40
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
36
import com.spice.profitmandi.dao.repository.dtr.ShopRepository;
41
import com.spice.profitmandi.dao.repository.dtr.ShopRepository;
-
 
42
import com.spice.profitmandi.dao.repository.user.LocationRepository;
-
 
43
import com.spice.profitmandi.dao.repository.user.UserRepository;
37
import com.spice.profitmandi.service.user.RetailerService;
44
import com.spice.profitmandi.service.user.RetailerService;
-
 
45
import com.spice.profitmandi.web.util.MVCResponseSender;
38
 
46
 
39
@Controller
47
@Controller
40
@Transactional(rollbackFor=Throwable.class)
48
@Transactional(rollbackFor=Throwable.class)
41
public class RetailerController {
49
public class RetailerController {
42
 
50
 
Line 53... Line 61...
53
	
61
	
54
	@Autowired
62
	@Autowired
55
	private DocumentRepository documentRepository;
63
	private DocumentRepository documentRepository;
56
	
64
	
57
	@Autowired
65
	@Autowired
-
 
66
	private UserRepository userRepository;
-
 
67
	
-
 
68
	@Autowired
-
 
69
	private LocationRepository locationRepository;
-
 
70
	
-
 
71
	@Autowired
58
	private ResponseSender<?> responseSender;
72
	private ResponseSender<?> responseSender;
59
	
73
	
-
 
74
	@Autowired
-
 
75
	private MVCResponseSender mvcResponseSender;
-
 
76
	
60
	@RequestMapping(value = "/retailerDetails", method = RequestMethod.GET)
77
	@RequestMapping(value = "/retailerDetails", method = RequestMethod.GET)
61
	public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber, Model model)  throws ProfitMandiBusinessException{
78
	public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber, Model model)  throws ProfitMandiBusinessException{
62
		LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(), emailIdOrMobileNumber);
79
		LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(), emailIdOrMobileNumber);
63
		Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
80
		Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
64
		model.addAllAttributes(map);
81
		model.addAllAttributes(map);
65
		model.addAttribute("counterSizes", CounterSize.values());
82
		model.addAttribute("counterSizes", CounterSize.values());
-
 
83
		User user = userRepository.selectByEmailId(emailIdOrMobileNumber);
-
 
84
		if(user.getLocation() != null){
-
 
85
		Location location = locationRepository.selectById(user.getLocation());
-
 
86
		model.addAttribute("locationdetail",location);
-
 
87
		 LOGGER.info("location"+location );
-
 
88
		}
-
 
89
		LOGGER.info("map detail"+ map) ;
-
 
90
      
66
		return "retailer-details";
91
		return "retailer-details";
67
	}
92
	}
68
	
93
	
69
	@RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
94
	@RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
70
	public String updateRetailerDetails(HttpServletRequest request, @RequestBody UpdateRetailerRequest updateRetailerRequest, Model model)  throws ProfitMandiBusinessException{
95
	public String updateRetailerDetails(HttpServletRequest request, @RequestBody UpdateRetailerRequest updateRetailerRequest, Model model)  throws ProfitMandiBusinessException{
Line 195... Line 220...
195
        final InputStreamResource inputStreamResource=new InputStreamResource(file);
220
        final InputStreamResource inputStreamResource=new InputStreamResource(file);
196
        return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
221
        return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
197
		
222
		
198
		//return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
223
		//return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
199
	}
224
	}
-
 
225
	
-
 
226
	@RequestMapping(value = "/getAddLocation", method = RequestMethod.GET)
-
 
227
	public String getAddLocationModal(HttpServletRequest request , Model model)  throws ProfitMandiBusinessException{
-
 
228
		model.addAttribute("stateNames", Utils.getAllStateNames());
-
 
229
      
-
 
230
		return "add-location-modal";
-
 
231
	}
-
 
232
	
-
 
233
	@RequestMapping(value = "/addLocation", method = RequestMethod.POST)
-
 
234
	public String addLocation(HttpServletRequest request , @RequestBody AddLocationModel addLocationModel,Model model)  throws Exception{
-
 
235
		
-
 
236
        Location location = new Location();
-
 
237
        location.setName(addLocationModel.getName());
-
 
238
        location.setLine1(addLocationModel.getLine1());
-
 
239
        location.setLine2(addLocationModel.getLine2());
-
 
240
        location.setCity(addLocationModel.getCity());
-
 
241
        location.setState(addLocationModel.getState());
-
 
242
        location.setPin(addLocationModel.getPin());
-
 
243
        
-
 
244
        LOGGER.info("PostLocation"+location);
-
 
245
       locationRepository.persist(location);
-
 
246
        
-
 
247
        model.addAttribute("response", mvcResponseSender.createResponseString(true));
-
 
248
		return "response";
-
 
249
      
-
 
250
	}
200
}
251
}
201
252