parent
7c4090c0fb
commit
239810a5e6
|
@ -1,39 +0,0 @@
|
||||||
package com.northtecom.visatrack.api.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
|
||||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
||||||
import org.springframework.web.filter.CorsFilter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created with IntelliJ IDEA.
|
|
||||||
*
|
|
||||||
* @Author: XieYang
|
|
||||||
* @Date: 2022/10/15/17:31
|
|
||||||
* @Description:
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class GlobalCorsConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CorsFilter corsFilter() {
|
|
||||||
//1. 添加 CORS配置信息
|
|
||||||
CorsConfiguration config = new CorsConfiguration();
|
|
||||||
//放行哪些原始域
|
|
||||||
config.addAllowedOrigin("*");
|
|
||||||
//是否发送 Cookie
|
|
||||||
config.setAllowCredentials(true);
|
|
||||||
//放行哪些请求方式
|
|
||||||
config.addAllowedMethod("*");
|
|
||||||
//放行哪些原始请求头部信息
|
|
||||||
config.addAllowedHeader("*");
|
|
||||||
//暴露哪些头部信息
|
|
||||||
config.addExposedHeader("*");
|
|
||||||
//2. 添加映射路径
|
|
||||||
UrlBasedCorsConfigurationSource corsConfigurationSource = new UrlBasedCorsConfigurationSource();
|
|
||||||
corsConfigurationSource.registerCorsConfiguration("/**", config);
|
|
||||||
//3. 返回新的CorsFilter
|
|
||||||
return new CorsFilter(corsConfigurationSource);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -13,6 +13,10 @@ import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.security.web.access.AccessDeniedHandler;
|
import org.springframework.security.web.access.AccessDeniedHandler;
|
||||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||||
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
|
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created with IntelliJ IDEA.
|
* Created with IntelliJ IDEA.
|
||||||
|
@ -51,7 +55,8 @@ public class SpringSecurityConfig {
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
|
||||||
|
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
httpSecurity.cors()
|
httpSecurity
|
||||||
|
.cors().configurationSource(request -> corsConfiguration())
|
||||||
// 关闭 CSRF
|
// 关闭 CSRF
|
||||||
.and().csrf().disable()
|
.and().csrf().disable()
|
||||||
// 登录行为由自己实现,参考 AuthController#login
|
// 登录行为由自己实现,参考 AuthController#login
|
||||||
|
@ -68,13 +73,19 @@ public class SpringSecurityConfig {
|
||||||
httpSecurity.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
httpSecurity.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return httpSecurity.build();
|
return httpSecurity.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CorsConfiguration corsConfiguration() {
|
||||||
|
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||||
|
corsConfiguration.setAllowedOrigins(Arrays.asList("*"));
|
||||||
|
corsConfiguration.setAllowedMethods(Arrays.asList("*"));
|
||||||
|
corsConfiguration.setAllowedHeaders(Arrays.asList("*"));
|
||||||
|
corsConfiguration.setMaxAge(3600L);
|
||||||
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
|
source.registerCorsConfiguration("/**", corsConfiguration);
|
||||||
|
return corsConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.northtecom.visatrack.api.controller.api;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Author: XieYang
|
||||||
|
* @Date: 2022/10/16/8:06
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(BlogController.BASE_URL)
|
||||||
|
@Tag(name = BlogController.TAG_NAME, description = BlogController.TAG_DESCRIPTION)
|
||||||
|
public class BlogController {
|
||||||
|
|
||||||
|
protected static final String DATA_NAME = "博客数据";
|
||||||
|
protected static final String BASE_URL = "/api/blog";
|
||||||
|
protected static final String TAG_NAME = "Blog";
|
||||||
|
protected static final String TAG_DESCRIPTION = DATA_NAME + "管理API";
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.northtecom.visatrack.api.controller.api;
|
||||||
|
|
||||||
|
import com.northtecom.visatrack.api.controller.vo.AllReportDataSummary;
|
||||||
|
import com.northtecom.visatrack.api.controller.vo.MonthlyReportDataSummary;
|
||||||
|
import com.northtecom.visatrack.api.data.entity.CaseVisaReport;
|
||||||
|
import com.northtecom.visatrack.api.service.impl.CaseVisaReportService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Author: XieYang
|
||||||
|
* @Date: 2022/10/16/8:06
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(CaseVisaReportReportController.BASE_URL)
|
||||||
|
@Tag(name = CaseVisaReportReportController.TAG_NAME, description = CaseVisaReportReportController.TAG_DESCRIPTION)
|
||||||
|
public class CaseVisaReportReportController {
|
||||||
|
protected static final String DATA_NAME = "签证报表数据";
|
||||||
|
protected static final String BASE_URL = "/api/visa_report";
|
||||||
|
protected static final String TAG_NAME = "CaseVisaReport";
|
||||||
|
protected static final String TAG_DESCRIPTION = DATA_NAME + "管理API";
|
||||||
|
|
||||||
|
private final CaseVisaReportService caseVisaReportService;
|
||||||
|
|
||||||
|
public CaseVisaReportReportController(CaseVisaReportService caseVisaReportService) {
|
||||||
|
this.caseVisaReportService = caseVisaReportService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/QueryAllReportData")
|
||||||
|
@Operation(summary = "查询所有报表数据", description = "查询首页所有报表数据")
|
||||||
|
public AllReportDataSummary QueryAllReportData() {
|
||||||
|
List<CaseVisaReport> caseVisaReportList = this.caseVisaReportService.QueryAllReportData();
|
||||||
|
AllReportDataSummary allReportDataSummary = new AllReportDataSummary(caseVisaReportList);
|
||||||
|
return new AllReportDataSummary(caseVisaReportList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/QueryMonthlyReportData")
|
||||||
|
@Operation(summary = "按月查询报表数据", description = "按月查询报表数据,月份的格式为 yyyy-MM 例如 2022-10")
|
||||||
|
public MonthlyReportDataSummary QueryAllReportData(String monthKey) {
|
||||||
|
return new MonthlyReportDataSummary();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.northtecom.visatrack.api.controller.vo;
|
||||||
|
|
||||||
|
import com.northtecom.visatrack.api.data.entity.CaseVisaReport;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Author: XieYang
|
||||||
|
* @Date: 2022/10/16/8:13
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AllReportDataSummary {
|
||||||
|
private List<ReportDataSummaryItem> items;
|
||||||
|
private ReportDataSummaryItem summaryItem;
|
||||||
|
|
||||||
|
public AllReportDataSummary() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AllReportDataSummary(List<CaseVisaReport> 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());
|
||||||
|
}
|
||||||
|
this.items.add(reportDataSummaryItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.northtecom.visatrack.api.controller.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Author: XieYang
|
||||||
|
* @Date: 2022/10/16/8:19
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MonthlyReportDataSummary {
|
||||||
|
private ReportDataSummaryItem summaryItem;
|
||||||
|
private List<ReportDataVisaCategorySummaryItem> categorySummaryItem;
|
||||||
|
private List<ReportDataVisaConsulateSummaryItem> consulateSummaryItem;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.northtecom.visatrack.api.controller.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Author: XieYang
|
||||||
|
* @Date: 2022/10/16/8:14
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportDataSummaryItem {
|
||||||
|
private String month;
|
||||||
|
private Integer pendingCaseCount;
|
||||||
|
private Integer clearCaseCount;
|
||||||
|
private Integer rejectCaseCount;
|
||||||
|
private Integer totalCaseCount;
|
||||||
|
private String AveWaitingDaysForCompleteCases;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.northtecom.visatrack.api.controller.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Author: XieYang
|
||||||
|
* @Date: 2022/10/16/8:23
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportDataVisaCategorySummaryItem {
|
||||||
|
private String month;
|
||||||
|
private String category;
|
||||||
|
private Integer pendingCaseCount;
|
||||||
|
private Integer clearCaseCount;
|
||||||
|
private Integer rejectCaseCount;
|
||||||
|
private Integer totalCaseCount;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.northtecom.visatrack.api.controller.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Author: XieYang
|
||||||
|
* @Date: 2022/10/16/8:23
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportDataVisaConsulateSummaryItem {
|
||||||
|
private String month;
|
||||||
|
private String consulate;
|
||||||
|
private Integer pendingCaseCount;
|
||||||
|
private Integer clearCaseCount;
|
||||||
|
private Integer rejectCaseCount;
|
||||||
|
private Integer totalCaseCount;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.northtecom.visatrack.api.service.impl;
|
||||||
|
|
||||||
|
import com.northtecom.visatrack.api.data.entity.CaseVisaReport;
|
||||||
|
import com.northtecom.visatrack.api.data.repository.CaseVisaReportRepository;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with IntelliJ IDEA.
|
||||||
|
*
|
||||||
|
* @Author: XieYang
|
||||||
|
* @Date: 2022/10/16/8:33
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class CaseVisaReportService {
|
||||||
|
|
||||||
|
private final CaseVisaReportRepository caseVisaReportRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public CaseVisaReportService(CaseVisaReportRepository caseVisaReportRepository) {
|
||||||
|
this.caseVisaReportRepository = caseVisaReportRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CaseVisaReport> QueryAllReportData() {
|
||||||
|
return (List<CaseVisaReport>) this.caseVisaReportRepository.findAll();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue