Subversion Repositories SmartDukaan

Rev

Rev 35458 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21561 ashik.ali 1
package com.spice.profitmandi.web.controller;
21555 kshitij.so 2
 
25008 amit.gupta 3
import com.google.gson.Gson;
4
import com.google.gson.reflect.TypeToken;
21561 ashik.ali 5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
24016 amit.gupta 6
import com.spice.profitmandi.common.model.Location;
21561 ashik.ali 7
import com.spice.profitmandi.common.model.ProfitMandiConstants;
25011 amit.gupta 8
import com.spice.profitmandi.common.model.ProfitMandiResponse;
25008 amit.gupta 9
import com.spice.profitmandi.common.web.client.RestClient;
24383 amit.gupta 10
import com.spice.profitmandi.dao.entity.auth.AuthUser;
30299 amit.gupta 11
import com.spice.profitmandi.dao.entity.dtr.*;
24016 amit.gupta 12
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
25303 amit.gupta 13
import com.spice.profitmandi.dao.entity.user.Device;
22111 ashik.ali 14
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
15
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
24383 amit.gupta 16
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
25303 amit.gupta 17
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
30299 amit.gupta 18
import com.spice.profitmandi.dao.repository.dtr.*;
24383 amit.gupta 19
import com.spice.profitmandi.service.AuthService;
24976 amit.gupta 20
import com.spice.profitmandi.service.authentication.RoleManager;
21
import com.spice.profitmandi.service.user.RetailerService;
34785 vikas.jang 22
import com.spice.profitmandi.service.user.UserService;
22139 amit.gupta 23
import com.spice.profitmandi.web.model.LoginDetails;
22069 ashik.ali 24
import com.spice.profitmandi.web.util.CookiesProcessor;
22111 ashik.ali 25
import com.spice.profitmandi.web.util.GoogleTokenUtil;
21574 ashik.ali 26
import com.spice.profitmandi.web.util.MVCResponseSender;
32570 amit.gupta 27
import org.apache.commons.lang.StringUtils;
30299 amit.gupta 28
import org.apache.http.NameValuePair;
29
import org.apache.http.client.utils.URLEncodedUtils;
30
import org.apache.http.message.BasicNameValuePair;
31
import org.apache.logging.log4j.LogManager;
32
import org.apache.logging.log4j.Logger;
33
import org.springframework.beans.factory.annotation.Autowired;
34
import org.springframework.beans.factory.annotation.Value;
35
import org.springframework.stereotype.Controller;
36
import org.springframework.ui.Model;
37
import org.springframework.ui.ModelMap;
38
import org.springframework.web.bind.annotation.*;
21561 ashik.ali 39
 
30299 amit.gupta 40
import javax.servlet.http.Cookie;
41
import javax.servlet.http.HttpServletRequest;
42
import javax.servlet.http.HttpServletResponse;
35458 amit 43
import org.springframework.transaction.annotation.Transactional;
30299 amit.gupta 44
import java.lang.reflect.Type;
45
import java.time.LocalDateTime;
46
import java.util.*;
47
import java.util.stream.Collectors;
48
 
