diff --git a/src/main/java/com/northtecom/visatrack/api/base/web/Status.java b/src/main/java/com/northtecom/visatrack/api/base/web/Status.java index e681386..8e2f49f 100644 --- a/src/main/java/com/northtecom/visatrack/api/base/web/Status.java +++ b/src/main/java/com/northtecom/visatrack/api/base/web/Status.java @@ -59,6 +59,12 @@ public enum Status implements IStatus { */ PARAM_NOT_NULL(400, "Parameters cannot be empty!"), + /** + * 当前用户已被锁定,请联系管理员解锁! + */ + USER_NOT_ACTIVE(453, "The current user has not been active!"), + + /** * 当前用户已被锁定,请联系管理员解锁! */ @@ -99,16 +105,6 @@ public enum Status implements IStatus { */ private String message; - @Override - public Integer getCode() { - return code; - } - - @Override - public String getMessage() { - return message; - } - Status(Integer code, String message) { this.code = code; this.message = message; @@ -124,6 +120,16 @@ public enum Status implements IStatus { return SUCCESS; } + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } + @Override public String toString() { return String.format(" Status:{code=%s, message=%s} ", getCode(), getMessage()); diff --git a/src/main/java/com/northtecom/visatrack/api/config/SpringDocConfig.java b/src/main/java/com/northtecom/visatrack/api/config/SpringDocConfig.java index 6f283db..73d1bfe 100644 --- a/src/main/java/com/northtecom/visatrack/api/config/SpringDocConfig.java +++ b/src/main/java/com/northtecom/visatrack/api/config/SpringDocConfig.java @@ -19,7 +19,7 @@ import java.util.Arrays; @Configuration public class SpringDocConfig { - private static final String VERSION = "1.0.1"; + private static final String VERSION = "1.0.3"; @Value("${spring.application.title}") private String applicationTitle; diff --git a/src/main/java/com/northtecom/visatrack/api/controller/AuthController.java b/src/main/java/com/northtecom/visatrack/api/controller/AuthController.java index a1dcbec..9cc53c0 100644 --- a/src/main/java/com/northtecom/visatrack/api/controller/AuthController.java +++ b/src/main/java/com/northtecom/visatrack/api/controller/AuthController.java @@ -6,6 +6,7 @@ import com.northtecom.visatrack.api.base.exception.BaseException; import com.northtecom.visatrack.api.base.web.Status; import com.northtecom.visatrack.api.controller.vo.*; import com.northtecom.visatrack.api.data.entity.User; +import com.northtecom.visatrack.api.data.entity.UserChangePassword; import com.northtecom.visatrack.api.service.impl.UserService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -71,6 +72,7 @@ public class AuthController { registerUserInfoResponse.setUserId(user.getId().toString()); registerUserInfoResponse.setUserEmail(user.getUserEmail()); registerUserInfoResponse.setUserLoginDate(new Date()); + registerUserInfoResponse.setUserActiveCode(user.getEmailVerifiedCode()); return registerUserInfoResponse; } @@ -138,6 +140,8 @@ public class AuthController { public UserLoginResponse customLogin(@RequestBody @Valid UserLoginRequest userLoginRequest) throws JsonProcessingException { log.debug("Login Request: {}", this.objectMapper.writeValueAsString(userLoginRequest)); + this.userService.loadUserByUsername(userLoginRequest.getUserEmail()); + Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(userLoginRequest.getUserEmail(), userLoginRequest.getPassword())); @@ -174,12 +178,17 @@ public class AuthController { @ResponseBody @Operation(summary = "用户忘记密码接口", description = "用户忘记密码接口,用户忘记密码以后,通过该接口输入一个邮件地址,系统会给用户发送一封邮件,邮件中包含了重置密码的链接,用户点击以后,可以重置密码") - public Boolean forgotPassword(@RequestBody @Valid ForgotPasswordRequest forgotPasswordRequest) throws JsonProcessingException { + public UserChangePasswordResponse forgotPassword(@RequestBody @Valid ForgotPasswordRequest forgotPasswordRequest) throws JsonProcessingException { log.debug("Forgot Request: {}", this.objectMapper.writeValueAsString(forgotPasswordRequest)); - this.userService.forgotPassword(forgotPasswordRequest.getUserEmail()); + UserChangePassword userChangePassword = this.userService.forgotPassword(forgotPasswordRequest.getUserEmail()); - return true; + UserChangePasswordResponse userChangePasswordResponse = new UserChangePasswordResponse(); + userChangePasswordResponse.setUserId(userChangePassword.getUserId().toString()); + userChangePasswordResponse.setChangeCode(userChangePassword.getChangePasswordCode()); + userChangePasswordResponse.setSuccess(true); + + return userChangePasswordResponse; } @PostMapping("/user/password/forgot/change") diff --git a/src/main/java/com/northtecom/visatrack/api/controller/api/CaseVisaReportReportController.java b/src/main/java/com/northtecom/visatrack/api/controller/api/CaseVisaReportReportController.java index 827d6b7..b1846f3 100644 --- a/src/main/java/com/northtecom/visatrack/api/controller/api/CaseVisaReportReportController.java +++ b/src/main/java/com/northtecom/visatrack/api/controller/api/CaseVisaReportReportController.java @@ -1,9 +1,14 @@ package com.northtecom.visatrack.api.controller.api; +import com.northtecom.visatrack.api.base.exception.BaseException; +import com.northtecom.visatrack.api.base.web.Status; import com.northtecom.visatrack.api.controller.vo.AllReportDataSummary; import com.northtecom.visatrack.api.controller.vo.MonthlyReportDataSummary; +import com.northtecom.visatrack.api.controller.vo.ReportDataSummaryItem; import com.northtecom.visatrack.api.data.entity.CaseVisaReport; +import com.northtecom.visatrack.api.data.entity.VisaCase; import com.northtecom.visatrack.api.service.impl.CaseVisaReportService; +import com.northtecom.visatrack.api.service.impl.VisaCaseService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.web.bind.annotation.GetMapping; @@ -29,9 +34,12 @@ public class CaseVisaReportReportController { protected static final String TAG_DESCRIPTION = DATA_NAME + "管理API"; private final CaseVisaReportService caseVisaReportService; + private final VisaCaseService visaCaseService; - public CaseVisaReportReportController(CaseVisaReportService caseVisaReportService) { + public CaseVisaReportReportController(CaseVisaReportService caseVisaReportService, + VisaCaseService visaCaseService) { this.caseVisaReportService = caseVisaReportService; + this.visaCaseService = visaCaseService; } @@ -47,6 +55,16 @@ public class CaseVisaReportReportController { @GetMapping("/QueryMonthlyReportData") @Operation(summary = "按月查询报表数据", description = "按月查询报表数据,月份的格式为 yyyy-MM 例如 2022-10") public MonthlyReportDataSummary QueryAllReportData(String monthKey) { + CaseVisaReport caseVisaReport = this.caseVisaReportService.QueryByMonth(monthKey); + if (caseVisaReport == null) { + throw new BaseException(Status.BAD_REQUEST, "没有找到对应的报表数据"); + } + List visaCaseList = visaCaseService.QueryByMonthKey(monthKey); + MonthlyReportDataSummary monthlyReportDataSummary = new MonthlyReportDataSummary(); + monthlyReportDataSummary.setSummaryItem(new ReportDataSummaryItem(caseVisaReport)); + monthlyReportDataSummary.setVisaCaseList(visaCaseList); +// monthlyReportDataSummary.setCategorySummaryItem(ReportDataVisaCategorySummaryItem.newList +// (caseVisaReportService.QueryCaseStatusVisaCategorySummaryReport(monthKey))); return new MonthlyReportDataSummary(); } } diff --git a/src/main/java/com/northtecom/visatrack/api/controller/api/VisaController.java b/src/main/java/com/northtecom/visatrack/api/controller/api/VisaController.java index 7fe96aa..94a8510 100644 --- a/src/main/java/com/northtecom/visatrack/api/controller/api/VisaController.java +++ b/src/main/java/com/northtecom/visatrack/api/controller/api/VisaController.java @@ -36,11 +36,11 @@ public class VisaController { this.visaCaseService = visaCaseService; } - @GetMapping("/QueryByMonthKey") - @Operation(summary = "按月份查询签证数据", description = "按月份查询签证数据,月份的格式为 yyyy-MM 例如 2022-10") - public List QueryByMonthKey(String monthKey) { - return this.visaCaseService.QueryByMonthKey(monthKey); - } +// @GetMapping("/QueryByMonthKey") +// @Operation(summary = "按月份查询签证数据", description = "按月份查询签证数据,月份的格式为 yyyy-MM 例如 2022-10") +// public List QueryByMonthKey(String monthKey) { +// return this.visaCaseService.QueryByMonthKey(monthKey); +// } @GetMapping("/QueryByLastCompletedDay") @Operation(summary = "查询最近N天的完成的签证数据", description = "查询最近N天的完成的签证数据,比如输入 3 就是最近三天的完成签证的数据") diff --git a/src/main/java/com/northtecom/visatrack/api/controller/vo/AllReportDataSummary.java b/src/main/java/com/northtecom/visatrack/api/controller/vo/AllReportDataSummary.java index 201e316..27af942 100644 --- a/src/main/java/com/northtecom/visatrack/api/controller/vo/AllReportDataSummary.java +++ b/src/main/java/com/northtecom/visatrack/api/controller/vo/AllReportDataSummary.java @@ -24,17 +24,7 @@ public class AllReportDataSummary { public AllReportDataSummary(List reportDataItems) { this.items = new ArrayList<>(); for (CaseVisaReport item : reportDataItems) { - ReportDataSummaryItem reportDataSummaryItem = new ReportDataSummaryItem(); - reportDataSummaryItem.setMonth(item.getMonth()); - reportDataSummaryItem.setPendingCaseCount(item.getPendingCaseCount()); - reportDataSummaryItem.setClearCaseCount(item.getClearCaseCount()); - reportDataSummaryItem.setRejectCaseCount(item.getRejectCaseCount()); - reportDataSummaryItem.setTotalCaseCount(item.getTotalCaseCount()); - if (item.getAveWaitingDaysForCompleteCases() == null) { - reportDataSummaryItem.setAveWaitingDaysForCompleteCases("N/A"); - } else { - reportDataSummaryItem.setAveWaitingDaysForCompleteCases(item.getAveWaitingDaysForCompleteCases().toString()); - } + ReportDataSummaryItem reportDataSummaryItem = new ReportDataSummaryItem(item); this.items.add(reportDataSummaryItem); } } diff --git a/src/main/java/com/northtecom/visatrack/api/controller/vo/CustomerUserInfoResponse.java b/src/main/java/com/northtecom/visatrack/api/controller/vo/CustomerUserInfoResponse.java index f6eee70..fc1d107 100644 --- a/src/main/java/com/northtecom/visatrack/api/controller/vo/CustomerUserInfoResponse.java +++ b/src/main/java/com/northtecom/visatrack/api/controller/vo/CustomerUserInfoResponse.java @@ -17,4 +17,5 @@ public class CustomerUserInfoResponse { private String userName; private String userEmail; private Date userLoginDate; + private String userActiveCode; } diff --git a/src/main/java/com/northtecom/visatrack/api/controller/vo/MonthlyReportDataSummary.java b/src/main/java/com/northtecom/visatrack/api/controller/vo/MonthlyReportDataSummary.java index 2c6c727..60b62f7 100644 --- a/src/main/java/com/northtecom/visatrack/api/controller/vo/MonthlyReportDataSummary.java +++ b/src/main/java/com/northtecom/visatrack/api/controller/vo/MonthlyReportDataSummary.java @@ -1,5 +1,6 @@ package com.northtecom.visatrack.api.controller.vo; +import com.northtecom.visatrack.api.data.entity.VisaCase; import lombok.Data; import java.util.List; @@ -16,4 +17,5 @@ public class MonthlyReportDataSummary { private ReportDataSummaryItem summaryItem; private List categorySummaryItem; private List consulateSummaryItem; + private List visaCaseList; } diff --git a/src/main/java/com/northtecom/visatrack/api/controller/vo/ReportDataSummaryItem.java b/src/main/java/com/northtecom/visatrack/api/controller/vo/ReportDataSummaryItem.java index bb2e242..4c02c09 100644 --- a/src/main/java/com/northtecom/visatrack/api/controller/vo/ReportDataSummaryItem.java +++ b/src/main/java/com/northtecom/visatrack/api/controller/vo/ReportDataSummaryItem.java @@ -1,5 +1,6 @@ package com.northtecom.visatrack.api.controller.vo; +import com.northtecom.visatrack.api.data.entity.CaseVisaReport; import lombok.Data; /** @@ -17,4 +18,17 @@ public class ReportDataSummaryItem { private Integer rejectCaseCount; private Integer totalCaseCount; private String AveWaitingDaysForCompleteCases; + + public ReportDataSummaryItem(CaseVisaReport item) { + this.setMonth(item.getMonth()); + this.setPendingCaseCount(item.getPendingCaseCount()); + this.setClearCaseCount(item.getClearCaseCount()); + this.setRejectCaseCount(item.getRejectCaseCount()); + this.setTotalCaseCount(item.getTotalCaseCount()); + if (item.getAveWaitingDaysForCompleteCases() == null) { + this.setAveWaitingDaysForCompleteCases("N/A"); + } else { + this.setAveWaitingDaysForCompleteCases(item.getAveWaitingDaysForCompleteCases().toString()); + } + } } diff --git a/src/main/java/com/northtecom/visatrack/api/controller/vo/ReportDataVisaCategorySummaryItem.java b/src/main/java/com/northtecom/visatrack/api/controller/vo/ReportDataVisaCategorySummaryItem.java index 780b52f..4db9777 100644 --- a/src/main/java/com/northtecom/visatrack/api/controller/vo/ReportDataVisaCategorySummaryItem.java +++ b/src/main/java/com/northtecom/visatrack/api/controller/vo/ReportDataVisaCategorySummaryItem.java @@ -1,7 +1,11 @@ package com.northtecom.visatrack.api.controller.vo; +import com.northtecom.visatrack.api.service.dto.CaseStatusVisaCategorySummaryReport; import lombok.Data; +import java.util.List; +import java.util.stream.Collectors; + /** * Created with IntelliJ IDEA. * @@ -11,10 +15,37 @@ import lombok.Data; */ @Data public class ReportDataVisaCategorySummaryItem { - private String month; private String category; private Integer pendingCaseCount; private Integer clearCaseCount; private Integer rejectCaseCount; private Integer totalCaseCount; + + + public static ReportDataVisaCategorySummaryItem from(List reports, + String category) { + List categoryReports = + reports.stream().filter(report -> report.getVisaCategory().equals(category)).collect(Collectors.toList()); + ReportDataVisaCategorySummaryItem item = new ReportDataVisaCategorySummaryItem(); + item.setCategory(category); + item.setPendingCaseCount(0); + item.setClearCaseCount(0); + item.setRejectCaseCount(0); + item.setTotalCaseCount(0); + for (CaseStatusVisaCategorySummaryReport report : categoryReports) { + switch (report.getStatus()) { + case "PENDING": + item.setPendingCaseCount(report.getCaseCount()); + break; + case "CLEAR": + item.setClearCaseCount(report.getCaseCount()); + break; + case "REJECT": + item.setRejectCaseCount(report.getCaseCount()); + break; + } + } + item.setTotalCaseCount(item.getPendingCaseCount() + item.getClearCaseCount() + item.getRejectCaseCount()); + return item; + } } diff --git a/src/main/java/com/northtecom/visatrack/api/controller/vo/UserChangePasswordResponse.java b/src/main/java/com/northtecom/visatrack/api/controller/vo/UserChangePasswordResponse.java new file mode 100644 index 0000000..222c4e8 --- /dev/null +++ b/src/main/java/com/northtecom/visatrack/api/controller/vo/UserChangePasswordResponse.java @@ -0,0 +1,19 @@ +package com.northtecom.visatrack.api.controller.vo; + +import lombok.Data; + +/** + * Created with IntelliJ IDEA. + * + * @Author: XieYang + * @Date: 2022/10/16/11:43 + * @Description: + */ +@Data +public class UserChangePasswordResponse { + private Boolean success; + private String userId; + private String changeCode; + + +} diff --git a/src/main/java/com/northtecom/visatrack/api/data/repository/VisaCaseRepository.java b/src/main/java/com/northtecom/visatrack/api/data/repository/VisaCaseRepository.java index c2b51fd..a119fdd 100644 --- a/src/main/java/com/northtecom/visatrack/api/data/repository/VisaCaseRepository.java +++ b/src/main/java/com/northtecom/visatrack/api/data/repository/VisaCaseRepository.java @@ -58,4 +58,21 @@ public interface VisaCaseRepository extends PagingAndSortingRepository=:startDate and date_visa_interview<:endDate \n" + + "GROUP by visa_category ,visa_status\n" + + "ORDER by visa_category ,visa_status", nativeQuery = true) + List queryCategoryStatusReport(@Param("startDate") LocalDate startDate, + @Param("endDate") LocalDate endDate); + + @Query(value = "select embassy_consulate ,visa_status,COUNT(*) case_count \n" + + "from usvisatrack.visa_case \n" + + "where date_visa_interview >=:startDate and date_visa_interview<:endDate \n" + + "GROUP by embassy_consulate ,visa_status\n" + + "ORDER by embassy_consulate ,visa_status", nativeQuery = true) + List queryConsulateStatusReport(@Param("startDate") LocalDate startDate, + @Param("endDate") LocalDate endDate); + + } diff --git a/src/main/java/com/northtecom/visatrack/api/service/dto/CaseStatusConsulateSummaryReport.java b/src/main/java/com/northtecom/visatrack/api/service/dto/CaseStatusConsulateSummaryReport.java index 3fe2140..f383bfc 100644 --- a/src/main/java/com/northtecom/visatrack/api/service/dto/CaseStatusConsulateSummaryReport.java +++ b/src/main/java/com/northtecom/visatrack/api/service/dto/CaseStatusConsulateSummaryReport.java @@ -1,5 +1,7 @@ package com.northtecom.visatrack.api.service.dto; +import lombok.Data; + /** * Created with IntelliJ IDEA. * @@ -7,8 +9,8 @@ package com.northtecom.visatrack.api.service.dto; * @Date: 2022/10/15/11:30 * @Description: */ +@Data public class CaseStatusConsulateSummaryReport { - private String month; private String status; private String consulate; private Integer caseCount; diff --git a/src/main/java/com/northtecom/visatrack/api/service/dto/CaseStatusVisaCategorySummaryReport.java b/src/main/java/com/northtecom/visatrack/api/service/dto/CaseStatusVisaCategorySummaryReport.java index 4b51c9d..4a4f73b 100644 --- a/src/main/java/com/northtecom/visatrack/api/service/dto/CaseStatusVisaCategorySummaryReport.java +++ b/src/main/java/com/northtecom/visatrack/api/service/dto/CaseStatusVisaCategorySummaryReport.java @@ -11,7 +11,6 @@ import lombok.Data; */ @Data public class CaseStatusVisaCategorySummaryReport { - private String month; private String status; private String visaCategory; private Integer caseCount; diff --git a/src/main/java/com/northtecom/visatrack/api/service/impl/CaseVisaReportService.java b/src/main/java/com/northtecom/visatrack/api/service/impl/CaseVisaReportService.java index 022e9ad..e7198d3 100644 --- a/src/main/java/com/northtecom/visatrack/api/service/impl/CaseVisaReportService.java +++ b/src/main/java/com/northtecom/visatrack/api/service/impl/CaseVisaReportService.java @@ -1,10 +1,17 @@ package com.northtecom.visatrack.api.service.impl; import com.northtecom.visatrack.api.data.entity.CaseVisaReport; +import com.northtecom.visatrack.api.data.entity.Dictionary; import com.northtecom.visatrack.api.data.repository.CaseVisaReportRepository; +import com.northtecom.visatrack.api.data.repository.DictionaryRepository; +import com.northtecom.visatrack.api.data.repository.VisaCaseRepository; +import com.northtecom.visatrack.api.data.spec.DateRange; +import com.northtecom.visatrack.api.service.dto.CaseStatusConsulateSummaryReport; +import com.northtecom.visatrack.api.service.dto.CaseStatusVisaCategorySummaryReport; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; /** @@ -19,13 +26,107 @@ import java.util.List; public class CaseVisaReportService { private final CaseVisaReportRepository caseVisaReportRepository; + private final VisaCaseRepository visaCaseRepository; + private final DictionaryRepository dictionaryRepository; - public CaseVisaReportService(CaseVisaReportRepository caseVisaReportRepository) { + public CaseVisaReportService(CaseVisaReportRepository caseVisaReportRepository, + VisaCaseRepository visaCaseRepository, DictionaryRepository dictionaryRepository) { this.caseVisaReportRepository = caseVisaReportRepository; + this.visaCaseRepository = visaCaseRepository; + this.dictionaryRepository = dictionaryRepository; } public List QueryAllReportData() { return (List) this.caseVisaReportRepository.findAll(); } + + public CaseVisaReport QueryByMonth(String monthKey) { + return caseVisaReportRepository.findByMonth(monthKey).orElse(null); + } + + public List QueryStatusConsulateSummaryReport(String monthKey) { + DateRange dateRange = DateRange.ofMonthKey(monthKey); + + + List usConsulateList = dictionaryRepository.findAllByCategoryName("US_CONSULATE"); + List statusList = dictionaryRepository.findAllByCategoryName("VISA_STATUS"); + + List summaryReports = new ArrayList<>(); + + for (int i = 0; i < usConsulateList.size(); i++) { + String usConsulate = usConsulateList.get(i).getValue(); + for (int j = 0; j < statusList.size(); j++) { + String status = statusList.get(j).getValue(); + CaseStatusConsulateSummaryReport report = new CaseStatusConsulateSummaryReport(); + report.setConsulate(usConsulate); + report.setStatus(status); + report.setCaseCount(0); + summaryReports.add(report); + } + } + + List queryReportDatas = visaCaseRepository.queryConsulateStatusReport(dateRange.getStart(), + dateRange.getEnd()); + + for (int i = 0; i < queryReportDatas.size(); i++) { + Object[] queryReportData = queryReportDatas.get(i); + String usConsulate = (String) queryReportData[0]; + String status = (String) queryReportData[1]; + Integer caseCount = (Integer) queryReportData[2]; + + CaseStatusConsulateSummaryReport summaryReport = summaryReports.stream() + .filter(x -> x.getConsulate().equals(usConsulate) && x.getStatus().equals(status)) + .findFirst().orElse(null); + + if (summaryReport != null) { + summaryReport.setCaseCount(caseCount); + } + } + + return summaryReports; + } + + public List QueryCaseStatusVisaCategorySummaryReport(String monthKey) { + DateRange dateRange = DateRange.ofMonthKey(monthKey); + + List visaCategoryList = dictionaryRepository.findAllByCategoryName("VISA_TYPE"); + List statusList = dictionaryRepository.findAllByCategoryName("VISA_STATUS"); + + List summaryReports = new ArrayList<>(); + + for (int i = 0; i < visaCategoryList.size(); i++) { + String visaCategory = visaCategoryList.get(i).getValue(); + for (int j = 0; j < statusList.size(); j++) { + String status = statusList.get(j).getValue(); + CaseStatusVisaCategorySummaryReport summaryReport = new CaseStatusVisaCategorySummaryReport(); + summaryReport.setVisaCategory(visaCategory); + summaryReport.setStatus(status); + summaryReport.setCaseCount(0); + summaryReports.add(summaryReport); + } + } + + List queryReportDatas = visaCaseRepository.queryCategoryStatusReport(dateRange.getStart(), + dateRange.getEnd()); + + for (int i = 0; i < queryReportDatas.size(); i++) { + Object[] queryReportData = queryReportDatas.get(i); + String visaCategory = (String) queryReportData[0]; + String status = (String) queryReportData[1]; + Integer caseCount = (Integer) queryReportData[2]; + + CaseStatusVisaCategorySummaryReport summaryReport = summaryReports.stream() + .filter(x -> x.getVisaCategory().equals(visaCategory) && x.getStatus().equals(status)) + .findFirst().orElse(null); + + if (summaryReport != null) { + summaryReport.setCaseCount(caseCount); + } + } + + return summaryReports; + } + + } diff --git a/src/main/java/com/northtecom/visatrack/api/service/impl/UserService.java b/src/main/java/com/northtecom/visatrack/api/service/impl/UserService.java index 5b93513..ccc6390 100644 --- a/src/main/java/com/northtecom/visatrack/api/service/impl/UserService.java +++ b/src/main/java/com/northtecom/visatrack/api/service/impl/UserService.java @@ -143,17 +143,17 @@ public class UserService implements UserDetailsService { "not found")); if (user.getUserStatus() == UserStatus.NEEDVERIFY) { - throw new BaseException(Status.BAD_REQUEST, "User is not verified"); + throw new BaseException(Status.USER_NOT_ACTIVE, "User is not verified"); } if (!user.getIsEmailVerified()) { - throw new BaseException(Status.BAD_REQUEST, "User email is not verified"); + throw new BaseException(Status.USER_NOT_ACTIVE, "User email is not verified"); } return new VisaTrackUserDetail(user); } - public void forgotPassword(String userEmail) { + public UserChangePassword forgotPassword(String userEmail) { User user = userRepository.findByUserEmail(userEmail).orElseThrow(() -> new BaseException(Status.BAD_REQUEST, "User is not exist")); @@ -168,7 +168,7 @@ public class UserService implements UserDetailsService { emailService.sendChangePasswordEmailToUser(user, savedUserChangePassword.getChangePasswordCode()); - + return savedUserChangePassword; } public void changeForgotPassword(ChangePasswordForgotRequest changePasswordForgotRequest) {