| Line 5... |
Line 5... |
| 5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 6 |
import com.spice.profitmandi.dao.entity.catalog.Catalog;
|
6 |
import com.spice.profitmandi.dao.entity.catalog.Catalog;
|
| 7 |
import com.spice.profitmandi.dao.entity.catalog.ModelHotDeal;
|
7 |
import com.spice.profitmandi.dao.entity.catalog.ModelHotDeal;
|
| 8 |
import com.spice.profitmandi.dao.repository.catalog.CatalogRepository;
|
8 |
import com.spice.profitmandi.dao.repository.catalog.CatalogRepository;
|
| 9 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
9 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| - |
|
10 |
import com.spice.profitmandi.service.catalog.HotDealAttributes;
|
| 10 |
import com.spice.profitmandi.service.catalog.ModelHotDealService;
|
11 |
import com.spice.profitmandi.service.catalog.ModelHotDealService;
|
| 11 |
import com.spice.profitmandi.web.model.LoginDetails;
|
12 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 12 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
13 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 13 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
14 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 14 |
import org.slf4j.Logger;
|
15 |
import org.slf4j.Logger;
|
| Line 91... |
Line 92... |
| 91 |
}
|
92 |
}
|
| 92 |
|
93 |
|
| 93 |
@RequestMapping(value = "/hotDeals/add", method = RequestMethod.POST)
|
94 |
@RequestMapping(value = "/hotDeals/add", method = RequestMethod.POST)
|
| 94 |
public String addHotDeal(HttpServletRequest request, @RequestParam int brandId,
|
95 |
public String addHotDeal(HttpServletRequest request, @RequestParam int brandId,
|
| 95 |
@RequestParam int catalogItemId, @RequestParam String startDate,
|
96 |
@RequestParam int catalogItemId, @RequestParam String startDate,
|
| - |
|
97 |
@RequestParam String endDate,
|
| - |
|
98 |
@RequestParam(required = false) Integer warrantyMonths,
|
| - |
|
99 |
@RequestParam(required = false) String condition,
|
| - |
|
100 |
@RequestParam(required = false) Boolean activated,
|
| - |
|
101 |
@RequestParam(required = false) Boolean financeMapping,
|
| - |
|
102 |
@RequestParam(required = false) Boolean affordability,
|
| 96 |
@RequestParam String endDate, Model model) throws Exception {
|
103 |
Model model) throws Exception {
|
| - |
|
104 |
// required=false so a missing field reaches the service's mandatory-field
|
| - |
|
105 |
// validation and comes back as a readable message instead of a Spring 400
|
| 97 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
106 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 98 |
try {
|
107 |
try {
|
| - |
|
108 |
HotDealAttributes attributes = new HotDealAttributes(warrantyMonths, condition,
|
| - |
|
109 |
activated, financeMapping, affordability);
|
| 99 |
modelHotDealService.addDeal(brandId, catalogItemId, LocalDate.parse(startDate),
|
110 |
modelHotDealService.addDeal(brandId, catalogItemId, LocalDate.parse(startDate),
|
| 100 |
LocalDate.parse(endDate), loginDetails.getEmailId());
|
111 |
LocalDate.parse(endDate), attributes, loginDetails.getEmailId());
|
| 101 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
112 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 102 |
} catch (ProfitMandiBusinessException e) {
|
113 |
} catch (ProfitMandiBusinessException e) {
|
| 103 |
LOGGER.warn("Hot deal add rejected: {}", e.getMessage());
|
114 |
LOGGER.warn("Hot deal add rejected: {}", e.getMessage());
|
| 104 |
model.addAttribute("response1", e.getMessage());
|
115 |
model.addAttribute("response1", e.getMessage());
|
| 105 |
}
|
116 |
}
|
| Line 107... |
Line 118... |
| 107 |
}
|
118 |
}
|
| 108 |
|
119 |
|
| 109 |
@RequestMapping(value = "/hotDeals/update", method = RequestMethod.POST)
|
120 |
@RequestMapping(value = "/hotDeals/update", method = RequestMethod.POST)
|
| 110 |
public String updateHotDeal(HttpServletRequest request, @RequestParam int id,
|
121 |
public String updateHotDeal(HttpServletRequest request, @RequestParam int id,
|
| 111 |
@RequestParam String startDate, @RequestParam String endDate,
|
122 |
@RequestParam String startDate, @RequestParam String endDate,
|
| - |
|
123 |
@RequestParam(required = false) Integer warrantyMonths,
|
| - |
|
124 |
@RequestParam(required = false) String condition,
|
| - |
|
125 |
@RequestParam(required = false) Boolean activated,
|
| - |
|
126 |
@RequestParam(required = false) Boolean financeMapping,
|
| - |
|
127 |
@RequestParam(required = false) Boolean affordability,
|
| 112 |
Model model) throws Exception {
|
128 |
Model model) throws Exception {
|
| 113 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
129 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 114 |
try {
|
130 |
try {
|
| - |
|
131 |
HotDealAttributes attributes = new HotDealAttributes(warrantyMonths, condition,
|
| - |
|
132 |
activated, financeMapping, affordability);
|
| 115 |
modelHotDealService.updateDates(id, LocalDate.parse(startDate), LocalDate.parse(endDate),
|
133 |
modelHotDealService.updateDeal(id, LocalDate.parse(startDate), LocalDate.parse(endDate),
|
| 116 |
loginDetails.getEmailId());
|
134 |
attributes, loginDetails.getEmailId());
|
| 117 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
135 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 118 |
} catch (ProfitMandiBusinessException e) {
|
136 |
} catch (ProfitMandiBusinessException e) {
|
| 119 |
LOGGER.warn("Hot deal update rejected: {}", e.getMessage());
|
137 |
LOGGER.warn("Hot deal update rejected: {}", e.getMessage());
|
| 120 |
model.addAttribute("response1", e.getMessage());
|
138 |
model.addAttribute("response1", e.getMessage());
|
| 121 |
}
|
139 |
}
|