21555 kshitij.so 49
@Controller
35458 amit 50
@Transactional(rollbackFor = Throwable.class)
21555 kshitij.so 51
public class LoginController {
52
 
32570 amit.gupta 53
    private static final Logger LOGGER = LogManager.getLogger(LoginController.class);
24016 amit.gupta 54
 
32570 amit.gupta 55
    @Autowired
56
    private GoogleTokenUtil googleTokenUtil;
24016 amit.gupta 57
 
32570 amit.gupta 58
    @Autowired
59
    private RoleManager roleManager;
26449 amit.gupta 60
 
32570 amit.gupta 61
    @Autowired
62
    private DeviceRepository deviceRepository;
24984 amit.gupta 63
 
32570 amit.gupta 64
    @Autowired
65
    private RetailerRepository retailerRepository;
24016 amit.gupta 66
 
32570 amit.gupta 67
    @Autowired
68
    private RetailerService retailerService;
24984 amit.gupta 69
 
32570 amit.gupta 70
    @Autowired
71
    private UserRepository userRepository;
24016 amit.gupta 72
 
32570 amit.gupta 73
    @Autowired
74
    private UserAccountRepository userAccountRepository;
24016 amit.gupta 75
 
32570 amit.gupta 76
    @Autowired
77
    private UserRoleRepository userRoleRepository;
24016 amit.gupta 78
 
32570 amit.gupta 79
    @Autowired
80
    private RoleRepository roleRepository;
24016 amit.gupta 81
 
32570 amit.gupta 82
    @Autowired
83
    private FofoStoreRepository fofoStoreRepository;
24016 amit.gupta 84
 
32570 amit.gupta 85
    @Autowired
86
    private MVCResponseSender mvcResponseSender;
25243 amit.gupta 87
 
32570 amit.gupta 88
    @Autowired
89
    private RestClient restClient;
24016 amit.gupta 90
 
32570 amit.gupta 91
    @Autowired
92
    private CookiesProcessor cookiesProcessor;
22079 amit.gupta 93
 
32570 amit.gupta 94
    @Value("${google.api.key}")
95
    private String googleApiKey;
24016 amit.gupta 96
 
32570 amit.gupta 97
    @Value("${app.token.url}")
98
    private String appTokenUrl;
24383 amit.gupta 99
 
32570 amit.gupta 100
    @Value("${angular.app.url}")
101
    private String appUrl;
24383 amit.gupta 102
 
36369 vikas 103
    @Value("${react.app.url}")
104
    private String reactAppUrl;
105
 
32570 amit.gupta 106
    @Value("${admin.token}")
107
    private String adminToken;
24016 amit.gupta 108
 
32570 amit.gupta 109
    @Autowired
110
    private AuthService authService;
26449 amit.gupta 111
 
32570 amit.gupta 112
    @Autowired
34785 vikas.jang 113
    private UserService userService;
114
 
115
    @Autowired
32570 amit.gupta 116
    private AuthRepository authRepository;
24016 amit.gupta 117
 
32570 amit.gupta 118
    @RequestMapping(value = "/login", method = RequestMethod.GET)
119
    public String loginPage(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
120
        LOGGER.info("Context Path is {}", request.getContextPath());
121
        try {
122
            LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
123
            LOGGER.info("Request session is already exist, should be redirect to as per roles assigned");
124
            String redirectUrl = null;
25243 amit.gupta 125
 
32570 amit.gupta 126
            Role roleRetailer = roleRepository.selectByName(RoleType.RETAILER.toString());
127
            Role roleFofo = roleRepository.selectByName(RoleType.FOFO.toString());
128
            Role roleFofoAdmin = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
129
            if (fofoDetails.getRoleIds().contains(roleFofoAdmin.getId())) {
130
                redirectUrl = "/dashboard";
131
            } else if (fofoDetails.getRoleIds().contains(roleRetailer.getId())
132
                    && fofoDetails.getRoleIds().contains(roleFofo.getId())) {
133
                FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoDetails.getFofoId());
134
                if (!fofoStore.isActive()) {
135
                    cookiesProcessor.removeCookies(request, response);
136
                    throw new ProfitMandiBusinessException("", "", "");
137
                }
138
                redirectUrl = "/dashboard";
24016 amit.gupta 139
 
32570 amit.gupta 140
            } else {
141
                redirectUrl = "/login";
142
            }
143
            return "redirect:" + redirectUrl;
144
        } catch (ProfitMandiBusinessException profitMandiBusinessException) {
145
            model.addAttribute("googleApiKey", googleApiKey);
146
            model.addAttribute("appContextPath", request.getContextPath());
147
            return "login";
148
        }
149
    }
25303 amit.gupta 150
 
32570 amit.gupta 151
    @RequestMapping(value = "/", method = RequestMethod.GET)
152
    public String home() {
153
        return "redirect:/login";
154
    }
25243 amit.gupta 155
 
32570 amit.gupta 156
    @RequestMapping(value = "/mobileapp", method = RequestMethod.GET)
