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