| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
2 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 3 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
3 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 4 |
import com.spice.profitmandi.dao.entity.fofo.TrialFeedbackForm;
|
- |
|
| 5 |
import com.spice.profitmandi.dao.entity.fofo.TrialForm;
|
4 |
import com.spice.profitmandi.dao.entity.fofo.TrialForm;
|
| 6 |
import com.spice.profitmandi.dao.repository.fofo.TrialFeedbackFormRepository;
|
- |
|
| 7 |
import com.spice.profitmandi.dao.repository.trialOnboarding.TrialFormRepository;
|
5 |
import com.spice.profitmandi.dao.repository.trialOnboarding.TrialFormRepository;
|
| 8 |
import com.spice.profitmandi.dao.service.TrialService;
|
- |
|
| 9 |
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
|
6 |
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
|
| 10 |
import com.spice.profitmandi.service.integrations.gstpro.entity.GstDetails;
|
7 |
import com.spice.profitmandi.service.integrations.gstpro.entity.GstDetails;
|
| 11 |
import org.apache.logging.log4j.LogManager;
|
8 |
import org.apache.logging.log4j.LogManager;
|
| 12 |
import org.apache.logging.log4j.Logger;
|
9 |
import org.apache.logging.log4j.Logger;
|
| 13 |
import org.springframework.beans.factory.annotation.Autowired;
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
| Line 37... |
Line 34... |
| 37 |
TrialFormRepository trialOnboardingRepository;
|
34 |
TrialFormRepository trialOnboardingRepository;
|
| 38 |
|
35 |
|
| 39 |
@Autowired
|
36 |
@Autowired
|
| 40 |
ResponseSender responseSender;
|
37 |
ResponseSender responseSender;
|
| 41 |
|
38 |
|
| 42 |
@Autowired
|
- |
|
| 43 |
TrialService trialService;
|
- |
|
| 44 |
|
- |
|
| 45 |
@Autowired
|
- |
|
| 46 |
TrialFeedbackFormRepository trialFeedbackFormRepository;
|
- |
|
| 47 |
|
- |
|
| 48 |
private static final Logger LOGGER = LogManager.getLogger(DealsController.class);
|
39 |
private static final Logger LOGGER = LogManager.getLogger(DealsController.class);
|
| 49 |
|
40 |
|
| 50 |
|
41 |
|
| 51 |
@RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
|
42 |
@RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
|
| 52 |
public ResponseEntity<?> gstValidate(HttpServletRequest request, @RequestParam String gstNo) throws Exception {
|
43 |
public ResponseEntity<?> gstValidate(HttpServletRequest request, @RequestParam String gstNo) throws Exception {
|
| Line 62... |
Line 53... |
| 62 |
return ResponseEntity.ok(gstDetails);
|
53 |
return ResponseEntity.ok(gstDetails);
|
| 63 |
}
|
54 |
}
|
| 64 |
|
55 |
|
| 65 |
|
56 |
|
| 66 |
@RequestMapping(value = "/trial-registration", method = RequestMethod.POST)
|
57 |
@RequestMapping(value = "/trial-registration", method = RequestMethod.POST)
|
| 67 |
public ResponseEntity<?> trialUser(@RequestBody TrialForm trialForm) {
|
58 |
public ResponseEntity<?> createTrialUser(@RequestBody TrialForm trialForm) {
|
| 68 |
if (trialForm.getMobile() == null || trialForm.getMobile().isEmpty()) {
|
59 |
if (trialForm.getMobile() == null || trialForm.getMobile().isEmpty()) {
|
| 69 |
return responseSender.badRequest("Mobile number is required");
|
60 |
return responseSender.badRequest("Mobile number is required");
|
| 70 |
}
|
61 |
}
|
| 71 |
try {
|
62 |
try {
|
| 72 |
TrialForm existingUser = trialOnboardingRepository.findByMobile(trialForm.getMobile());
|
63 |
TrialForm existingUser = trialOnboardingRepository.findByMobile(trialForm.getMobile());
|
| Line 74... |
Line 65... |
| 74 |
return responseSender.internalServerError("User already exists");
|
65 |
return responseSender.internalServerError("User already exists");
|
| 75 |
}
|
66 |
}
|
| 76 |
trialForm.setStatus(ProfitMandiConstants.Status.PENDING);
|
67 |
trialForm.setStatus(ProfitMandiConstants.Status.PENDING);
|
| 77 |
trialForm.setCreatedOn(LocalDateTime.now());
|
68 |
trialForm.setCreatedOn(LocalDateTime.now());
|
| 78 |
trialOnboardingRepository.persist(trialForm);
|
69 |
trialOnboardingRepository.persist(trialForm);
|
| 79 |
trialService.sentMailForTrialUser(trialForm);
|
- |
|
| 80 |
return responseSender.ok(trialForm);
|
70 |
return responseSender.ok(trialForm);
|
| 81 |
|
71 |
|
| 82 |
} catch (Exception e) {
|
72 |
} catch (Exception e) {
|
| 83 |
e.printStackTrace();
|
73 |
e.printStackTrace();
|
| 84 |
return responseSender.internalServerError("Registration failed: " + e.getMessage());
|
74 |
return responseSender.internalServerError("Registration failed: " + e.getMessage());
|
| 85 |
}
|
75 |
}
|
| 86 |
}
|
76 |
}
|
| 87 |
@RequestMapping(value = "/trial-feedback", method = RequestMethod.POST)
|
- |
|
| 88 |
public ResponseEntity<?> TrialFeedback(@RequestBody TrialFeedbackForm trialFeedbackForm) {
|
- |
|
| 89 |
try {
|
- |
|
| 90 |
trialFeedbackForm.setCreatedAt(LocalDateTime.now());
|
- |
|
| 91 |
trialFeedbackFormRepository.persist(trialFeedbackForm);
|
- |
|
| 92 |
return responseSender.ok(trialFeedbackForm);
|
- |
|
| 93 |
|
- |
|
| 94 |
} catch (Exception e) {
|
- |
|
| 95 |
e.printStackTrace();
|
- |
|
| 96 |
return responseSender.internalServerError("Feedback failed: " + e.getMessage());
|
- |
|
| 97 |
}
|
- |
|
| 98 |
}
|
- |
|
| 99 |
|
77 |
|
| 100 |
|
78 |
|
| 101 |
}
|
79 |
}
|