| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.ByteArrayInputStream;
|
3 |
import java.io.ByteArrayInputStream;
|
| 4 |
import java.io.ByteArrayOutputStream;
|
4 |
import java.io.ByteArrayOutputStream;
|
| 5 |
import java.io.InputStream;
|
5 |
import java.io.InputStream;
|
| - |
|
6 |
import java.time.LocalDate;
|
| 6 |
import java.time.LocalDateTime;
|
7 |
import java.time.LocalDateTime;
|
| - |
|
8 |
import java.time.chrono.ChronoLocalDateTime;
|
| - |
|
9 |
import java.time.format.DateTimeFormatter;
|
| 7 |
import java.util.Arrays;
|
10 |
import java.util.Arrays;
|
| - |
|
11 |
import java.util.HashMap;
|
| 8 |
import java.util.HashSet;
|
12 |
import java.util.HashSet;
|
| 9 |
import java.util.List;
|
13 |
import java.util.List;
|
| 10 |
import java.util.Map;
|
14 |
import java.util.Map;
|
| 11 |
|
15 |
|
| 12 |
import javax.servlet.http.HttpServletRequest;
|
16 |
import javax.servlet.http.HttpServletRequest;
|
| Line 14... |
Line 18... |
| 14 |
import org.apache.logging.log4j.LogManager;
|
18 |
import org.apache.logging.log4j.LogManager;
|
| 15 |
import org.apache.logging.log4j.Logger;
|
19 |
import org.apache.logging.log4j.Logger;
|
| 16 |
import org.springframework.beans.factory.annotation.Autowired;
|
20 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 17 |
import org.springframework.beans.factory.annotation.Qualifier;
|
21 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 18 |
import org.springframework.core.io.InputStreamResource;
|
22 |
import org.springframework.core.io.InputStreamResource;
|
| - |
|
23 |
import org.springframework.format.annotation.DateTimeFormat;
|
| - |
|
24 |
import org.springframework.format.annotation.DateTimeFormat.ISO;
|
| 19 |
import org.springframework.http.HttpHeaders;
|
25 |
import org.springframework.http.HttpHeaders;
|
| 20 |
import org.springframework.http.HttpStatus;
|
26 |
import org.springframework.http.HttpStatus;
|
| 21 |
import org.springframework.http.ResponseEntity;
|
27 |
import org.springframework.http.ResponseEntity;
|
| 22 |
import org.springframework.stereotype.Controller;
|
28 |
import org.springframework.stereotype.Controller;
|
| 23 |
import org.springframework.transaction.annotation.Transactional;
|
29 |
import org.springframework.transaction.annotation.Transactional;
|
| Line 28... |
Line 34... |
| 28 |
import org.springframework.web.bind.annotation.RequestParam;
|
34 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 29 |
|
35 |
|
| 30 |
import com.spice.profitmandi.common.enumuration.DateTimePattern;
|
36 |
import com.spice.profitmandi.common.enumuration.DateTimePattern;
|
| 31 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
37 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 32 |
import com.spice.profitmandi.common.model.CreateSchemeRequest;
|
38 |
import com.spice.profitmandi.common.model.CreateSchemeRequest;
|
| - |
|
39 |
import com.spice.profitmandi.common.model.MapWrapper;
|
| 33 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
40 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 34 |
import com.spice.profitmandi.common.model.SchemeItems;
|
41 |
import com.spice.profitmandi.common.model.SchemeItems;
|
| 35 |
import com.spice.profitmandi.common.model.SchemeModel;
|
42 |
import com.spice.profitmandi.common.model.SchemeModel;
|
| 36 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
43 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 37 |
import com.spice.profitmandi.common.util.StringUtils;
|
44 |
import com.spice.profitmandi.common.util.StringUtils;
|
| Line 75... |
Line 82... |
| 75 |
@Qualifier("fofoInventoryService")
|
82 |
@Qualifier("fofoInventoryService")
|
| 76 |
private InventoryService inventoryService;
|
83 |
private InventoryService inventoryService;
|
| 77 |
|
84 |
|
| 78 |
@Autowired
|
85 |
@Autowired
|
| 79 |
private TagListingRepository tagListingRepository;
|
86 |
private TagListingRepository tagListingRepository;
|
| 80 |
|
87 |
|
| 81 |
@Autowired
|
88 |
@Autowired
|
| 82 |
private RoleManager roleManager;
|
89 |
private RoleManager roleManager;
|
| 83 |
|
90 |
|
| 84 |
@Autowired
|
91 |
@Autowired
|
| 85 |
PurchaseRepository purchaseRepository;
|
92 |
PurchaseRepository purchaseRepository;
|
| Line 93... |
Line 100... |
| 93 |
@RequestMapping(value = "/createScheme", method = RequestMethod.GET)
|
100 |
@RequestMapping(value = "/createScheme", method = RequestMethod.GET)
|
| 94 |
public String createScheme(HttpServletRequest request, Model model) {
|
101 |
public String createScheme(HttpServletRequest request, Model model) {
|
| 95 |
// Map<Integer, String> itemIdItemDescriptionMap =
|
102 |
// Map<Integer, String> itemIdItemDescriptionMap =
|
| 96 |
// inventoryService.getAllItemIdItemDescriptionMap();
|
103 |
// inventoryService.getAllItemIdItemDescriptionMap();
|
| 97 |
// model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
104 |
// model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
| 98 |
model.addAttribute("brands", inventoryService.getAllTagListingBrands());
|
105 |
model.addAttribute("brands", inventoryService.getAllTagListingBrands(ProfitMandiConstants.MOBILE_CATEGORY_ID));
|
| 99 |
return "create-scheme";
|
106 |
return "create-scheme";
|
| 100 |
}
|
107 |
}
|
| 101 |
|
108 |
|
| 102 |
@RequestMapping(value = "/getTagListingItemsByBrand", method = RequestMethod.GET)
|
109 |
@RequestMapping(value = "/getTagListingItemsByBrand", method = RequestMethod.POST)
|
| 103 |
public String getTagListingItemsByBrand(HttpServletRequest request,
|
110 |
public String getTagListingItemsByBrand(HttpServletRequest request, @RequestBody List<String> brands, Model model) {
|
| 104 |
@RequestParam(name = ProfitMandiConstants.BRAND) String brand, Model model) {
|
111 |
Map<Integer, String> itemIdItemDescriptionMap = new HashMap<>();
|
| - |
|
112 |
LOGGER.info("brands" + brands);
|
| - |
|
113 |
|
| 105 |
Map<Integer, String> itemIdItemDescriptionMap = inventoryService
|
114 |
List<MapWrapper<Integer, String>> itemIdItemDescriptionMaplist = inventoryService
|
| 106 |
.getAllTagListingItemIdItemDescriptionMap(brand);
|
115 |
.getAllTagListingItemIdItemDescriptionMap(new HashSet<>(brands));
|
| - |
|
116 |
for (MapWrapper<Integer, String> mapWrapper : itemIdItemDescriptionMaplist) {
|
| - |
|
117 |
itemIdItemDescriptionMap.put(mapWrapper.getKey(), mapWrapper.getValue());
|
| - |
|
118 |
}
|
| 107 |
model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
119 |
model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
| 108 |
// model.addAttribute("brands", inventoryService.getAllBrands());
|
120 |
// model.addAttribute("brands", inventoryService.getAllBrands());
|
| - |
|
121 |
|
| 109 |
return "tag-listing-items-description";
|
122 |
return "tag-listing-items-description";
|
| 110 |
}
|
123 |
}
|
| 111 |
|
124 |
|
| 112 |
@RequestMapping(value = "/schemes/update-schemes-page", method = RequestMethod.GET)
|
125 |
@RequestMapping(value = "/schemes/update-schemes-page", method = RequestMethod.GET)
|
| 113 |
public String updateShcemes(HttpServletRequest request) throws ProfitMandiBusinessException {
|
126 |
public String updateShcemes(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| Line 120... |
Line 133... |
| 120 |
|
133 |
|
| 121 |
@RequestMapping(value = "/schemes/update", method = RequestMethod.POST)
|
134 |
@RequestMapping(value = "/schemes/update", method = RequestMethod.POST)
|
| 122 |
public String updateShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
|
135 |
public String updateShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
|
| 123 |
throws Exception {
|
136 |
throws Exception {
|
| 124 |
for (int schemeId : schemeItems.getSchemeIds()) {
|
137 |
for (int schemeId : schemeItems.getSchemeIds()) {
|
| - |
|
138 |
List<Integer> itemIds = schemeItemRepository.selectItemIdsBySchemeId(schemeId);
|
| 125 |
if (schemeRepository.selectById(schemeId) != null)
|
139 |
if (schemeRepository.selectById(schemeId) != null)
|
| 126 |
for (int itemId : schemeItems.getItemIds()) {
|
140 |
for (int itemId : schemeItems.getItemIds()) {
|
| 127 |
if (tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)),
|
141 |
if (tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)),
|
| 128 |
new HashSet<>(Arrays.asList(4, 7))).size() > 0) {
|
142 |
new HashSet<>(Arrays.asList(4, 7))).size() > 0 && (!(itemIds.contains(itemId)))) {
|
| 129 |
SchemeItem si = new SchemeItem();
|
143 |
SchemeItem si = new SchemeItem();
|
| 130 |
si.setItemId(itemId);
|
144 |
si.setItemId(itemId);
|
| 131 |
si.setSchemeId(schemeId);
|
145 |
si.setSchemeId(schemeId);
|
| 132 |
try {
|
146 |
try {
|
| 133 |
schemeItemRepository.persist(si);
|
147 |
schemeItemRepository.persist(si);
|
| 134 |
} catch (Exception e) {
|
148 |
} catch (Exception e) {
|
| 135 |
LOGGER.info("Scheme aleady exist");
|
149 |
LOGGER.info("Scheme already exist");
|
| 136 |
}
|
150 |
}
|
| 137 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
151 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 138 |
} else {
|
152 |
} else {
|
| 139 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
153 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
| 140 |
throw new ProfitMandiBusinessException("ItemId", itemId, "Invalid Item Id");
|
- |
|
| 141 |
}
|
154 |
}
|
| 142 |
}
|
155 |
}
|
| 143 |
}
|
156 |
}
|
| 144 |
return "response";
|
157 |
return "response";
|
| 145 |
}
|
158 |
}
|
| - |
|
159 |
|
| 146 |
@RequestMapping(value = "/schemes/delete", method = RequestMethod.POST)
|
160 |
@RequestMapping(value = "/schemes/delete", method = RequestMethod.DELETE)
|
| 147 |
public String deleteShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
|
161 |
public String deleteShcemes(HttpServletRequest request,
|
| - |
|
162 |
@RequestParam(name = "schemeId", required = false, defaultValue = "0") int schemeId,
|
| - |
|
163 |
@RequestParam(name = "itemId", required = false, defaultValue = "0") int itemId, Model model)
|
| 148 |
throws Exception {
|
164 |
throws Exception {
|
| - |
|
165 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
166 |
if (!(schemeId == 0 && itemId == 0) || (!(schemeId == 0 || itemId == 0))) {
|
| 149 |
if (schemeItemRepository.selectBySchemeIdsAndItemIds(new HashSet<>(schemeItems.getSchemeIds()),
|
167 |
schemeItemRepository.deletebyItemIdsandSchemeIds(itemId, schemeId);
|
| - |
|
168 |
|
| - |
|
169 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
170 |
|
| - |
|
171 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| - |
|
172 |
|
| - |
|
173 |
}
|
| - |
|
174 |
return "response";
|
| - |
|
175 |
}
|
| - |
|
176 |
|
| - |
|
177 |
@RequestMapping(value = "/extendAllSchemes", method = RequestMethod.POST)
|
| - |
|
178 |
public String extendAllScheme(HttpServletRequest request, @RequestBody LocalDateTime extendDatetime, Model model)
|
| - |
|
179 |
throws Exception {
|
| - |
|
180 |
|
| - |
|
181 |
LOGGER.info("ExtendDatetime" + extendDatetime);
|
| - |
|
182 |
List<Scheme> schemes = schemeRepository.selectActiveAll();
|
| 150 |
new HashSet<>(schemeItems.getItemIds())).size() > 0) {
|
183 |
if (schemes.size() > 0) {
|
| 151 |
for (int schemeId : schemeItems.getSchemeIds()) {
|
184 |
for (Scheme scheme : schemes) {
|
| - |
|
185 |
if (scheme.getEndDateTime().isBefore(extendDatetime) && scheme.getExpireTimestamp() == null
|
| 152 |
for (int itemId : schemeItems.getItemIds()) {
|
186 |
&& (!(scheme.getActiveTimestamp() == null))) {
|
| 153 |
schemeItemRepository.deletebyItemIdsandSchemeIds(itemId, schemeId);
|
187 |
scheme.setEndDateTime(extendDatetime);
|
| 154 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
188 |
schemeRepository.persist(scheme);
|
| - |
|
189 |
} else {
|
| - |
|
190 |
continue;
|
| 155 |
}
|
191 |
}
|
| 156 |
}
|
192 |
}
|
| 157 |
} else {
|
- |
|
| 158 |
throw new ProfitMandiBusinessException("ItemId", schemeItems.getItemIds(), "invalid Item Id");
|
193 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
194 |
return "response";
|
| 159 |
}
|
195 |
}
|
| - |
|
196 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
| 160 |
return "response";
|
197 |
return "response";
|
| 161 |
}
|
198 |
}
|
| 162 |
|
199 |
|
| - |
|
200 |
@RequestMapping(value = "/extendSchemeById", method = RequestMethod.POST)
|
| - |
|
201 |
public String extendSchemeById(HttpServletRequest request,
|
| - |
|
202 |
|
| - |
|
203 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId,
|
| - |
|
204 |
@RequestBody LocalDateTime extendDatetime, Model model) throws Exception {
|
| - |
|
205 |
|
| - |
|
206 |
LOGGER.info("ExtendDatetime" + extendDatetime);
|
| - |
|
207 |
LOGGER.info("schemeId" + schemeId);
|
| - |
|
208 |
Scheme scheme = schemeRepository.selectById(schemeId);
|
| - |
|
209 |
if ((!(scheme.getActiveTimestamp() == null)) && scheme.getExpireTimestamp() == null) {
|
| - |
|
210 |
scheme.setEndDateTime(extendDatetime);
|
| - |
|
211 |
schemeRepository.persist(scheme);
|
| - |
|
212 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
213 |
return "response";
|
| - |
|
214 |
}
|
| - |
|
215 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
| - |
|
216 |
return "response";
|
| - |
|
217 |
}
|
| 163 |
|
218 |
|
| 164 |
@RequestMapping(value = "/createScheme", method = RequestMethod.POST)
|
219 |
@RequestMapping(value = "/createScheme", method = RequestMethod.POST)
|
| 165 |
public String createScheme(HttpServletRequest request, @RequestBody CreateSchemeRequest createSchemeRequest,
|
220 |
public String createScheme(HttpServletRequest request, @RequestBody CreateSchemeRequest createSchemeRequest,
|
| 166 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
221 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 167 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
222 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| Line 177... |
Line 232... |
| 177 |
model.addAttribute("schemes", schemes);
|
232 |
model.addAttribute("schemes", schemes);
|
| 178 |
model.addAttribute("start", offset + 1);
|
233 |
model.addAttribute("start", offset + 1);
|
| 179 |
model.addAttribute("size", size);
|
234 |
model.addAttribute("size", size);
|
| 180 |
model.addAttribute("searchItem", searchItem);
|
235 |
model.addAttribute("searchItem", searchItem);
|
| 181 |
model.addAttribute("searchTerm", searchTerm);
|
236 |
model.addAttribute("searchTerm", searchTerm);
|
| - |
|
237 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 182 |
if (schemes.size() < limit) {
|
238 |
if (schemes.size() < limit) {
|
| 183 |
model.addAttribute("end", offset + schemes.size());
|
239 |
model.addAttribute("end", offset + schemes.size());
|
| 184 |
} else {
|
240 |
} else {
|
| 185 |
model.addAttribute("end", offset + limit);
|
241 |
model.addAttribute("end", offset + limit);
|
| 186 |
}
|
242 |
}
|
| Line 207... |
Line 263... |
| 207 |
model.addAttribute("schemes", schemes);
|
263 |
model.addAttribute("schemes", schemes);
|
| 208 |
model.addAttribute("start", offset + 1);
|
264 |
model.addAttribute("start", offset + 1);
|
| 209 |
model.addAttribute("size", size);
|
265 |
model.addAttribute("size", size);
|
| 210 |
model.addAttribute("searchItem", searchItem);
|
266 |
model.addAttribute("searchItem", searchItem);
|
| 211 |
model.addAttribute("searchTerm", searchTerm);
|
267 |
model.addAttribute("searchTerm", searchTerm);
|
| - |
|
268 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 212 |
if (schemes.size() < limit) {
|
269 |
if (schemes.size() < limit) {
|
| 213 |
model.addAttribute("end", offset + schemes.size());
|
270 |
model.addAttribute("end", offset + schemes.size());
|
| 214 |
} else {
|
271 |
} else {
|
| 215 |
model.addAttribute("end", offset + limit);
|
272 |
model.addAttribute("end", offset + limit);
|
| 216 |
}
|
273 |
}
|
| Line 230... |
Line 287... |
| 230 |
schemes = schemeRepository.selectAll(offset, limit);
|
287 |
schemes = schemeRepository.selectAll(offset, limit);
|
| 231 |
} else {
|
288 |
} else {
|
| 232 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
289 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
| 233 |
}
|
290 |
}
|
| 234 |
model.addAttribute("schemes", schemes);
|
291 |
model.addAttribute("schemes", schemes);
|
| 235 |
model.addAttribute("roleIds", loginDetails.getRoleIds());
|
292 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 236 |
return "schemes-paginated";
|
293 |
return "schemes-paginated";
|
| 237 |
}
|
294 |
}
|
| 238 |
|
295 |
|
| 239 |
@RequestMapping(value = "/schemes/downloadPage", method = RequestMethod.GET)
|
296 |
@RequestMapping(value = "/schemes/downloadPage", method = RequestMethod.GET)
|
| 240 |
public String downloadPage(HttpServletRequest request, Model model) {
|
297 |
public String downloadPage(HttpServletRequest request, Model model) {
|
| 241 |
return "schemes-download";
|
298 |
return "schemes-download";
|
| 242 |
}
|
299 |
}
|
| 243 |
|
300 |
|
| 244 |
@RequestMapping(value = "/schemes/download", method = RequestMethod.GET)
|
301 |
@RequestMapping(value = "/schemes/download", method = RequestMethod.GET)
|
| 245 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request,
|
302 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request,
|
| 246 |
@RequestParam LocalDateTime startDateTime,
|
303 |
@RequestParam(name = ProfitMandiConstants.START_DATE_TIME) String startDateTimeString,
|
| 247 |
@RequestParam LocalDateTime endDateTime, Model model)
|
304 |
@RequestParam(name = ProfitMandiConstants.END_DATE_TIME) String endDateTimeString, Model model)
|
| 248 |
throws ProfitMandiBusinessException {
|
305 |
throws ProfitMandiBusinessException {
|
| - |
|
306 |
LocalDateTime startDateTime = StringUtils.toDateTime(startDateTimeString,
|
| - |
|
307 |
DateTimePattern.DD_MM_YYYY_T_HH_MM_SS);
|
| - |
|
308 |
LocalDateTime endDateTime = StringUtils.toDateTime(endDateTimeString, DateTimePattern.DD_MM_YYYY_T_HH_MM_SS);
|
| - |
|
309 |
|
| 249 |
List<SchemeModel> schemeModels = schemeService.getAllSchemeModels(startDateTime, endDateTime);
|
310 |
List<SchemeModel> schemeModels = schemeService.getAllSchemeModels(startDateTime, endDateTime);
|
| 250 |
|
311 |
|
| 251 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
312 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| 252 |
ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
313 |
ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
| 253 |
|
314 |
|
| Line 267... |
Line 328... |
| 267 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, Model model)
|
328 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, Model model)
|
| 268 |
throws ProfitMandiBusinessException {
|
329 |
throws ProfitMandiBusinessException {
|
| 269 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
330 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 270 |
Scheme scheme = schemeService.getSchemeById(schemeId);
|
331 |
Scheme scheme = schemeService.getSchemeById(schemeId);
|
| 271 |
model.addAttribute("scheme", scheme);
|
332 |
model.addAttribute("scheme", scheme);
|
| 272 |
model.addAttribute("isFofoAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
333 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 273 |
return "scheme-details";
|
334 |
return "scheme-details";
|
| - |
|
335 |
|
| 274 |
}
|
336 |
}
|
| 275 |
|
337 |
|
| 276 |
@RequestMapping(value = "/activeSchemeById", method = RequestMethod.PUT)
|
338 |
@RequestMapping(value = "/activeSchemeById", method = RequestMethod.PUT)
|
| 277 |
public String activeSchemeById(HttpServletRequest request,
|
339 |
public String activeSchemeById(HttpServletRequest request,
|
| 278 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId,
|
340 |
@RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId,
|
| Line 324... |
Line 386... |
| 324 |
model.addAttribute("schemes", schemes);
|
386 |
model.addAttribute("schemes", schemes);
|
| 325 |
model.addAttribute("start", offset + 1);
|
387 |
model.addAttribute("start", offset + 1);
|
| 326 |
model.addAttribute("size", size);
|
388 |
model.addAttribute("size", size);
|
| 327 |
model.addAttribute("searchTerm", searchTerm);
|
389 |
model.addAttribute("searchTerm", searchTerm);
|
| 328 |
model.addAttribute("searchItem", searchItem);
|
390 |
model.addAttribute("searchItem", searchItem);
|
| - |
|
391 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 329 |
if (schemes.size() < limit) {
|
392 |
if (schemes.size() < limit) {
|
| 330 |
model.addAttribute("end", offset + schemes.size());
|
393 |
model.addAttribute("end", offset + schemes.size());
|
| 331 |
} else {
|
394 |
} else {
|
| 332 |
model.addAttribute("end", offset + limit);
|
395 |
model.addAttribute("end", offset + limit);
|
| 333 |
}
|
396 |
}
|
| Line 344... |
Line 407... |
| 344 |
model.addAttribute("schemes", schemes);
|
407 |
model.addAttribute("schemes", schemes);
|
| 345 |
model.addAttribute("start", offset + 1);
|
408 |
model.addAttribute("start", offset + 1);
|
| 346 |
model.addAttribute("size", size);
|
409 |
model.addAttribute("size", size);
|
| 347 |
model.addAttribute("searchItem", searchItem);
|
410 |
model.addAttribute("searchItem", searchItem);
|
| 348 |
model.addAttribute("searchTerm", searchTerm);
|
411 |
model.addAttribute("searchTerm", searchTerm);
|
| - |
|
412 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 349 |
if (schemes.size() < limit) {
|
413 |
if (schemes.size() < limit) {
|
| 350 |
model.addAttribute("end", offset + schemes.size());
|
414 |
model.addAttribute("end", offset + schemes.size());
|
| 351 |
} else {
|
415 |
} else {
|
| 352 |
model.addAttribute("end", offset + limit);
|
416 |
model.addAttribute("end", offset + limit);
|
| 353 |
}
|
417 |
}
|
| Line 366... |
Line 430... |
| 366 |
model.addAttribute("schemes", schemes);
|
430 |
model.addAttribute("schemes", schemes);
|
| 367 |
model.addAttribute("start", offset + 1);
|
431 |
model.addAttribute("start", offset + 1);
|
| 368 |
model.addAttribute("size", size);
|
432 |
model.addAttribute("size", size);
|
| 369 |
model.addAttribute("searchItem", searchItem);
|
433 |
model.addAttribute("searchItem", searchItem);
|
| 370 |
model.addAttribute("searchTerm", searchTerm);
|
434 |
model.addAttribute("searchTerm", searchTerm);
|
| - |
|
435 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 371 |
if (schemes.size() < limit) {
|
436 |
if (schemes.size() < limit) {
|
| 372 |
model.addAttribute("end", offset + schemes.size());
|
437 |
model.addAttribute("end", offset + schemes.size());
|
| 373 |
} else {
|
438 |
} else {
|
| 374 |
model.addAttribute("end", offset + limit);
|
439 |
model.addAttribute("end", offset + limit);
|
| 375 |
}
|
440 |
}
|
| Line 381... |
Line 446... |
| 381 |
public String getSchemeByItemPanigated(HttpServletRequest request,
|
446 |
public String getSchemeByItemPanigated(HttpServletRequest request,
|
| 382 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
447 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 383 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
448 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| 384 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem, Model model)
|
449 |
@RequestParam(name = "searchItem", required = false, defaultValue = "") String searchItem, Model model)
|
| 385 |
throws ProfitMandiBusinessException {
|
450 |
throws ProfitMandiBusinessException {
|
| - |
|
451 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 386 |
LOGGER.info("In search Item....");
|
452 |
LOGGER.info("In search Item....");
|
| 387 |
List<Scheme> schemes = null;
|
453 |
List<Scheme> schemes = null;
|
| 388 |
if (!searchItem.equals("")) {
|
454 |
if (!searchItem.equals("")) {
|
| 389 |
List<Integer> schemeIds = schemeItemRepository.selectSchemeIdByItemId(Integer.parseInt(searchItem));
|
455 |
List<Integer> schemeIds = schemeItemRepository.selectSchemeIdByItemId(Integer.parseInt(searchItem));
|
| 390 |
if (schemeIds != null) {
|
456 |
if (schemeIds != null) {
|
| Line 393... |
Line 459... |
| 393 |
|
459 |
|
| 394 |
}
|
460 |
}
|
| 395 |
}
|
461 |
}
|
| 396 |
model.addAttribute("schemes", schemes);
|
462 |
model.addAttribute("schemes", schemes);
|
| 397 |
model.addAttribute("searchItem", searchItem);
|
463 |
model.addAttribute("searchItem", searchItem);
|
| - |
|
464 |
model.addAttribute("roleType", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 398 |
return "schemes-paginated";
|
465 |
return "schemes-paginated";
|
| 399 |
|
466 |
|
| 400 |
}
|
467 |
}
|
| 401 |
|
468 |
|
| 402 |
}
|
469 |
}
|
| 403 |
|
470 |
|