36369 vikas 157
    public String mobileApp(HttpServletRequest request, Model model, @RequestParam(defaultValue = "") String emailId, @RequestParam(defaultValue = "") String appType)
32570 amit.gupta 158
            throws Exception {
159
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
160
        if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
32574 amit.gupta 161
            if (StringUtils.isEmpty(emailId)) {
32570 amit.gupta 162
                AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
163
                model.addAttribute("authToken", getToken(authUser.getGmailId()));
164
            } else {
165
                model.addAttribute("authToken", getToken(emailId));
166
                model.addAttribute("androidId", getAndroidId(emailId));
167
            }
168
        } else {
169
            emailId = fofoDetails.getEmailId();
170
            model.addAttribute("authToken", getToken(emailId));
171
            model.addAttribute("androidId", getAndroidId(emailId));
172
        }
34300 ranu 173
        model.addAttribute("internal", true);
36369 vikas 174
        if (appType.equals("angular")) {
175
            model.addAttribute("appUrl", appUrl);
176
        } else {
177
            model.addAttribute("appUrl", reactAppUrl);
178
        }
32570 amit.gupta 179
        return "mobileapp";
180
    }
25243 amit.gupta 181
 
32570 amit.gupta 182
    private String getAndroidId(String emailId) throws Exception {
183
        User user = userRepository.selectByEmailId(emailId);
184
        List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(Arrays.asList(user.getId()),
185
                LocalDateTime.now().minusYears(2), LocalDateTime.now());
186
        if (devices.size() > 0) {
187
            Device device = devices.get(0);
188
            return device.getAndroidId();
189
        } else {
190
            return "";
191
        }
192
    }
24976 amit.gupta 193
 
32570 amit.gupta 194
    private String getToken(String emailId) throws Exception {
195
        List<NameValuePair> nameValuePairs = new ArrayList<>();
196
        nameValuePairs.add(new BasicNameValuePair("adminToken", this.adminToken));
197
        nameValuePairs.add(new BasicNameValuePair("emailId", emailId));
198
        String queryString = URLEncodedUtils.format(nameValuePairs, "UTF-8");
199
        String response = restClient.post(this.appTokenUrl + queryString,
200
                new HashMap<>(), new HashMap<>());
201
        Type t = new TypeToken<ProfitMandiResponse<Map<String, Object>>>() {
202
        }.getType();
203
        ProfitMandiResponse<Map<String, Object>> apiResponse = new Gson().fromJson(response, t);
204
        if (apiResponse.getStatusCode().equals("200")) {
205
            return (new StringBuilder((String) apiResponse.getResponse().get("token")).reverse().toString());
206
        } else {
207
            throw new Exception("Unauthorised access");
208
        }
24383 amit.gupta 209
 
32570 amit.gupta 210
    }
24383 amit.gupta 211
 
32570 amit.gupta 212
    @RequestMapping(value = "/login-as-partner", method = RequestMethod.GET)
213
    public String adminLogin(HttpServletRequest request, Model model, HttpServletResponse response,
214
                             @RequestParam int fofoId) throws Exception {
215
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
216
        if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
217
            int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
218
            User user = userRepository.selectById(userId);
219
            Set<Integer> roleIds = userRoleRepository.selectByUserId(userId).stream().map(x -> x.getRoleId())
220
                    .collect(Collectors.toSet());
221
            LoginDetails newFofoDetails = new LoginDetails();
222
            newFofoDetails.setFofoId(fofoId);
223
            newFofoDetails.setRoleIds(roleIds);
224
            newFofoDetails.setEmailId(user.getEmailId());
225
            model.addAttribute("response1", true);
226
            this.addCookiesToResponse(newFofoDetails, request, response);
227
        } else {
228
            throw new ProfitMandiBusinessException("", "", "");
229
        }
230
        return "response";
231
    }
24016 amit.gupta 232
 
32570 amit.gupta 233
    @RequestMapping(value = "/login-as-partner-readonly", method = RequestMethod.GET)
