| 21248 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDateTime;
|
| 21277 |
ashik.ali |
4 |
import java.util.Map;
|
| 21248 |
ashik.ali |
5 |
|
|
|
6 |
import javax.servlet.http.HttpServletRequest;
|
|
|
7 |
|
|
|
8 |
import org.slf4j.Logger;
|
|
|
9 |
import org.slf4j.LoggerFactory;
|
| 21278 |
ashik.ali |
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 21248 |
ashik.ali |
11 |
import org.springframework.http.HttpStatus;
|
|
|
12 |
import org.springframework.http.ResponseEntity;
|
|
|
13 |
import org.springframework.stereotype.Controller;
|
|
|
14 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
15 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
16 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
17 |
|
|
|
18 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
|
|
19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 21278 |
ashik.ali |
21 |
import com.spice.profitmandi.dao.entity.User;
|
| 21248 |
ashik.ali |
22 |
import com.spice.profitmandi.dao.repository.UserRepository;
|
|
|
23 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
|
|
24 |
import com.spice.profitmandi.web.model.Response;
|
|
|
25 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
| 21277 |
ashik.ali |
26 |
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
|
| 21248 |
ashik.ali |
27 |
|
|
|
28 |
/**
|
|
|
29 |
* @author ashikali
|
|
|
30 |
*
|
|
|
31 |
*/
|
|
|
32 |
@Controller
|
|
|
33 |
public class UserController {
|
|
|
34 |
|
|
|
35 |
private static final Logger LOGGER=LoggerFactory.getLogger(UserController.class);
|
|
|
36 |
|
| 21278 |
ashik.ali |
37 |
@Autowired
|
|
|
38 |
UserRepository userRepository;
|
| 21248 |
ashik.ali |
39 |
|
| 21278 |
ashik.ali |
40 |
@Autowired
|
|
|
41 |
GoogleLoginProcessor googleLoginProcessor;
|
|
|
42 |
|
| 21277 |
ashik.ali |
43 |
@SuppressWarnings("unchecked")
|
|
|
44 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN,method=RequestMethod.POST)
|
|
|
45 |
public ResponseEntity<?> googleLogin(HttpServletRequest request){
|
|
|
46 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
47 |
final Map<String, Object> googleLoginMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
|
|
|
48 |
request.removeAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
|
|
|
49 |
try {
|
|
|
50 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, googleLoginProcessor.process(googleLoginMap));
|
|
|
51 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
52 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
53 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
54 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
55 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
56 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
57 |
}catch (Exception e) {
|
|
|
58 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
59 |
final Response response=new Response("","","", e.getMessage());
|
|
|
60 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
61 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
|
| 21278 |
ashik.ali |
65 |
@RequestMapping(value = ProfitMandiConstants.URL_USER, method=RequestMethod.POST)
|
|
|
66 |
public ResponseEntity<?> createUser(HttpServletRequest request){
|
|
|
67 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
68 |
final User user = (User)request.getAttribute(ProfitMandiConstants.USER);
|
|
|
69 |
request.removeAttribute(ProfitMandiConstants.USER);
|
|
|
70 |
try {
|
|
|
71 |
user.setCreateTimestamp(LocalDateTime.now());
|
|
|
72 |
user.setUpdateTimestamp(LocalDateTime.now());
|
|
|
73 |
userRepository.persist(user);
|
|
|
74 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1000"));
|
|
|
75 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
76 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
77 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
78 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
79 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
80 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
|
|
81 |
}catch (Exception e) {
|
|
|
82 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
83 |
final Response response=new Response("","","", e.getMessage());
|
|
|
84 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
85 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
86 |
}
|
|
|
87 |
}
|
|
|
88 |
|
| 21248 |
ashik.ali |
89 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ALL,method=RequestMethod.GET)
|
|
|
90 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
|
|
91 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
92 |
try {
|
|
|
93 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectAll());
|
|
|
94 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
95 |
}catch (Exception e) {
|
|
|
96 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
97 |
final Response response=new Response("","","", e.getMessage());
|
|
|
98 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
99 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
100 |
}
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ID,method=RequestMethod.GET)
|
|
|
104 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
|
|
|
105 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
106 |
try {
|
|
|
107 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectById(id));
|
|
|
108 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
109 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
110 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
111 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
112 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
113 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
114 |
}catch (Exception e) {
|
|
|
115 |
LOGGER.error("Internal Server Error: ", e);
|
|
|
116 |
final Response response=new Response("","","", e.getMessage());
|
|
|
117 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
118 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
119 |
}
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_MOBILE_NUMBER,method=RequestMethod.GET)
|
|
|
123 |
public ResponseEntity<?> getByMobileNumber(HttpServletRequest request, @RequestParam(name = "mobileNumber") String mobileNumber){
|
|
|
124 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
125 |
try {
|
|
|
126 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByMobileNumber(mobileNumber));
|
|
|
127 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
128 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
129 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
130 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
131 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
132 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
133 |
}catch (Exception e) {
|
|
|
134 |
LOGGER.error("Internal Server Error: ", e);
|
|
|
135 |
final Response response=new Response("","","", e.getMessage());
|
|
|
136 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
137 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
138 |
}
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_EMAIL_ID,method=RequestMethod.GET)
|
|
|
143 |
public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId){
|
|
|
144 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
145 |
try {
|
|
|
146 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByEmailId(emailId));
|
|
|
147 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
148 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
149 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
150 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
151 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
152 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
153 |
}catch (Exception e) {
|
|
|
154 |
LOGGER.error("Internal Server Error: ", e);
|
|
|
155 |
final Response response=new Response("","","", e.getMessage());
|
|
|
156 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
157 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
158 |
}
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_ID, method = RequestMethod.PUT)
|
|
|
162 |
public ResponseEntity<?> addRoleByIdWithId(HttpServletRequest request, @RequestParam(name = "roleId") long roleId, @RequestParam(name = "userId") long userId){
|
|
|
163 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
164 |
try {
|
|
|
165 |
userRepository.addRoleByIdWithId(roleId, userId);
|
|
|
166 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
167 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
168 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
169 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
170 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
171 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
172 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
173 |
}catch (Exception e) {
|
|
|
174 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
175 |
final Response response=new Response("","","", e.getMessage());
|
|
|
176 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
177 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
178 |
}
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_MOBILE_NUMBER, method = RequestMethod.PUT)
|
|
|
184 |
public ResponseEntity<?> addRoleByIdWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleId") long id, @RequestParam(name = "mobileNumber") String mobileNumber){
|
|
|
185 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
186 |
try {
|
|
|
187 |
userRepository.addRoleByIdWithMobileNumber(id, mobileNumber);
|
|
|
188 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
189 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
190 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
191 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
192 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
193 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
194 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
195 |
}catch (Exception e) {
|
|
|
196 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
197 |
final Response response=new Response("","","", e.getMessage());
|
|
|
198 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
199 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
200 |
}
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_EMAIL_ID, method = RequestMethod.PUT)
|
|
|
204 |
public ResponseEntity<?> addRoleByIdWithEmailId(HttpServletRequest request, @RequestParam(name = "roleId") long id, @RequestParam(name = "emailId") String emailId){
|
|
|
205 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
206 |
try {
|
|
|
207 |
userRepository.addRoleByIdWithEmailId(id, emailId);
|
|
|
208 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
209 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
210 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
211 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
212 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
213 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
214 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
215 |
}catch (Exception e) {
|
|
|
216 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
217 |
final Response response=new Response("","","", e.getMessage());
|
|
|
218 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
219 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
220 |
}
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_ID, method = RequestMethod.PUT)
|
|
|
224 |
public ResponseEntity<?> addRoleByNameWithId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "userId") long id){
|
|
|
225 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
226 |
try {
|
|
|
227 |
userRepository.addRoleByNameWithId(roleName, id);
|
|
|
228 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
229 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
230 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
231 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
232 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
233 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
234 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
235 |
}catch (Exception e) {
|
|
|
236 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
237 |
final Response response=new Response("","","", e.getMessage());
|
|
|
238 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
239 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
240 |
}
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_MOBILE_NUMBER, method = RequestMethod.PUT)
|
|
|
244 |
public ResponseEntity<?> addRoleByNameWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "mobileNumber") String mobileNumber){
|
|
|
245 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
246 |
try {
|
|
|
247 |
userRepository.addRoleByNameWithMobileNumber(roleName, mobileNumber);
|
|
|
248 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
249 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
250 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
251 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
252 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
253 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
254 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
255 |
}catch (Exception e) {
|
|
|
256 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
257 |
final Response response=new Response("","","", e.getMessage());
|
|
|
258 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
259 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
260 |
}
|
|
|
261 |
}
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_EMAIL_ID, method = RequestMethod.PUT)
|
|
|
265 |
public ResponseEntity<?> addRoleByNameWithEmailId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "emailId") String emailId){
|
|
|
266 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
267 |
try {
|
|
|
268 |
userRepository.addRoleByNameWithEmailId(roleName, emailId);
|
|
|
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 |
}
|
|
|
283 |
|
|
|
284 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_ID, method = RequestMethod.DELETE)
|
|
|
285 |
public ResponseEntity<?> removeRoleByIdWithId(HttpServletRequest request, @RequestParam(name = "roleId") long roleId, @RequestParam(name = "userId") long userId){
|
|
|
286 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
287 |
try {
|
|
|
288 |
userRepository.deleteRoleByIdWithId(roleId, userId);
|
|
|
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 |
}
|
|
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_MOBILE_NUMBER, method = RequestMethod.DELETE)
|
|
|
307 |
public ResponseEntity<?> removeRoleByIdWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleId") long id, @RequestParam(name = "mobileNumber") String mobileNumber){
|
|
|
308 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
309 |
try {
|
|
|
310 |
userRepository.deleteRoleByIdWithMobileNumber(id, mobileNumber);
|
|
|
311 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
312 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
313 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
314 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
315 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
316 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
317 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
318 |
}catch (Exception e) {
|
|
|
319 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
320 |
final Response response=new Response("","","", e.getMessage());
|
|
|
321 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
322 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
323 |
}
|
|
|
324 |
}
|
|
|
325 |
|
|
|
326 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_EMAIL_ID, method = RequestMethod.DELETE)
|
|
|
327 |
public ResponseEntity<?> removeRoleByIdWithEmailId(HttpServletRequest request, @RequestParam(name = "roleId") long id, @RequestParam(name = "emailId") String emailId){
|
|
|
328 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
329 |
try {
|
|
|
330 |
userRepository.deleteRoleByIdWithEmailId(id, emailId);
|
|
|
331 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
332 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
333 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
334 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
335 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
336 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
337 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
338 |
}catch (Exception e) {
|
|
|
339 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
340 |
final Response response=new Response("","","", e.getMessage());
|
|
|
341 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
342 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
343 |
}
|
|
|
344 |
}
|
|
|
345 |
|
|
|
346 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_ID, method = RequestMethod.DELETE)
|
|
|
347 |
public ResponseEntity<?> removeRoleByNameWithId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "userId") long id){
|
|
|
348 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
349 |
try {
|
|
|
350 |
userRepository.deleteRoleByNameWithId(roleName, id);
|
|
|
351 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
352 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
353 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
354 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
355 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
356 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
357 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
358 |
}catch (Exception e) {
|
|
|
359 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
360 |
final Response response=new Response("","","", e.getMessage());
|
|
|
361 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
362 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
363 |
}
|
|
|
364 |
}
|
|
|
365 |
|
|
|
366 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_MOBILE_NUMBER, method = RequestMethod.DELETE)
|
|
|
367 |
public ResponseEntity<?> removeRoleByNameWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "mobileNumber") String mobileNumber){
|
|
|
368 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
369 |
try {
|
|
|
370 |
userRepository.deleteRoleByNameWithMobileNumber(roleName, mobileNumber);
|
|
|
371 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
|
|
372 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
|
|
373 |
}catch (ProfitMandiBusinessException pmbe) {
|
|
|
374 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
|
|
375 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
|
|
376 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
|
|
377 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
|
|
378 |
}catch (Exception e) {
|
|
|
379 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
380 |
final Response response=new Response("","","", e.getMessage());
|
|
|
381 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
382 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
383 |
}
|
|
|
384 |
}
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_EMAIL_ID, method = RequestMethod.DELETE)
|
|
|
388 |
public ResponseEntity<?> removeRoleByNameWithEmailId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "emailId") String emailId){
|
|
|
389 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
390 |
try {
|
|
|
391 |
userRepository.deleteRoleByNameWithEmailId(roleName, emailId);
|
|
|
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 |
}
|
|
|
406 |
}
|