临时返回激活码参数方便测试
This commit is contained in:
parent
239810a5e6
commit
8aff8c08af
|
@ -59,6 +59,12 @@ public enum Status implements IStatus {
|
||||||
*/
|
*/
|
||||||
PARAM_NOT_NULL(400, "Parameters cannot be empty!"),
|
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;
|
private String message;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status(Integer code, String message) {
|
Status(Integer code, String message) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
@ -124,6 +120,16 @@ public enum Status implements IStatus {
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(" Status:{code=%s, message=%s} ", getCode(), getMessage());
|
return String.format(" Status:{code=%s, message=%s} ", getCode(), getMessage());
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.Arrays;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SpringDocConfig {
|
public class SpringDocConfig {
|
||||||
|
|
||||||
private static final String VERSION = "1.0.1";
|
private static final String VERSION = "1.0.3";
|
||||||
|
|
||||||
@Value("${spring.application.title}")
|
@Value("${spring.application.title}")
|
||||||
private String applicationTitle;
|
private String applicationTitle;
|
||||||
|
|
|
@ -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.base.web.Status;
|
||||||
import com.northtecom.visatrack.api.controller.vo.*;
|
import com.northtecom.visatrack.api.controller.vo.*;
|
||||||
import com.northtecom.visatrack.api.data.entity.User;
|
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 com.northtecom.visatrack.api.service.impl.UserService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
@ -71,6 +72,7 @@ public class AuthController {
|
||||||
registerUserInfoResponse.setUserId(user.getId().toString());
|
registerUserInfoResponse.setUserId(user.getId().toString());
|
||||||
registerUserInfoResponse.setUserEmail(user.getUserEmail());
|
registerUserInfoResponse.setUserEmail(user.getUserEmail());
|
||||||
registerUserInfoResponse.setUserLoginDate(new Date());
|
registerUserInfoResponse.setUserLoginDate(new Date());
|
||||||
|
registerUserInfoResponse.setUserActiveCode(user.getEmailVerifiedCode());
|
||||||
return registerUserInfoResponse;
|
return registerUserInfoResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +140,8 @@ public class AuthController {
|
||||||
public UserLoginResponse customLogin(@RequestBody @Valid UserLoginRequest userLoginRequest) throws JsonProcessingException {
|
public UserLoginResponse customLogin(@RequestBody @Valid UserLoginRequest userLoginRequest) throws JsonProcessingException {
|
||||||
log.debug("Login Request: {}", this.objectMapper.writeValueAsString(userLoginRequest));
|
log.debug("Login Request: {}", this.objectMapper.writeValueAsString(userLoginRequest));
|
||||||
|
|
||||||
|
this.userService.loadUserByUsername(userLoginRequest.getUserEmail());
|
||||||
|
|
||||||
Authentication authentication =
|
Authentication authentication =
|
||||||
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(userLoginRequest.getUserEmail(), userLoginRequest.getPassword()));
|
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(userLoginRequest.getUserEmail(), userLoginRequest.getPassword()));
|
||||||
|
|
||||||
|
@ -174,12 +178,17 @@ public class AuthController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Operation(summary = "用户忘记密码接口", description =
|
@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));
|
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")
|
@PostMapping("/user/password/forgot/change")
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package com.northtecom.visatrack.api.controller.api;
|
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.AllReportDataSummary;
|
||||||
import com.northtecom.visatrack.api.controller.vo.MonthlyReportDataSummary;
|
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.CaseVisaReport;
|
||||||
|
import com.northtecom.visatrack.api.data.entity.VisaCase;
|
||||||
import com.northtecom.visatrack.api.service.impl.CaseVisaReportService;
|
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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -29,9 +34,12 @@ public class CaseVisaReportReportController {
|
||||||
protected static final String TAG_DESCRIPTION = DATA_NAME + "管理API";
|
protected static final String TAG_DESCRIPTION = DATA_NAME + "管理API";
|
||||||
|
|
||||||
private final CaseVisaReportService caseVisaReportService;
|
private final CaseVisaReportService caseVisaReportService;
|
||||||
|
private final VisaCaseService visaCaseService;
|
||||||
|
|
||||||
public CaseVisaReportReportController(CaseVisaReportService caseVisaReportService) {
|
public CaseVisaReportReportController(CaseVisaReportService caseVisaReportService,
|
||||||
|
VisaCaseService visaCaseService) {
|
||||||
this.caseVisaReportService = caseVisaReportService;
|
this.caseVisaReportService = caseVisaReportService;
|
||||||
|
this.visaCaseService = visaCaseService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +55,16 @@ public class CaseVisaReportReportController {
|
||||||
@GetMapping("/QueryMonthlyReportData")
|
@GetMapping("/QueryMonthlyReportData")
|
||||||
@Operation(summary = "按月查询报表数据", description = "按月查询报表数据,月份的格式为 yyyy-MM 例如 2022-10")
|
@Operation(summary = "按月查询报表数据", description = "按月查询报表数据,月份的格式为 yyyy-MM 例如 2022-10")
|
||||||
public MonthlyReportDataSummary QueryAllReportData(String monthKey) {
|
public MonthlyReportDataSummary QueryAllReportData(String monthKey) {
|
||||||
|
CaseVisaReport caseVisaReport = this.caseVisaReportService.QueryByMonth(monthKey);
|
||||||
|
if (caseVisaReport == null) {
|
||||||
|
throw new BaseException(Status.BAD_REQUEST, "没有找到对应的报表数据");
|
||||||
|
}
|
||||||
|
List<VisaCase> 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();
|
return new MonthlyReportDataSummary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,11 @@ public class VisaController {
|
||||||
this.visaCaseService = visaCaseService;
|
this.visaCaseService = visaCaseService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/QueryByMonthKey")
|
// @GetMapping("/QueryByMonthKey")
|
||||||
@Operation(summary = "按月份查询签证数据", description = "按月份查询签证数据,月份的格式为 yyyy-MM 例如 2022-10")
|
// @Operation(summary = "按月份查询签证数据", description = "按月份查询签证数据,月份的格式为 yyyy-MM 例如 2022-10")
|
||||||
public List<VisaCase> QueryByMonthKey(String monthKey) {
|
// public List<VisaCase> QueryByMonthKey(String monthKey) {
|
||||||
return this.visaCaseService.QueryByMonthKey(monthKey);
|
// return this.visaCaseService.QueryByMonthKey(monthKey);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@GetMapping("/QueryByLastCompletedDay")
|
@GetMapping("/QueryByLastCompletedDay")
|
||||||
@Operation(summary = "查询最近N天的完成的签证数据", description = "查询最近N天的完成的签证数据,比如输入 3 就是最近三天的完成签证的数据")
|
@Operation(summary = "查询最近N天的完成的签证数据", description = "查询最近N天的完成的签证数据,比如输入 3 就是最近三天的完成签证的数据")
|
||||||
|
|
|
@ -24,17 +24,7 @@ public class AllReportDataSummary {
|
||||||
public AllReportDataSummary(List<CaseVisaReport> reportDataItems) {
|
public AllReportDataSummary(List<CaseVisaReport> reportDataItems) {
|
||||||
this.items = new ArrayList<>();
|
this.items = new ArrayList<>();
|
||||||
for (CaseVisaReport item : reportDataItems) {
|
for (CaseVisaReport item : reportDataItems) {
|
||||||
ReportDataSummaryItem reportDataSummaryItem = new ReportDataSummaryItem();
|
ReportDataSummaryItem reportDataSummaryItem = new ReportDataSummaryItem(item);
|
||||||
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());
|
|
||||||
}
|
|
||||||
this.items.add(reportDataSummaryItem);
|
this.items.add(reportDataSummaryItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,5 @@ public class CustomerUserInfoResponse {
|
||||||
private String userName;
|
private String userName;
|
||||||
private String userEmail;
|
private String userEmail;
|
||||||
private Date userLoginDate;
|
private Date userLoginDate;
|
||||||
|
private String userActiveCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.northtecom.visatrack.api.controller.vo;
|
package com.northtecom.visatrack.api.controller.vo;
|
||||||
|
|
||||||
|
import com.northtecom.visatrack.api.data.entity.VisaCase;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -16,4 +17,5 @@ public class MonthlyReportDataSummary {
|
||||||
private ReportDataSummaryItem summaryItem;
|
private ReportDataSummaryItem summaryItem;
|
||||||
private List<ReportDataVisaCategorySummaryItem> categorySummaryItem;
|
private List<ReportDataVisaCategorySummaryItem> categorySummaryItem;
|
||||||
private List<ReportDataVisaConsulateSummaryItem> consulateSummaryItem;
|
private List<ReportDataVisaConsulateSummaryItem> consulateSummaryItem;
|
||||||
|
private List<VisaCase> visaCaseList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.northtecom.visatrack.api.controller.vo;
|
package com.northtecom.visatrack.api.controller.vo;
|
||||||
|
|
||||||
|
import com.northtecom.visatrack.api.data.entity.CaseVisaReport;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,4 +18,17 @@ public class ReportDataSummaryItem {
|
||||||
private Integer rejectCaseCount;
|
private Integer rejectCaseCount;
|
||||||
private Integer totalCaseCount;
|
private Integer totalCaseCount;
|
||||||
private String AveWaitingDaysForCompleteCases;
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package com.northtecom.visatrack.api.controller.vo;
|
package com.northtecom.visatrack.api.controller.vo;
|
||||||
|
|
||||||
|
import com.northtecom.visatrack.api.service.dto.CaseStatusVisaCategorySummaryReport;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created with IntelliJ IDEA.
|
* Created with IntelliJ IDEA.
|
||||||
*
|
*
|
||||||
|
@ -11,10 +15,37 @@ import lombok.Data;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ReportDataVisaCategorySummaryItem {
|
public class ReportDataVisaCategorySummaryItem {
|
||||||
private String month;
|
|
||||||
private String category;
|
private String category;
|
||||||
private Integer pendingCaseCount;
|
private Integer pendingCaseCount;
|
||||||
private Integer clearCaseCount;
|
private Integer clearCaseCount;
|
||||||
private Integer rejectCaseCount;
|
private Integer rejectCaseCount;
|
||||||
private Integer totalCaseCount;
|
private Integer totalCaseCount;
|
||||||
|
|
||||||
|
|
||||||
|
public static ReportDataVisaCategorySummaryItem from(List<CaseStatusVisaCategorySummaryReport> reports,
|
||||||
|
String category) {
|
||||||
|
List<CaseStatusVisaCategorySummaryReport> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -58,4 +58,21 @@ public interface VisaCaseRepository extends PagingAndSortingRepository<VisaCase,
|
||||||
@Param("endDate") LocalDate endDate);
|
@Param("endDate") LocalDate endDate);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = "select visa_category ,visa_status,COUNT(*) case_count \n" +
|
||||||
|
"from usvisatrack.visa_case \n" +
|
||||||
|
"where date_visa_interview >=:startDate and date_visa_interview<:endDate \n" +
|
||||||
|
"GROUP by visa_category ,visa_status\n" +
|
||||||
|
"ORDER by visa_category ,visa_status", nativeQuery = true)
|
||||||
|
List<Object[]> 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<Object[]> queryConsulateStatusReport(@Param("startDate") LocalDate startDate,
|
||||||
|
@Param("endDate") LocalDate endDate);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.northtecom.visatrack.api.service.dto;
|
package com.northtecom.visatrack.api.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created with IntelliJ IDEA.
|
* Created with IntelliJ IDEA.
|
||||||
*
|
*
|
||||||
|
@ -7,8 +9,8 @@ package com.northtecom.visatrack.api.service.dto;
|
||||||
* @Date: 2022/10/15/11:30
|
* @Date: 2022/10/15/11:30
|
||||||
* @Description:
|
* @Description:
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
public class CaseStatusConsulateSummaryReport {
|
public class CaseStatusConsulateSummaryReport {
|
||||||
private String month;
|
|
||||||
private String status;
|
private String status;
|
||||||
private String consulate;
|
private String consulate;
|
||||||
private Integer caseCount;
|
private Integer caseCount;
|
||||||
|
|
|
@ -11,7 +11,6 @@ import lombok.Data;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CaseStatusVisaCategorySummaryReport {
|
public class CaseStatusVisaCategorySummaryReport {
|
||||||
private String month;
|
|
||||||
private String status;
|
private String status;
|
||||||
private String visaCategory;
|
private String visaCategory;
|
||||||
private Integer caseCount;
|
private Integer caseCount;
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
package com.northtecom.visatrack.api.service.impl;
|
package com.northtecom.visatrack.api.service.impl;
|
||||||
|
|
||||||
import com.northtecom.visatrack.api.data.entity.CaseVisaReport;
|
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.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 lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,13 +26,107 @@ import java.util.List;
|
||||||
public class CaseVisaReportService {
|
public class CaseVisaReportService {
|
||||||
|
|
||||||
private final CaseVisaReportRepository caseVisaReportRepository;
|
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.caseVisaReportRepository = caseVisaReportRepository;
|
||||||
|
this.visaCaseRepository = visaCaseRepository;
|
||||||
|
this.dictionaryRepository = dictionaryRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CaseVisaReport> QueryAllReportData() {
|
public List<CaseVisaReport> QueryAllReportData() {
|
||||||
return (List<CaseVisaReport>) this.caseVisaReportRepository.findAll();
|
return (List<CaseVisaReport>) this.caseVisaReportRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CaseVisaReport QueryByMonth(String monthKey) {
|
||||||
|
return caseVisaReportRepository.findByMonth(monthKey).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CaseStatusConsulateSummaryReport> QueryStatusConsulateSummaryReport(String monthKey) {
|
||||||
|
DateRange dateRange = DateRange.ofMonthKey(monthKey);
|
||||||
|
|
||||||
|
|
||||||
|
List<Dictionary> usConsulateList = dictionaryRepository.findAllByCategoryName("US_CONSULATE");
|
||||||
|
List<Dictionary> statusList = dictionaryRepository.findAllByCategoryName("VISA_STATUS");
|
||||||
|
|
||||||
|
List<CaseStatusConsulateSummaryReport> 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<Object[]> 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<CaseStatusVisaCategorySummaryReport> QueryCaseStatusVisaCategorySummaryReport(String monthKey) {
|
||||||
|
DateRange dateRange = DateRange.ofMonthKey(monthKey);
|
||||||
|
|
||||||
|
List<Dictionary> visaCategoryList = dictionaryRepository.findAllByCategoryName("VISA_TYPE");
|
||||||
|
List<Dictionary> statusList = dictionaryRepository.findAllByCategoryName("VISA_STATUS");
|
||||||
|
|
||||||
|
List<CaseStatusVisaCategorySummaryReport> 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<Object[]> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,17 +143,17 @@ public class UserService implements UserDetailsService {
|
||||||
"not found"));
|
"not found"));
|
||||||
|
|
||||||
if (user.getUserStatus() == UserStatus.NEEDVERIFY) {
|
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()) {
|
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);
|
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 user = userRepository.findByUserEmail(userEmail).orElseThrow(() -> new BaseException(Status.BAD_REQUEST,
|
||||||
"User is not exist"));
|
"User is not exist"));
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ public class UserService implements UserDetailsService {
|
||||||
|
|
||||||
emailService.sendChangePasswordEmailToUser(user, savedUserChangePassword.getChangePasswordCode());
|
emailService.sendChangePasswordEmailToUser(user, savedUserChangePassword.getChangePasswordCode());
|
||||||
|
|
||||||
|
return savedUserChangePassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeForgotPassword(ChangePasswordForgotRequest changePasswordForgotRequest) {
|
public void changeForgotPassword(ChangePasswordForgotRequest changePasswordForgotRequest) {
|
||||||
|
|
Loading…
Reference in New Issue