| Line 30... |
Line 30... |
| 30 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
30 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 31 |
import com.spice.profitmandi.common.model.SchemeModel;
|
31 |
import com.spice.profitmandi.common.model.SchemeModel;
|
| 32 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
32 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 33 |
import com.spice.profitmandi.common.util.StringUtils;
|
33 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 34 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
34 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| - |
|
35 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 35 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
36 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 36 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
37 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 37 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
38 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 38 |
import com.spice.profitmandi.web.model.LoginDetails;
|
39 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 39 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
40 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| Line 93... |
Line 94... |
| 93 |
return "schemes";
|
94 |
return "schemes";
|
| 94 |
|
95 |
|
| 95 |
}
|
96 |
}
|
| 96 |
|
97 |
|
| 97 |
@RequestMapping(value = "/getSchemes", method = RequestMethod.GET)
|
98 |
@RequestMapping(value = "/getSchemes", method = RequestMethod.GET)
|
| 98 |
public String getSchemes(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model){
|
99 |
public String getSchemes(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
| - |
|
100 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
101 |
List<Scheme> schemes = null;
|
| - |
|
102 |
long size = 0;
|
| - |
|
103 |
if(loginDetails.getRoleTypes().contains(RoleType.FOFO_ADMIN)){
|
| 99 |
List<Scheme> schemes = schemeRepository.selectAll(offset, limit);
|
104 |
schemes = schemeRepository.selectAll(offset, limit);
|
| 100 |
long size = schemeRepository.selectAllCount();
|
105 |
size = schemeRepository.selectAllCount();
|
| - |
|
106 |
}else{
|
| - |
|
107 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
| - |
|
108 |
size = schemeRepository.selectAllActiveCount();
|
| - |
|
109 |
}
|
| 101 |
model.addAttribute("schemes", schemes);
|
110 |
model.addAttribute("schemes", schemes);
|
| 102 |
model.addAttribute("start", offset + 1);
|
111 |
model.addAttribute("start", offset + 1);
|
| 103 |
model.addAttribute("size", size);
|
112 |
model.addAttribute("size", size);
|
| 104 |
if (schemes.size() < limit){
|
113 |
if (schemes.size() < limit){
|
| 105 |
model.addAttribute("end", offset + schemes.size());
|
114 |
model.addAttribute("end", offset + schemes.size());
|
| 106 |
}
|
115 |
}
|
| 107 |
else{
|
116 |
else{
|
| 108 |
model.addAttribute("end", offset + limit);
|
117 |
model.addAttribute("end", offset + limit);
|
| 109 |
}
|
118 |
}
|
| - |
|
119 |
//model.addAttribute("roleTypes", loginDetails.getRoleTypes());
|
| 110 |
return "schemes";
|
120 |
return "schemes";
|
| 111 |
}
|
121 |
}
|
| 112 |
|
122 |
|
| 113 |
@RequestMapping(value = "/getPaginatedSchemes", method = RequestMethod.GET)
|
123 |
@RequestMapping(value = "/getPaginatedSchemes", method = RequestMethod.GET)
|
| 114 |
public String getPaginatedSchemes(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model){
|
124 |
public String getPaginatedSchemes(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
| - |
|
125 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 115 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
126 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
| - |
|
127 |
List<Scheme> schemes = null;
|
| - |
|
128 |
if(loginDetails.getRoleTypes().contains(RoleType.FOFO_ADMIN)){
|
| 116 |
List<Scheme> schemes = schemeRepository.selectAll(offset, limit);
|
129 |
schemes = schemeRepository.selectAll(offset, limit);
|
| - |
|
130 |
}else{
|
| - |
|
131 |
schemes = schemeRepository.selectActiveAll(offset, limit);
|
| - |
|
132 |
}
|
| 117 |
model.addAttribute("schemes", schemes);
|
133 |
model.addAttribute("schemes", schemes);
|
| - |
|
134 |
model.addAttribute("roleTypes", loginDetails.getRoleTypes());
|
| 118 |
return "schemes-paginated";
|
135 |
return "schemes-paginated";
|
| 119 |
}
|
136 |
}
|
| 120 |
|
137 |
|
| 121 |
@RequestMapping(value = "/schemes/downloadPage", method = RequestMethod.GET)
|
138 |
@RequestMapping(value = "/schemes/downloadPage", method = RequestMethod.GET)
|
| 122 |
public String downloadPage(HttpServletRequest request, Model model){
|
139 |
public String downloadPage(HttpServletRequest request, Model model){
|
| Line 144... |
Line 161... |
| 144 |
//return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
161 |
//return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 145 |
}
|
162 |
}
|
| 146 |
|
163 |
|
| 147 |
@RequestMapping(value = "/getSchemeById", method = RequestMethod.GET)
|
164 |
@RequestMapping(value = "/getSchemeById", method = RequestMethod.GET)
|
| 148 |
public String getSchemeById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, Model model) throws ProfitMandiBusinessException{
|
165 |
public String getSchemeById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, Model model) throws ProfitMandiBusinessException{
|
| - |
|
166 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 149 |
Scheme scheme = schemeService.getSchemeById(schemeId);
|
167 |
Scheme scheme = schemeService.getSchemeById(schemeId);
|
| 150 |
model.addAttribute("scheme", scheme);
|
168 |
model.addAttribute("scheme", scheme);
|
| - |
|
169 |
model.addAttribute("roleTypes", loginDetails.getRoleTypes());
|
| 151 |
return "scheme-details";
|
170 |
return "scheme-details";
|
| 152 |
}
|
171 |
}
|
| 153 |
|
172 |
|
| 154 |
@RequestMapping(value = "/activeSchemeById", method = RequestMethod.PUT)
|
173 |
@RequestMapping(value = "/activeSchemeById", method = RequestMethod.PUT)
|
| 155 |
public String activeSchemeById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
174 |
public String activeSchemeById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SCHEME_ID) int schemeId, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|