234
    public String readonlyLogin(HttpServletRequest request, Model model, HttpServletResponse response,
235
                                @RequestParam int fofoId) throws Exception {
236
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
237
        if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
238
            int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
239
            User user = userRepository.selectById(userId);
240
            Set<Integer> roleIds = userRoleRepository.selectByUserId(userId).stream().map(x -> x.getRoleId())
241
                    .collect(Collectors.toSet());
242
            LoginDetails newFofoDetails = new LoginDetails();
243
            newFofoDetails.setFofoId(fofoId);
244
            newFofoDetails.setRoleIds(roleIds);
245
            newFofoDetails.setEmailId(user.getEmailId());
246
            newFofoDetails.setReadOnly(true);
247
            model.addAttribute("response1", true);
248
            this.addCookiesToResponse(newFofoDetails, request, response);
249
        } else {
250
            throw new ProfitMandiBusinessException("", "", "");
251
        }
252
        return "response";
253
    }
24016 amit.gupta 254
 
32570 amit.gupta 255
    @RequestMapping(value = "/login", method = RequestMethod.POST)
256
    public String login(HttpServletRequest request, HttpServletResponse response,
257
                        @RequestParam(name = ProfitMandiConstants.TOKEN) String token,
258
                        @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER, defaultValue = "") String emailIdOrMobileNumber,
