| Line 21... |
Line 21... |
| 21 |
import com.spice.profitmandi.dao.repository.RetailerRepository;
|
21 |
import com.spice.profitmandi.dao.repository.RetailerRepository;
|
| 22 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
22 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
| 23 |
import com.spice.profitmandi.web.model.Response;
|
23 |
import com.spice.profitmandi.web.model.Response;
|
| 24 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
24 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
| 25 |
|
25 |
|
| - |
|
26 |
import io.swagger.annotations.ApiImplicitParam;
|
| - |
|
27 |
import io.swagger.annotations.ApiImplicitParams;
|
| - |
|
28 |
import io.swagger.annotations.ApiOperation;
|
| - |
|
29 |
|
| 26 |
@Controller
|
30 |
@Controller
|
| 27 |
public class RetailerController {
|
31 |
public class RetailerController {
|
| 28 |
|
32 |
|
| 29 |
private static final Logger LOGGER=LoggerFactory.getLogger(RetailerController.class);
|
33 |
private static final Logger LOGGER=LoggerFactory.getLogger(RetailerController.class);
|
| 30 |
|
34 |
|
| 31 |
@Autowired
|
35 |
@Autowired
|
| 32 |
RetailerRepository retailerRepository;
|
36 |
RetailerRepository retailerRepository;
|
| 33 |
|
37 |
|
| - |
|
38 |
@ApiImplicitParams({
|
| - |
|
39 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| - |
|
40 |
required = true, dataType = "string", paramType = "header")
|
| - |
|
41 |
})
|
| - |
|
42 |
@ApiOperation(value = "Create Retailer")
|
| 34 |
@RequestMapping(value = ProfitMandiConstants.URL_API, method=RequestMethod.POST)
|
43 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER, method=RequestMethod.POST)
|
| 35 |
public ResponseEntity<?> createRetailer(HttpServletRequest request){
|
44 |
public ResponseEntity<?> createRetailer(HttpServletRequest request){
|
| 36 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
45 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 37 |
final Retailer retailer = (Retailer)request.getAttribute(ProfitMandiConstants.RETAILER);
|
46 |
final Retailer retailer = (Retailer)request.getAttribute(ProfitMandiConstants.RETAILER);
|
| 38 |
request.removeAttribute(ProfitMandiConstants.API);
|
47 |
request.removeAttribute(ProfitMandiConstants.RETAILER);
|
| 39 |
try {
|
48 |
try {
|
| 40 |
retailer.setCreateTimestamp(LocalDateTime.now());
|
49 |
retailer.setCreateTimestamp(LocalDateTime.now());
|
| 41 |
retailer.setUpdateTimestamp(LocalDateTime.now());
|
50 |
retailer.setUpdateTimestamp(LocalDateTime.now());
|
| 42 |
retailerRepository.persist(retailer);
|
51 |
retailerRepository.persist(retailer);
|
| 43 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1000"));
|
52 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1000"));
|
| Line 125... |
Line 134... |
| 125 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
134 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
| 126 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
135 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 127 |
}
|
136 |
}
|
| 128 |
}
|
137 |
}
|
| 129 |
|
138 |
|
| 130 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ID,method=RequestMethod.DELETE)
|
139 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_REMOVE, method=RequestMethod.DELETE)
|
| 131 |
public ResponseEntity<?> removeShop(HttpServletRequest request, @RequestParam(name = "shopId") String shopId, @RequestParam(name = "retailerId") String retailerId){
|
140 |
public ResponseEntity<?> removeShop(HttpServletRequest request, @RequestParam(name = "shopId") String shopId, @RequestParam(name = "retailerId") String retailerId){
|
| 132 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
141 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 133 |
try {
|
142 |
try {
|
| 134 |
retailerRepository.removeShop(shopId, retailerId);
|
143 |
retailerRepository.removeShop(shopId, retailerId);
|
| 135 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
144 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
| Line 146... |
Line 155... |
| 146 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
155 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 147 |
}
|
156 |
}
|
| 148 |
}
|
157 |
}
|
| 149 |
|
158 |
|
| 150 |
|
159 |
|
| 151 |
|
- |
|
| 152 |
}
|
160 |
}
|