| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| 4 |
import java.util.HashMap;
|
- |
|
| 5 |
import java.util.Map;
|
4 |
import java.util.Map;
|
| 6 |
import java.util.Set;
|
- |
|
| 7 |
|
5 |
|
| 8 |
import javax.servlet.http.HttpServletRequest;
|
6 |
import javax.servlet.http.HttpServletRequest;
|
| 9 |
|
7 |
|
| 10 |
import org.slf4j.Logger;
|
8 |
import org.slf4j.Logger;
|
| 11 |
import org.slf4j.LoggerFactory;
|
9 |
import org.slf4j.LoggerFactory;
|
| Line 21... |
Line 19... |
| 21 |
|
19 |
|
| 22 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
20 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
| 23 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
21 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
22 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 25 |
import com.spice.profitmandi.common.util.JWTUtil;
|
23 |
import com.spice.profitmandi.common.util.JWTUtil;
|
| - |
|
24 |
import com.spice.profitmandi.dao.entity.Permission;
|
| 26 |
import com.spice.profitmandi.dao.entity.Role;
|
25 |
import com.spice.profitmandi.dao.entity.Role;
|
| 27 |
import com.spice.profitmandi.dao.entity.User;
|
26 |
import com.spice.profitmandi.dao.entity.User;
|
| - |
|
27 |
import com.spice.profitmandi.dao.entity.UserRole;
|
| - |
|
28 |
import com.spice.profitmandi.dao.repository.PermissionRepository;
|
| - |
|
29 |
import com.spice.profitmandi.dao.repository.RoleRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.UserRepository;
|
30 |
import com.spice.profitmandi.dao.repository.UserRepository;
|
| - |
|
31 |
import com.spice.profitmandi.dao.repository.UserRoleRepository;
|
| 29 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
32 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
| 30 |
import com.spice.profitmandi.web.model.Response;
|
33 |
import com.spice.profitmandi.web.model.Response;
|
| 31 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
34 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
| 32 |
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
|
35 |
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
|
| - |
|
36 |
import com.spice.profitmandi.web.req.UserAddRoleRequest;
|
| 33 |
import com.spice.profitmandi.web.req.UserRequest;
|
37 |
import com.spice.profitmandi.web.req.UserRequest;
|
| 34 |
|
38 |
|
| 35 |
/**
|
39 |
/**
|
| 36 |
* @author ashikali
|
40 |
* @author ashikali
|
| 37 |
*
|
41 |
*
|
| 38 |
*/
|
42 |
*/
|
| 39 |
@Controller
|
43 |
@Controller
|
| 40 |
public class UserController {
|
44 |
public class UserController {
|
| 41 |
|
45 |
|
| 42 |
private static final Logger LOGGER=LoggerFactory.getLogger(UserController.class);
|
46 |
private static final Logger LOGGER=LoggerFactory.getLogger(UserController.class);
|
| 43 |
|
47 |
|
| 44 |
@Value("${admin.token}")
|
48 |
@Value("${admin.token}")
|
| 45 |
private String validAdminToken;
|
49 |
private String validAdminToken;
|
| 46 |
|
50 |
|
| 47 |
@Autowired
|
51 |
@Autowired
|
| 48 |
UserRepository userRepository;
|
52 |
UserRepository userRepository;
|
| - |
|
53 |
|
| - |
|
54 |
@Autowired
|
| - |
|
55 |
RoleRepository roleRepository;
|
| 49 |
|
56 |
|
| - |
|
57 |
@Autowired
|
| - |
|
58 |
UserRoleRepository userRoleRepository;
|
| - |
|
59 |
|
| - |
|
60 |
@Autowired
|
| - |
|
61 |
PermissionRepository permissionRepository;
|
| - |
|
62 |
|
| 50 |
@Autowired
|
63 |
@Autowired
|
| 51 |
GoogleLoginProcessor googleLoginProcessor;
|
64 |
GoogleLoginProcessor googleLoginProcessor;
|
| 52 |
|
65 |
|
| 53 |
@SuppressWarnings("unchecked")
|
66 |
@SuppressWarnings("unchecked")
|
| 54 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN,method=RequestMethod.POST)
|
67 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN,method=RequestMethod.POST)
|
| 55 |
public ResponseEntity<?> googleLogin(HttpServletRequest request){
|
68 |
public ResponseEntity<?> googleLogin(HttpServletRequest request){
|
| 56 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
69 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 57 |
final Map<String, Object> googleLoginMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
|
70 |
final Map<String, Object> googleLoginMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
|
| Line 62... |
Line 75... |
| 62 |
}catch (ProfitMandiBusinessException pmbe) {
|
75 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 63 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
76 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 64 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
77 |
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);
|
78 |
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);
|
79 |
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 |
}
|
80 |
}
|
| 73 |
}
|
81 |
}
|
| 74 |
|
82 |
|
| 75 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_IS_EXPIRED, method=RequestMethod.GET)
|
83 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_IS_EXPIRED, method=RequestMethod.GET)
|
| 76 |
public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token){
|
84 |
public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token){
|
| 77 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
85 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 78 |
try {
|
86 |
try {
|
| 79 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, JWTUtil.isExpired(token));
|
87 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, JWTUtil.isExpired(token));
|
| Line 81... |
Line 89... |
| 81 |
}catch (ProfitMandiBusinessException pmbe) {
|
89 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 82 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
90 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 83 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
91 |
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);
|
92 |
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);
|
93 |
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 |
}
|
94 |
}
|
| 92 |
}
|
95 |
}
|
| - |
|
96 |
|
| 93 |
|
97 |
|
| 94 |
@RequestMapping(value = ProfitMandiConstants.URL_USER, method=RequestMethod.POST)
|
98 |
@RequestMapping(value = ProfitMandiConstants.URL_USER, method=RequestMethod.POST)
|
| 95 |
public ResponseEntity<?> createUser(HttpServletRequest request, @RequestBody UserRequest userRequest){
|
99 |
public ResponseEntity<?> createUser(HttpServletRequest request, @RequestBody UserRequest userRequest){
|
| 96 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
100 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 97 |
User user = new User();
|
101 |
User user = new User();
|
| 98 |
user.setFirstName(userRequest.getFirstName());
|
102 |
user.setFirstName(userRequest.getFirstName());
|
| Line 117... |
Line 121... |
| 117 |
}catch (ProfitMandiBusinessException pmbe) {
|
121 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 118 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
122 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 119 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
123 |
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);
|
124 |
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);
|
125 |
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 |
}
|
126 |
}
|
| 128 |
}
|
127 |
}
|
| 129 |
|
128 |
|
| 130 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ALL,method=RequestMethod.GET)
|
129 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ALL,method=RequestMethod.GET)
|
| 131 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
130 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
| 132 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
131 |
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());
|
132 |
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);
|
133 |
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 |
}
|
134 |
}
|
| 143 |
|
135 |
|
| 144 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ID,method=RequestMethod.GET)
|
136 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ID,method=RequestMethod.GET)
|
| 145 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
|
137 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| 146 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
138 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 147 |
try {
|
139 |
try {
|
| 148 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectById(id));
|
140 |
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);
|
141 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 150 |
}catch (ProfitMandiBusinessException pmbe) {
|
142 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 151 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
143 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 152 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
144 |
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);
|
145 |
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);
|
146 |
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 |
}
|
147 |
}
|
| 161 |
}
|
148 |
}
|
| 162 |
|
149 |
|
| 163 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_MOBILE_NUMBER,method=RequestMethod.GET)
|
150 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_MOBILE_NUMBER,method=RequestMethod.GET)
|
| 164 |
public ResponseEntity<?> getByMobileNumber(HttpServletRequest request, @RequestParam(name = "mobileNumber") String mobileNumber){
|
151 |
public ResponseEntity<?> getByMobileNumber(HttpServletRequest request, @RequestParam(name = "mobileNumber") String mobileNumber){
|
| 165 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
152 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 166 |
try {
|
153 |
try {
|
| 167 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByMobileNumber(mobileNumber));
|
154 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByMobileNumber(mobileNumber));
|
| Line 169... |
Line 156... |
| 169 |
}catch (ProfitMandiBusinessException pmbe) {
|
156 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 170 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
157 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 171 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
158 |
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);
|
159 |
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);
|
160 |
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 |
}
|
161 |
}
|
| 180 |
}
|
162 |
}
|
| 181 |
|
163 |
|
| - |
|
164 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_IS_EXIST_MOBILE_NUMBER, method = RequestMethod.GET)
|
| - |
|
165 |
public ResponseEntity<?> isMobileNumberExist(HttpServletRequest request, @RequestParam(name = "mobileNumber") String mobileNumber){
|
| - |
|
166 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
167 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.isExistByMobileNumber(mobileNumber));
|
| - |
|
168 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
169 |
}
|
| - |
|
170 |
|
| 182 |
|
171 |
|
| 183 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_EMAIL_ID,method=RequestMethod.GET)
|
172 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_EMAIL_ID,method=RequestMethod.GET)
|
| 184 |
public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId){
|
173 |
public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId){
|
| 185 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
174 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 186 |
try {
|
175 |
try {
|
| 187 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByEmailId(emailId));
|
176 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByEmailId(emailId));
|
| Line 189... |
Line 178... |
| 189 |
}catch (ProfitMandiBusinessException pmbe) {
|
178 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 190 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
179 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 191 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
180 |
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);
|
181 |
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);
|
182 |
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 |
}
|
- |
|
| 201 |
|
- |
|
| 202 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_ID, method = RequestMethod.PUT)
|
- |
|
| 203 |
public ResponseEntity<?> addRoleByIdWithId(HttpServletRequest request, @RequestParam(name = "roleId") int roleId, @RequestParam(name = "userId") int userId){
|
- |
|
| 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 |
}
|
- |
|
| 221 |
|
- |
|
| 222 |
|
- |
|
| 223 |
|
- |
|
| 224 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_MOBILE_NUMBER, method = RequestMethod.PUT)
|
- |
|
| 225 |
public ResponseEntity<?> addRoleByIdWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "mobileNumber") String mobileNumber){
|
- |
|
| 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 |
}
|
- |
|
| 243 |
|
- |
|
| 244 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_EMAIL_ID, method = RequestMethod.PUT)
|
- |
|
| 245 |
public ResponseEntity<?> addRoleByIdWithEmailId(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "emailId") String emailId){
|
- |
|
| 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 |
}
|
- |
|
| 263 |
|
- |
|
| 264 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_ID, method = RequestMethod.PUT)
|
- |
|
| 265 |
public ResponseEntity<?> addRoleByNameWithId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "userId") int id){
|
- |
|
| 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 |
}
|
- |
|
| 283 |
|
- |
|
| 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 |
}
|
- |
|
| 303 |
|
- |
|
| 304 |
|
- |
|
| 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 |
}
|
- |
|
| 324 |
|
- |
|
| 325 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_ID, method = RequestMethod.DELETE)
|
- |
|
| 326 |
public ResponseEntity<?> removeRoleByIdWithId(HttpServletRequest request, @RequestParam(name = "roleId") int roleId, @RequestParam(name = "userId") int userId){
|
- |
|
| 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 |
}
|
183 |
}
|
| 343 |
}
|
184 |
}
|
| 344 |
|
- |
|
| 345 |
|
- |
|
| 346 |
|
- |
|
| 347 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_MOBILE_NUMBER, method = RequestMethod.DELETE)
|
- |
|
| 348 |
public ResponseEntity<?> removeRoleByIdWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "mobileNumber") String mobileNumber){
|
- |
|
| 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);
|
185 |
|
| 363 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 364 |
}
|
- |
|
| 365 |
}
|
- |
|
| 366 |
|
- |
|
| 367 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_EMAIL_ID, method = RequestMethod.DELETE)
|
186 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_ADD, method=RequestMethod.POST)
|
| 368 |
public ResponseEntity<?> removeRoleByIdWithEmailId(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "emailId") String emailId){
|
- |
|
| 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);
|
187 |
public ResponseEntity<?> addRole(HttpServletRequest request, @RequestBody UserAddRoleRequest userAddRoleRequest){
|
| 383 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 384 |
}
|
- |
|
| 385 |
}
|
- |
|
| 386 |
|
- |
|
| 387 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_ID, method = RequestMethod.DELETE)
|
- |
|
| 388 |
public ResponseEntity<?> removeRoleByNameWithId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "userId") int id){
|
- |
|
| 389 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
188 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 390 |
try {
|
189 |
try {
|
| - |
|
190 |
User user = userRepository.selectById(userAddRoleRequest.getUserId());
|
| - |
|
191 |
|
| - |
|
192 |
Role role = null;
|
| - |
|
193 |
try{
|
| - |
|
194 |
role = roleRepository.selectByNameAndType(userAddRoleRequest.getRole().getName(), userAddRoleRequest.getRole().getType());
|
| - |
|
195 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| - |
|
196 |
role = new Role();
|
| - |
|
197 |
role.setName(userAddRoleRequest.getRole().getName());
|
| - |
|
198 |
role.setType(userAddRoleRequest.getRole().getType());
|
| - |
|
199 |
roleRepository.persist(role);
|
| - |
|
200 |
}
|
| - |
|
201 |
Permission permission = new Permission();
|
| - |
|
202 |
permission.setType(userAddRoleRequest.getRole().getPermissionType());
|
| - |
|
203 |
permission.setRoleId(role.getId());
|
| - |
|
204 |
permissionRepository.persist(permission);
|
| - |
|
205 |
UserRole userRole = new UserRole();
|
| 391 |
userRepository.deleteRoleByNameWithId(roleName, id);
|
206 |
userRole.setRoleId(role.getId());
|
| - |
|
207 |
userRole.setUserId(user.getId());
|
| - |
|
208 |
userRoleRepository.persist(userRole);
|
| - |
|
209 |
//role.setPermissionType(userAddRoleRequest.getRole().getPermissionType());
|
| 392 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
210 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, "");
|
| 393 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
211 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 394 |
}catch (ProfitMandiBusinessException pmbe) {
|
212 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 395 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
213 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 396 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
214 |
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);
|
215 |
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);
|
216 |
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 |
}
|
217 |
}
|
| 405 |
}
|
218 |
}
|
| 406 |
|
219 |
|
| 407 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_MOBILE_NUMBER, method = RequestMethod.DELETE)
|
220 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_REMOVE,method=RequestMethod.DELETE)
|
| 408 |
public ResponseEntity<?> removeRoleByNameWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "mobileNumber") String mobileNumber){
|
221 |
public ResponseEntity<?> removeRole(HttpServletRequest request, @RequestParam(name = "roleId") long roleId, @RequestParam(name = "userId") long userId){
|
| 409 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
222 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 410 |
try {
|
223 |
try {
|
| - |
|
224 |
roleRepository.selectById(roleId);
|
| - |
|
225 |
userRepository.selectById(userId);
|
| 411 |
userRepository.deleteRoleByNameWithMobileNumber(roleName, mobileNumber);
|
226 |
userRoleRepository.deleteByUserAndRoleId(userId, roleId);
|
| - |
|
227 |
permissionRepository.deleteByRoleId(roleId);
|
| 412 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
228 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, "");
|
| 413 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
229 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 414 |
}catch (ProfitMandiBusinessException pmbe) {
|
230 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 415 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
231 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 416 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
232 |
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);
|
233 |
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);
|
234 |
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 |
}
|
235 |
}
|
| 425 |
}
|
236 |
}
|
| 426 |
|
237 |
|
| 427 |
|
238 |
|
| 428 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_EMAIL_ID, method = RequestMethod.DELETE)
|
239 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_ALL,method=RequestMethod.GET)
|
| 429 |
public ResponseEntity<?> removeRoleByNameWithEmailId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "emailId") String emailId){
|
240 |
public ResponseEntity<?> getAllRoles(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| 430 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
241 |
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"));
|
242 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRoleRepository.selectRolesByUserId(id));
|
| 434 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
243 |
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 |
}
|
244 |
}
|
| 447 |
|
245 |
|
| 448 |
@RequestMapping(value = ProfitMandiConstants.URL_ADMIN_TOKEN, method = RequestMethod.POST)
|
246 |
@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){
|
247 |
public ResponseEntity<?> getAdminToken(HttpServletRequest request, @RequestParam(name = "adminToken") String adminToken, @RequestParam(name = "emailId") String emailId){
|
| 450 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
248 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|