259
                        @RequestParam(name = "password", defaultValue = "") String password, Model model) throws Exception {
25275 amit.gupta 260
 
32570 amit.gupta 261
        LoginDetails fofoDetails = new LoginDetails();
262
        Set<Integer> roleIds = new HashSet<>();
263
        fofoDetails.setRoleIds(roleIds);
264
        String emailId = null;
265
        String name = null;
34785 vikas.jang 266
        User user = null;
32570 amit.gupta 267
        try {
268
            // if role is retailer then FOFO_ID is retailerId else it is userid as normal
269
            // user's wont have retailer id.
32571 amit.gupta 270
            if (StringUtils.isEmpty(token)) {
32570 amit.gupta 271
                if (authService.authenticate(emailIdOrMobileNumber, password)) {
272
                    AuthUser authUser = authRepository.selectByEmailOrMobile(emailIdOrMobileNumber);
273
                    if (authUser == null) {
34785 vikas.jang 274
                        throw new ProfitMandiBusinessException("Authentication", "Email or Mobile", "Invalid Email Or Mobile");
32570 amit.gupta 275
                    }
276
                    emailId = authUser.getEmailId();
277
                    name = authUser.getFirstName() + " " + authUser.getLastName();
278
                    authUser.setLastLoginTimestamp(LocalDateTime.now());
34785 vikas.jang 279
                } else {
280
                    // TODO: Add login with email and password
281
                    user = userService.authenticate(emailIdOrMobileNumber, password);
282
                    if (user != null) {
283
                        emailId = user.getEmailId();
284
                    } else {
285
                        LOGGER.error("User not found with given emailIdOrMobileNumber [{}]", emailIdOrMobileNumber);
286
                        model.addAttribute("response1", mvcResponseSender.createResponseString("RTLR_OK_1002", true,
287
                                request.getContextPath() + "/login", "Email"));
288
                        return "response";
289
                    }
32570 amit.gupta 290
                }
291
            } else {
292
                try {
293
                    emailId = googleTokenUtil.getEmailId(token);
294
                } catch (Exception e) {
295
                    // in case we cannot connect to google server.
296
                    emailId = emailIdOrMobileNumber;
297
                }
298
            }
299
            fofoDetails.setEmailId(emailId);
300
            fofoDetails.setFofoId(-1);
34785 vikas.jang 301
 
32570 amit.gupta 302
            if (user == null) {
303
                try {
34785 vikas.jang 304
                    user = userRepository.selectByEmailId(emailId);
32570 amit.gupta 305
                } catch (ProfitMandiBusinessException profitMandiBusinessException) {
34785 vikas.jang 306
                    LOGGER.error("User not found with given emailId [{}]", emailId);
307
                    try {
308
                        user = userRepository.selectBySecondryEmailId(emailId);
309
                    } catch (ProfitMandiBusinessException exception) {
310
                        LOGGER.error("User not found with given emailId", exception);
311
                        model.addAttribute("response1", mvcResponseSender.createResponseString("RTLR_OK_1002", true,
312
                                request.getContextPath() + "/login", "Email"));
313
                        return "response";
314
                    }
32570 amit.gupta 315
                }
316
            }
34785 vikas.jang 317
 
32570 amit.gupta 318
            if (user != null) {
319
                fofoDetails.setFofoId(user.getId());
320
                try {
321
                    List<UserRole> userRoles = userRoleRepository.selectByUserId(user.getId());
34785 vikas.jang 322
                    for (UserRole userRole : userRoles) {
323
                        roleIds.add(userRole.getRoleId());
32570 amit.gupta 324
                    }
325
                    List<Role> roles = roleRepository.selectByIds(roleIds);
326
                    for (Role role : roles) {
327
                        if (role.getName().equals(RoleType.RETAILER.toString())) {
34785 vikas.jang 328
                            UserAccount userAccounts = userAccountRepository.selectByUserIdType(user.getId(), AccountType.saholic);
32570 amit.gupta 329
                            Retailer retailer = retailerRepository.selectById(userAccounts.getAccountKey());
330
                            fofoDetails.setFofoId(retailer.getId());
331
                        }
332
                    }
333
                } catch (ProfitMandiBusinessException pmbe) {
334
                    LOGGER.error("Data Inconsistent", pmbe);
335
                }
336
            }
337
            String redirectUrl = null;
24976 amit.gupta 338
 
32570 amit.gupta 339
            Role roleFofo = roleRepository.selectByName(RoleType.FOFO.toString());
340
            Role roleFofoAdmin = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
24016 amit.gupta 341
 
32570 amit.gupta 342
            if (fofoDetails.getRoleIds().contains(roleFofo.getId())) {
343
                redirectUrl = "/dashboard";
344
            } else {
345
                redirectUrl = "/login";
346
            }
24016 amit.gupta 347
 
32570 amit.gupta 348
            if (redirectUrl.equals("/dashboard")) {
349
                user.setLoginTimestamp(LocalDateTime.now());
350
                this.addCookiesToResponse(fofoDetails, request, response);
34785 vikas.jang 351
                LOGGER.info("Requested token email_id is valid, user login to system, shoud be redirect to {}", redirectUrl);
32570 amit.gupta 352
                model.addAttribute("response1", mvcResponseSender.createResponseString("RTLR_OK_1002", true,
353
                        request.getContextPath() + redirectUrl, name));
354
            } else {
355
                LOGGER.error("Requested token email_id is not valid, please try to login");
356
                /**
357
                 * TODO:Amit This redirect should be handle.
358
                 */
34785 vikas.jang 359
                throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, fofoDetails.getEmailId(), "RTLR_1000");
32570 amit.gupta 360
            }
361
            return "response";
362
        } catch (ProfitMandiBusinessException profitMandiBusinessException) {
363
            LOGGER.error("Error : ", profitMandiBusinessException);
364
            model.addAttribute("response1",
365
                    mvcResponseSender.createResponseString(profitMandiBusinessException.getCode(), false, "/error"));
366
            return "response";
367
        } catch (Exception e) {
368
            e.printStackTrace();
369
            model.addAttribute("response1",
370
                    mvcResponseSender.createResponseString(
371
                            "You are not authorised! " + "Please contact the team if you feel this is incorrect", false,
372
                            "/error"));
373
            return "response";
374
        }
375
    }
24016 amit.gupta 376
 
32570 amit.gupta 377
    @PostMapping(value = "/forgetPassword")
