25 changed files with 263 additions and 22 deletions
@ -1,4 +1,4 @@ |
|||
package com.qs.serve.mbp.context; |
|||
package com.qs.serve.common.context; |
|||
|
|||
import lombok.experimental.UtilityClass; |
|||
|
@ -0,0 +1,27 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<parent> |
|||
<artifactId>cms-framework</artifactId> |
|||
<groupId>com.qs</groupId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>cms-framework-feign</artifactId> |
|||
|
|||
<properties> |
|||
<maven.compiler.source>8</maven.compiler.source> |
|||
<maven.compiler.target>8</maven.compiler.target> |
|||
</properties> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.qs</groupId> |
|||
<artifactId>cms-common</artifactId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
</project> |
@ -0,0 +1,21 @@ |
|||
package com.qs.serve.feign; |
|||
|
|||
import com.qs.serve.common.context.SecurityUserUtil; |
|||
import feign.RequestInterceptor; |
|||
import feign.RequestTemplate; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* @author YenHex |
|||
* @since 2025/4/17 |
|||
*/ |
|||
@Configuration |
|||
public class FeignRequestInterceptor implements RequestInterceptor { |
|||
|
|||
@Override |
|||
public void apply(RequestTemplate template) { |
|||
template.header("userId", SecurityUserUtil.getUserId()); |
|||
template.header("tenant-id", SecurityUserUtil.getTenant()); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,57 @@ |
|||
package com.qs.serve.framework.mvc; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.core.annotation.Order; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import javax.annotation.Resource; |
|||
import javax.servlet.*; |
|||
import javax.servlet.annotation.WebFilter; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletRequestWrapper; |
|||
import java.io.BufferedReader; |
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
|
|||
/** |
|||
* HttpServletRequest 过滤器 |
|||
* 解决: request.getInputStream()只能读取一次的问题 |
|||
* 目标: 流可重复读 |
|||
* @Author YenHex |
|||
* @Date 2021/4/9 |
|||
* @Version: 1.0 |
|||
**/ |
|||
@Slf4j |
|||
@Component |
|||
@WebFilter(filterName = "HttpServletRequestFilter", urlPatterns = "/") |
|||
@Order(10000) |
|||
public class HttpServletRequestFilter implements Filter{ |
|||
|
|||
@Override |
|||
public void init(FilterConfig filterConfig) throws ServletException { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { |
|||
filterChain.doFilter(servletRequest, servletResponse); |
|||
long endTime = System.currentTimeMillis(); |
|||
assert servletRequest instanceof HttpServletRequest; |
|||
HttpServletRequest request = (HttpServletRequest)servletRequest; |
|||
String url = request.getRequestURL().toString(); |
|||
String method = request.getMethod(); |
|||
String queryStr = request.getQueryString(); |
|||
log.info("url:{}",url); |
|||
} |
|||
|
|||
@Override |
|||
public void destroy() { |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.qs.serve.mbp.config.props; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Author: YenHex |
|||
* @Date: 2021/3/3 |
|||
* @Version: 1.0 |
|||
**/ |
|||
@Getter |
|||
@Setter |
|||
@Component |
|||
@ConfigurationProperties(prefix = "project.tenant") |
|||
public class ProjectTenantProperties { |
|||
|
|||
private Boolean enable; |
|||
|
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.qs.serve.modules.tzc.api; |
|||
|
|||
import com.qs.serve.modules.tzc.entity.TzcRebate; |
|||
import com.qs.serve.modules.tzc.service.TzcRebateService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* @author YenHex |
|||
* @since 2025/4/17 |
|||
*/ |
|||
@Service |
|||
public class TzcRebateApiImpl implements TzcRebateApi { |
|||
|
|||
TzcRebateService tzcRebateService; |
|||
|
|||
@Override |
|||
public TzcRebate getRebateById(Long id) { |
|||
return tzcRebateService.getById(id); |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue