Subversion Repositories SmartDukaan

Rev

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

Rev 21496 Rev 21666
Line 11... Line 11...
11
import org.springframework.web.bind.annotation.RequestMethod;
11
import org.springframework.web.bind.annotation.RequestMethod;
12
import org.springframework.web.bind.annotation.RequestParam;
12
import org.springframework.web.bind.annotation.RequestParam;
13
 
13
 
14
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
14
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
15
import com.spice.profitmandi.common.model.ProfitMandiConstants;
15
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
16
import com.spice.profitmandi.dao.model.UserCart;
16
import com.spice.profitmandi.dao.repository.AddressRepository;
17
import com.spice.profitmandi.dao.repository.AddressRepository;
-
 
18
import com.spice.profitmandi.dao.repository.UserAccountRepository;
17
import com.spice.profitmandi.web.util.ResponseSender;
19
import com.spice.profitmandi.web.util.ResponseSender;
18
 
20
 
-
 
21
import io.swagger.annotations.ApiImplicitParam;
-
 
22
import io.swagger.annotations.ApiImplicitParams;
-
 
23
 
19
@Controller
24
@Controller
20
public class AddressController {
25
public class AddressController {
21
	
26
	
22
	@Autowired
27
	@Autowired
23
	ResponseSender<?> responseSender;
28
	ResponseSender<?> responseSender;
Line 25... Line 30...
25
	private static final Logger LOGGER=LoggerFactory.getLogger(AddressController.class);
30
	private static final Logger LOGGER=LoggerFactory.getLogger(AddressController.class);
26
	
31
	
27
	@Autowired
32
	@Autowired
28
	AddressRepository addressRepository;
33
	AddressRepository addressRepository;
29
	
34
	
-
 
35
	@Autowired
-
 
36
	UserAccountRepository userAccountRepository;
-
 
37
	
-
 
38
	
-
 
39
	@ApiImplicitParams({
-
 
40
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
-
 
41
				required = true, dataType = "string", paramType = "header")
-
 
42
	})
30
	@RequestMapping(value = ProfitMandiConstants.URL_ADDRESS_ALL, method=RequestMethod.GET)
43
	@RequestMapping(value = ProfitMandiConstants.URL_ADDRESS_ALL, method=RequestMethod.GET)
31
	public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize){
44
	public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize) throws Throwable{
-
 
45
		int userId = (int)request.getAttribute("userId");
-
 
46
		UserCart uc  = userAccountRepository.getUserCart(userId);
32
		LOGGER.info("requested url : "+request.getRequestURL().toString());
47
		LOGGER.info("requested url : "+request.getRequestURL().toString());
33
		return responseSender.ok(addressRepository.selectAll(pageNumber, pageSize));
48
		return responseSender.ok(addressRepository.selectAll(uc.getUserId(), pageNumber, pageSize));
34
	}
49
	}
35
	
50
	
36
	@RequestMapping(value = ProfitMandiConstants.URL_ADDRESS_ID, method=RequestMethod.GET)
51
	@RequestMapping(value = ProfitMandiConstants.URL_ADDRESS_ID, method=RequestMethod.GET)
37
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
52
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
38
		LOGGER.info("requested url : "+request.getRequestURL().toString());
53
		LOGGER.info("requested url : "+request.getRequestURL().toString());