34785 vikas.jang 378
    public String forgetPasswordPage(@RequestParam(name = ProfitMandiConstants.EMAIL_ID, defaultValue = "") String emailId, Model model) throws Exception {
379
        try {
380
            LOGGER.info("Forgetting password of: [{}]",emailId);
381
            authService.resetPassword(emailId);
382
        } catch (Exception exception){
383
            try {
384
                userService.resetPassword(emailId);
385
            } catch (Exception e){
34815 vikas 386
                LOGGER.info("Forgetting password of: [{}] - {}",emailId, e);
34785 vikas.jang 387
                throw new ProfitMandiBusinessException("Password Reset Email", emailId, "Could not send password reset mail. Password Could not be reset");
388
            }
389
        }
32570 amit.gupta 390
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
391
        LOGGER.info("completed");
392
        return "response";
393
    }
24984 amit.gupta 394
 
34785 vikas.jang 395
    private void addCookiesToResponse(LoginDetails fofoDetails, HttpServletRequest request, HttpServletResponse response) {
32570 amit.gupta 396
        List<String> roleIds = new ArrayList<>();
24016 amit.gupta 397
 
32570 amit.gupta 398
        for (int roleId : fofoDetails.getRoleIds()) {
399
            roleIds.add(String.valueOf(roleId));
400
        }
401
        Cookie cookieRoleIds = new Cookie(ProfitMandiConstants.ROLE_IDS, String.join("-", roleIds));
402
        cookieRoleIds.setDomain(request.getServerName());
403
        cookieRoleIds.setPath(request.getContextPath());
24016 amit.gupta 404
 
32570 amit.gupta 405
        Cookie cookieFofoId = new Cookie(ProfitMandiConstants.FOFO_ID, String.valueOf(fofoDetails.getFofoId()));
406
        cookieFofoId.setDomain(request.getServerName());
407
        cookieFofoId.setPath(request.getContextPath());
408
 
409
        Cookie cookieEmailId = new Cookie(ProfitMandiConstants.EMAIL_ID, fofoDetails.getEmailId());
410
        cookieEmailId.setDomain(request.getServerName());
411
        cookieEmailId.setPath(request.getContextPath());
412
 
413
        Cookie cookieReadOnly = new Cookie(ProfitMandiConstants.READONLY_KEY, fofoDetails.isReadOnly() + "");
414
        cookieReadOnly.setDomain(request.getServerName());
415
        cookieReadOnly.setPath(request.getContextPath());
416
 
417
        response.addCookie(cookieFofoId);
418
        response.addCookie(cookieEmailId);
419
        response.addCookie(cookieRoleIds);
420
        response.addCookie(cookieReadOnly);
421
    }
422
 
423
    @RequestMapping(value = "/logout", method = RequestMethod.GET)
424
    public String logout(HttpServletRequest request, @ModelAttribute("model") ModelMap model,
425
                         HttpServletResponse response) throws Exception {
426
        try {
427
            LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
428
            User user = null;
429
            try {
430
                user = userRepository.selectByEmailId(loginDetails.getEmailId());
431
            } catch (ProfitMandiBusinessException profitMandiBusinessException) {
432
                LOGGER.error("User not found with given emailId", profitMandiBusinessException);
433
            }
434
            if (user == null) {
435
                user = userRepository.selectBySecondryEmailId(loginDetails.getEmailId());
436
            }
437
            user.setLogoutTimestamp(LocalDateTime.now());
438
            cookiesProcessor.removeCookies(request, response);
439
            LOGGER.info("Logout is successfull, should be redirect to /login");
440
            return "redirect:/login";
441
        } catch (ProfitMandiBusinessException profitMandiBusinessException) {
442
            LOGGER.info("Error occured while removing requested cookies, should be redirect to /login");
443
            return "redirect:/login";
444
        }
445
    }
446
 
447
    @RequestMapping(value = "/partner/location", method = RequestMethod.PUT)
448
    public String setLocation(HttpServletRequest request, Model model, @RequestBody Location location)
449
            throws Exception {
450
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
451
        boolean response = true;
452
        try {
453
            FofoStore fs = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
454
            if (fs.getLatitude() == null) {
455
                fs.setLatitude(location.getLatitude());
456
                fs.setLongitude(location.getLongitude());
457
            }
458
            model.addAttribute("response1", response);
459
        } catch (Exception e) {
460
            LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
461
        }
462
        return "response";
463
    }
21555 kshitij.so 464
}