| 21248 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDateTime;
|
| 21414 |
kshitij.so |
4 |
import java.util.HashMap;
|
| 21277 |
ashik.ali |
5 |
import java.util.Map;
|
| 21414 |
kshitij.so |
6 |
import java.util.Set;
|
| 21248 |
ashik.ali |
7 |
|
|
|
8 |
import javax.servlet.http.HttpServletRequest;
|
|
|
9 |
|
|
|
10 |
import org.slf4j.Logger;
|
|
|
11 |
import org.slf4j.LoggerFactory;
|
| 21278 |
ashik.ali |
12 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 21414 |
kshitij.so |
13 |
import org.springframework.beans.factory.annotation.Value;
|
| 21248 |
ashik.ali |
14 |
import org.springframework.http.HttpStatus;
|
|
|
15 |
import org.springframework.http.ResponseEntity;
|
|
|
16 |
import org.springframework.stereotype.Controller;
|
| 21366 |
kshitij.so |
17 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 21248 |
ashik.ali |
18 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
19 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
20 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
21 |
|
|
|
22 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
|
|
23 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
24 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 21282 |
ashik.ali |
25 |
import com.spice.profitmandi.common.util.JWTUtil;
|
| 21414 |
kshitij.so |
26 |
import com.spice.profitmandi.dao.entity.Role;
|
| 21278 |
ashik.ali |
27 |
import com.spice.profitmandi.dao.entity.User;
|
| 21248 |
ashik.ali |
28 |
import com.spice.profitmandi.dao.repository.UserRepository;
|
|
|
29 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
|
|
30 |
import com.spice.profitmandi.web.model.Response;
|
|
|
31 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
| 21277 |
ashik.ali |
32 |
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
|
| 21366 |
kshitij.so |
33 |
import com.spice.profitmandi.web.req.UserRequest;
|
| 21248 |
ashik.ali |
34 |
|
|
|
35 |
/**
|
|
|
36 |
* @author ashikali
|
|
|
37 |
*
|
|
|
38 |
*/
|
|
|
39 |
@Controller
|
|
|
40 |
public class UserController {
|
| 21414 |
kshitij.so |
41 |
|
| 21248 |
ashik.ali |
42 |
private static final Logger LOGGER=LoggerFactory.getLogger(UserController.class);
|
|
|
43 |
|
| 21414 |
kshitij.so |
44 |
@Value("${admin.token}")
|
|
|
45 |
private String validAdminToken;
|
|
|
46 |
|
| 21278 |
ashik.ali |
47 |
@Autowired
|
|
|
48 |
UserRepository userRepository;
|
| 21414 |
kshitij.so |
49 |
|
| 21278 |
ashik.ali |
50 |
@Autowired
|
|
|
51 |
GoogleLoginProcessor googleLoginProcessor;
|
| 21414 |
kshitij.so |
52 |
|
| 21277 |
ashik.ali |
53 |
@SuppressWarnings("unchecked")
|
|
|
54 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN,method=RequestMethod.POST)
|
|
|
55 |
public ResponseEntity<?> googleLogin(HttpServletRequest request){
|
|
|
56 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
57 |
final Map<String, Object> googleLoginMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
|
|
|
58 |
request.removeAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
|
|
|
59 |
try {
|
|
|
60 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, googleLoginProcessor.process(googleLoginMap));
|
|
|
61 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
62 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
63 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
64 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
65 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
66 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
67 |
}catch (Exception e) {
|
|
|
68 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
69 |
final Response response=new Response("","","", e.getMessage());
|
|
|
70 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
71 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
72 |
}
|
|
|
73 |
}
|
| 21414 |
kshitij.so |
74 |
|
| 21282 |
ashik.ali |
75 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_IS_EXPIRED, method=RequestMethod.GET)
|
|
|
76 |
public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token){
|
|
|
77 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
78 |
try {
|
|
|
79 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, JWTUtil.isExpired(token));
|
|
|
80 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
81 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
82 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
83 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
84 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
85 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
86 |
}catch (Exception e) {
|
|
|
87 |
LOGGER.error("Internal Server Error: ", e);
|
|
|
88 |
final Response response=new Response("","","", e.getMessage());
|
|
|
89 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
90 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
91 |
}
|
|
|
92 |
}
|
| 21414 |
kshitij.so |
93 |
|
| 21278 |
ashik.ali |
94 |
@RequestMapping(value = ProfitMandiConstants.URL_USER, method=RequestMethod.POST)
|
| 21366 |
kshitij.so |
95 |
public ResponseEntity<?> createUser(HttpServletRequest request, @RequestBody UserRequest userRequest){
|
| 21278 |
ashik.ali |
96 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 21368 |
kshitij.so |
97 |
User user = new User();
|
|
|
98 |
user.setFirstName(userRequest.getFirstName());
|
|
|
99 |
user.setLastName(userRequest.getLastName());
|
|
|
100 |
user.setCity(userRequest.getCity());
|
|
|
101 |
user.setPinCode(Integer.valueOf(userRequest.getPinCode()));
|
|
|
102 |
user.setEmailId(userRequest.getEmailId());
|
|
|
103 |
user.setUsername("");
|
|
|
104 |
user.setPassword("");
|
|
|
105 |
user.setMobile_verified(false);
|
|
|
106 |
user.setReferral_url("");
|
|
|
107 |
user.setGroup_id(1);
|
|
|
108 |
user.setStatus(0);
|
|
|
109 |
user.setActivated(false);
|
| 21414 |
kshitij.so |
110 |
|
| 21278 |
ashik.ali |
111 |
try {
|
|
|
112 |
user.setCreateTimestamp(LocalDateTime.now());
|
|
|
113 |
user.setUpdateTimestamp(LocalDateTime.now());
|
|
|
114 |
userRepository.persist(user);
|
| 21282 |
ashik.ali |
115 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("USR_OK_1000"));
|
| 21278 |
ashik.ali |
116 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
117 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
118 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
119 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
120 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
121 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
|
|
122 |
}catch (Exception e) {
|
|
|
123 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
124 |
final Response response=new Response("","","", e.getMessage());
|
|
|
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);
|
|
|
126 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
127 |
}
|
|
|
128 |
}
|
| 21414 |
kshitij.so |
129 |
|
| 21248 |
ashik.ali |
130 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ALL,method=RequestMethod.GET)
|
|
|
131 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
|
|
132 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
133 |
try {
|
|
|
134 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectAll());
|
|
|
135 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
136 |
}catch (Exception e) {
|
|
|
137 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
138 |
final Response response=new Response("","","", e.getMessage());
|
|
|
139 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
140 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
141 |
}
|
|
|
142 |
}
|
| 21414 |
kshitij.so |
143 |
|
| 21248 |
ashik.ali |
144 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ID,method=RequestMethod.GET)
|
| 21404 |
kshitij.so |
145 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
|
| 21248 |
ashik.ali |
146 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
147 |
try {
|
|
|
148 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectById(id));
|
|
|
149 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
150 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
151 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
152 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
153 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
154 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
155 |
}catch (Exception e) {
|
|
|
156 |
LOGGER.error("Internal Server Error: ", e);
|
|
|
157 |
final Response response=new Response("","","", e.getMessage());
|
|
|
158 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
159 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
160 |
}
|
|
|
161 |
}
|
| 21414 |
kshitij.so |
162 |
|
| 21248 |
ashik.ali |
163 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_MOBILE_NUMBER,method=RequestMethod.GET)
|
|
|
164 |
public ResponseEntity<?> getByMobileNumber(HttpServletRequest request, @RequestParam(name = "mobileNumber") String mobileNumber){
|
|
|
165 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
166 |
try {
|
|
|
167 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByMobileNumber(mobileNumber));
|
|
|
168 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
169 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
170 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
171 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
172 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
173 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
174 |
}catch (Exception e) {
|
|
|
175 |
LOGGER.error("Internal Server Error: ", e);
|
|
|
176 |
final Response response=new Response("","","", e.getMessage());
|
|
|
177 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
178 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
179 |
}
|
|
|
180 |
}
|
| 21414 |
kshitij.so |
181 |
|
|
|
182 |
|
| 21248 |
ashik.ali |
183 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_EMAIL_ID,method=RequestMethod.GET)
|
|
|
184 |
public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId){
|
|
|
185 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
186 |
try {
|
|
|
187 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByEmailId(emailId));
|
|
|
188 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
189 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
190 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
191 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
192 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
193 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
194 |
}catch (Exception e) {
|
|
|
195 |
LOGGER.error("Internal Server Error: ", e);
|
|
|
196 |
final Response response=new Response("","","", e.getMessage());
|
|
|
197 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
198 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
199 |
}
|
|
|
200 |
}
|
| 21414 |
kshitij.so |
201 |
|
| 21248 |
ashik.ali |
202 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_ID, method = RequestMethod.PUT)
|
| 21404 |
kshitij.so |
203 |
public ResponseEntity<?> addRoleByIdWithId(HttpServletRequest request, @RequestParam(name = "roleId") int roleId, @RequestParam(name = "userId") int userId){
|
| 21248 |
ashik.ali |
204 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
205 |
try {
|
|
|
206 |
userRepository.addRoleByIdWithId(roleId, userId);
|
|
|
207 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
208 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
209 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
210 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
211 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
212 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
213 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
214 |
}catch (Exception e) {
|
|
|
215 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
216 |
final Response response=new Response("","","", e.getMessage());
|
|
|
217 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
218 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
219 |
}
|
|
|
220 |
}
|
| 21414 |
kshitij.so |
221 |
|
|
|
222 |
|
|
|
223 |
|
| 21248 |
ashik.ali |
224 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_MOBILE_NUMBER, method = RequestMethod.PUT)
|
| 21404 |
kshitij.so |
225 |
public ResponseEntity<?> addRoleByIdWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "mobileNumber") String mobileNumber){
|
| 21248 |
ashik.ali |
226 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
227 |
try {
|
|
|
228 |
userRepository.addRoleByIdWithMobileNumber(id, mobileNumber);
|
|
|
229 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
230 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
231 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
232 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
233 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
234 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
235 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
236 |
}catch (Exception e) {
|
|
|
237 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
238 |
final Response response=new Response("","","", e.getMessage());
|
|
|
239 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
240 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
241 |
}
|
|
|
242 |
}
|
| 21414 |
kshitij.so |
243 |
|
| 21248 |
ashik.ali |
244 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_EMAIL_ID, method = RequestMethod.PUT)
|
| 21404 |
kshitij.so |
245 |
public ResponseEntity<?> addRoleByIdWithEmailId(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "emailId") String emailId){
|
| 21248 |
ashik.ali |
246 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
247 |
try {
|
|
|
248 |
userRepository.addRoleByIdWithEmailId(id, emailId);
|
|
|
249 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
250 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
251 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
252 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
253 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
254 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
255 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
256 |
}catch (Exception e) {
|
|
|
257 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
258 |
final Response response=new Response("","","", e.getMessage());
|
|
|
259 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
260 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
261 |
}
|
|
|
262 |
}
|
| 21414 |
kshitij.so |
263 |
|
| 21248 |
ashik.ali |
264 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_ID, method = RequestMethod.PUT)
|
| 21404 |
kshitij.so |
265 |
public ResponseEntity<?> addRoleByNameWithId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "userId") int id){
|
| 21248 |
ashik.ali |
266 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
267 |
try {
|
|
|
268 |
userRepository.addRoleByNameWithId(roleName, id);
|
|
|
269 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
270 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
271 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
272 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
273 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
274 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
275 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
276 |
}catch (Exception e) {
|
|
|
277 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
278 |
final Response response=new Response("","","", e.getMessage());
|
|
|
279 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
280 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
281 |
}
|
|
|
282 |
}
|
| 21414 |
kshitij.so |
283 |
|
| 21248 |
ashik.ali |
284 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_MOBILE_NUMBER, method = RequestMethod.PUT)
|
|
|
285 |
public ResponseEntity<?> addRoleByNameWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "mobileNumber") String mobileNumber){
|
|
|
286 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
287 |
try {
|
|
|
288 |
userRepository.addRoleByNameWithMobileNumber(roleName, mobileNumber);
|
|
|
289 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
290 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
291 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
292 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
293 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
294 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
295 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
296 |
}catch (Exception e) {
|
|
|
297 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
298 |
final Response response=new Response("","","", e.getMessage());
|
|
|
299 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
300 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
301 |
}
|
|
|
302 |
}
|
| 21414 |
kshitij.so |
303 |
|
|
|
304 |
|
| 21248 |
ashik.ali |
305 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_EMAIL_ID, method = RequestMethod.PUT)
|
|
|
306 |
public ResponseEntity<?> addRoleByNameWithEmailId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "emailId") String emailId){
|
|
|
307 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
308 |
try {
|
|
|
309 |
userRepository.addRoleByNameWithEmailId(roleName, emailId);
|
|
|
310 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
311 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
312 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
313 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
314 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
315 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
316 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
317 |
}catch (Exception e) {
|
|
|
318 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
319 |
final Response response=new Response("","","", e.getMessage());
|
|
|
320 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
321 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
322 |
}
|
|
|
323 |
}
|
| 21414 |
kshitij.so |
324 |
|
| 21248 |
ashik.ali |
325 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_ID, method = RequestMethod.DELETE)
|
| 21404 |
kshitij.so |
326 |
public ResponseEntity<?> removeRoleByIdWithId(HttpServletRequest request, @RequestParam(name = "roleId") int roleId, @RequestParam(name = "userId") int userId){
|
| 21248 |
ashik.ali |
327 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
328 |
try {
|
|
|
329 |
userRepository.deleteRoleByIdWithId(roleId, userId);
|
|
|
330 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
331 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
332 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
333 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
334 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
335 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
336 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
337 |
}catch (Exception e) {
|
|
|
338 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
339 |
final Response response=new Response("","","", e.getMessage());
|
|
|
340 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
341 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
342 |
}
|
|
|
343 |
}
|
| 21414 |
kshitij.so |
344 |
|
|
|
345 |
|
|
|
346 |
|
| 21248 |
ashik.ali |
347 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_MOBILE_NUMBER, method = RequestMethod.DELETE)
|
| 21404 |
kshitij.so |
348 |
public ResponseEntity<?> removeRoleByIdWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "mobileNumber") String mobileNumber){
|
| 21248 |
ashik.ali |
349 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
350 |
try {
|
|
|
351 |
userRepository.deleteRoleByIdWithMobileNumber(id, mobileNumber);
|
|
|
352 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
353 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
354 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
355 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
356 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
357 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
358 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
359 |
}catch (Exception e) {
|
|
|
360 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
361 |
final Response response=new Response("","","", e.getMessage());
|
|
|
362 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
363 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
364 |
}
|
|
|
365 |
}
|
| 21414 |
kshitij.so |
366 |
|
| 21248 |
ashik.ali |
367 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_EMAIL_ID, method = RequestMethod.DELETE)
|
| 21404 |
kshitij.so |
368 |
public ResponseEntity<?> removeRoleByIdWithEmailId(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "emailId") String emailId){
|
| 21248 |
ashik.ali |
369 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
370 |
try {
|
|
|
371 |
userRepository.deleteRoleByIdWithEmailId(id, emailId);
|
|
|
372 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
373 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
374 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
375 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
376 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
377 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
378 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
379 |
}catch (Exception e) {
|
|
|
380 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
381 |
final Response response=new Response("","","", e.getMessage());
|
|
|
382 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
383 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
384 |
}
|
|
|
385 |
}
|
| 21414 |
kshitij.so |
386 |
|
| 21248 |
ashik.ali |
387 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_ID, method = RequestMethod.DELETE)
|
| 21404 |
kshitij.so |
388 |
public ResponseEntity<?> removeRoleByNameWithId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "userId") int id){
|
| 21248 |
ashik.ali |
389 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
390 |
try {
|
|
|
391 |
userRepository.deleteRoleByNameWithId(roleName, id);
|
|
|
392 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
393 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
394 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
395 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
396 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
397 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
398 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
399 |
}catch (Exception e) {
|
|
|
400 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
401 |
final Response response=new Response("","","", e.getMessage());
|
|
|
402 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
403 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
404 |
}
|
|
|
405 |
}
|
| 21414 |
kshitij.so |
406 |
|
| 21248 |
ashik.ali |
407 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_MOBILE_NUMBER, method = RequestMethod.DELETE)
|
|
|
408 |
public ResponseEntity<?> removeRoleByNameWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "mobileNumber") String mobileNumber){
|
|
|
409 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
410 |
try {
|
|
|
411 |
userRepository.deleteRoleByNameWithMobileNumber(roleName, mobileNumber);
|
|
|
412 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
413 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
414 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
415 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
416 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
417 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
418 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
419 |
}catch (Exception e) {
|
|
|
420 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
421 |
final Response response=new Response("","","", e.getMessage());
|
|
|
422 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
423 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
424 |
}
|
|
|
425 |
}
|
| 21414 |
kshitij.so |
426 |
|
|
|
427 |
|
| 21248 |
ashik.ali |
428 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_EMAIL_ID, method = RequestMethod.DELETE)
|
|
|
429 |
public ResponseEntity<?> removeRoleByNameWithEmailId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "emailId") String emailId){
|
|
|
430 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
431 |
try {
|
|
|
432 |
userRepository.deleteRoleByNameWithEmailId(roleName, emailId);
|
|
|
433 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
434 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
435 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
436 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
437 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
438 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
439 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
440 |
}catch (Exception e) {
|
|
|
441 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
442 |
final Response response=new Response("","","", e.getMessage());
|
|
|
443 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
444 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
445 |
}
|
|
|
446 |
}
|
| 21414 |
kshitij.so |
447 |
|
|
|
448 |
@RequestMapping(value = ProfitMandiConstants.URL_ADMIN_TOKEN, method = RequestMethod.POST)
|
|
|
449 |
public ResponseEntity<?> getAdminToken(HttpServletRequest request, @RequestParam(name = "adminToken") String adminToken, @RequestParam(name = "emailId") String emailId){
|
|
|
450 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
451 |
if (!adminToken.equals(validAdminToken)){
|
|
|
452 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.FORBIDDEN.toString(), HttpStatus.FORBIDDEN, ResponseStatus.FAILURE, null);
|
|
|
453 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.FORBIDDEN);
|
|
|
454 |
}
|
|
|
455 |
|
|
|
456 |
|
|
|
457 |
Map<String, Object> responseMap = new HashMap<>(2);
|
|
|
458 |
try{
|
|
|
459 |
User user = userRepository.selectByEmailId(emailId);
|
|
|
460 |
Set<Role> roles = user.getRoles();
|
|
|
461 |
String[] roleTypes = new String[roles.size()];
|
|
|
462 |
int index = 0;
|
|
|
463 |
for(Role role : roles){
|
|
|
464 |
roleTypes[index++] = role.getType().toString();
|
|
|
465 |
}
|
|
|
466 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(user.getId(), roleTypes));
|
|
|
467 |
responseMap.put(ProfitMandiConstants.REGISTERED, true);
|
|
|
468 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
469 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create());
|
|
|
470 |
responseMap.put(ProfitMandiConstants.REGISTERED, false);
|
|
|
471 |
}
|
|
|
472 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, responseMap);
|
|
|
473 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
474 |
}
|
| 21248 |
ashik.ali |
475 |
}
|