Compare commits
2 Commits
56740f6efa
...
3ee8435b2c
Author | SHA1 | Date |
---|---|---|
|
3ee8435b2c | 10 months ago |
|
60700d689f | 10 months ago |
@ -0,0 +1,7 @@
|
||||
FROM openjdk:8u332-jre-slim-bullseye AS runner
|
||||
WORKDIR /root
|
||||
ENV TZ=Asia/Shanghai
|
||||
COPY ./target/gw-charge.jar /root/gw-charge.jar
|
||||
ENV JAVA_OPTS="-server -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 "
|
||||
ENV ENV_OPTS="-Dspring.profiles.active=test"
|
||||
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS $ENV_OPTS -Djava.security.egd=file:/dev/./urandom -jar /root/gw-charge.jar" ]
|
@ -0,0 +1 @@
|
||||
小程序网关服务
|
@ -0,0 +1,20 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: gw-charge
|
||||
name: gw-charge
|
||||
namespace: yibin-charge
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 7001
|
||||
protocol: TCP
|
||||
targetPort: 7001
|
||||
nodePort: 30701
|
||||
selector:
|
||||
app: gw-charge
|
||||
tier: backend
|
||||
sessionAffinity: None
|
||||
type: NodePort
|
||||
|
@ -0,0 +1,56 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: gw-charge
|
||||
tier: backend
|
||||
name: gw-charge
|
||||
namespace: yibin-charge
|
||||
spec:
|
||||
progressDeadlineSeconds: 600
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gw-charge
|
||||
tier: backend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gw-charge
|
||||
tier: backend
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: CACHE_IGNORE
|
||||
value: js|html
|
||||
- name: CACHE_PUBLIC_EXPIRATION
|
||||
value: 3d
|
||||
- name: LANG
|
||||
value: C.UTF-8
|
||||
- name: JAVA_OPTS
|
||||
value: '-Dspring.profiles.active=test'
|
||||
image: $REGISTRY_HARBOR/$REGISTRY_HARBOR_NAMESPACE/gw-charge:latest
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 7001
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 30
|
||||
periodSeconds: 5
|
||||
imagePullPolicy: Always
|
||||
name: gw-charge
|
||||
ports:
|
||||
- containerPort: 7001
|
||||
protocol: TCP
|
||||
resources:
|
||||
limits:
|
||||
cpu: 300m
|
||||
memory: 600Mi
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
terminationGracePeriodSeconds: 30
|
@ -0,0 +1,73 @@
|
||||
<?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>
|
||||
<groupId>com.icharge.framework</groupId>
|
||||
<artifactId>rough-dependencies</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>gw-charge</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>gw-charge</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zuul</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-json</artifactId>
|
||||
<version>5.8.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- dinger组件-->
|
||||
<dependency>
|
||||
<groupId>com.github.answerail</groupId>
|
||||
<artifactId>dinger-spring-boot-starter</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.7.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>gw-charge</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
FROM frolvlad/alpine-oraclejre8:8.202.08-slim
|
||||
VOLUME /tmp
|
||||
ADD gw-charge.jar app.jar
|
||||
RUN sh -c 'touch /app.jar'
|
||||
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo Asia/Shanghai > /etc/timezone
|
||||
ENV JAVA_OPTS=""
|
||||
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
|
@ -0,0 +1,35 @@
|
||||
package com.i100c.charge.gw;
|
||||
|
||||
import com.i100c.charge.gw.filter.CorsFilter;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
@EnableZuulProxy
|
||||
public class GwApplication {
|
||||
|
||||
|
||||
@RequestMapping("/")
|
||||
public String index() {
|
||||
return "Hello, gw-charge";
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GwApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean filterRegist() {
|
||||
FilterRegistrationBean frBean = new FilterRegistrationBean();
|
||||
frBean.setFilter(new CorsFilter());
|
||||
frBean.addUrlPatterns("/*");
|
||||
return frBean;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.i100c.charge.gw.filter;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@WebFilter(urlPatterns = "/*")
|
||||
public class CorsFilter implements Filter {
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse res,
|
||||
FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletResponse response = (HttpServletResponse) res;
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
String uri = request.getRequestURI();
|
||||
request.getServerName();
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
||||
response.setHeader("Access-Control-Max-Age", "3600");
|
||||
response.setHeader("Access-Control-Allow-Headers", "Content-Type, x-requested-with, X-Custom-Header, Authorization,type");
|
||||
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
return;
|
||||
}
|
||||
chain.doFilter(req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
package com.i100c.charge.gw.filter;
|
||||
|
||||
import com.i100c.charge.gw.service.AsyncTask;
|
||||
import com.i100c.charge.gw.service.TokenService;
|
||||
import com.i100c.charge.gw.util.JwtUtil;
|
||||
import com.netflix.zuul.ZuulFilter;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "jwt.filter")
|
||||
public class ZuulPreFilter extends ZuulFilter {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ZuulPreFilter.class);
|
||||
|
||||
|
||||
@Value("${jwt.secret}")
|
||||
private String secret;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Autowired
|
||||
private AsyncTask asyncTask;
|
||||
|
||||
List<String> should_not_filter = new ArrayList<>();
|
||||
|
||||
List<String> no_access_filter = new ArrayList<>();
|
||||
|
||||
public List<String> getNo_access_filter() {
|
||||
return no_access_filter;
|
||||
}
|
||||
|
||||
public void setNo_access_filter(List<String> no_access_filter) {
|
||||
this.no_access_filter = no_access_filter;
|
||||
}
|
||||
|
||||
public List<String> getShould_not_filter() {
|
||||
return should_not_filter;
|
||||
}
|
||||
|
||||
|
||||
public void setShould_not_filter(List<String> should_not_filter) {
|
||||
this.should_not_filter = should_not_filter;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
ArrayList<String> newList = new ArrayList<>();
|
||||
for (String s : should_not_filter) {
|
||||
newList.add(s.replaceAll("\\*\\*", "[^\\\\s]*"));
|
||||
}
|
||||
this.should_not_filter = newList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filterType() {
|
||||
return "pre";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int filterOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldFilter() {
|
||||
RequestContext currentContext = RequestContext.getCurrentContext();
|
||||
HttpServletRequest request = currentContext.getRequest();
|
||||
String path = request.getRequestURI();
|
||||
String contextPath = request.getContextPath();
|
||||
String pathInfo = path.replaceFirst(contextPath, "");
|
||||
boolean matches = false;
|
||||
for (String s : should_not_filter) {
|
||||
Pattern pattern = Pattern.compile(s);
|
||||
Matcher matcher = pattern.matcher(pathInfo);
|
||||
matches = matcher.find();
|
||||
if (matches) break;
|
||||
}
|
||||
return !matches;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object run() {
|
||||
RequestContext ctx = RequestContext.getCurrentContext();
|
||||
Map<String, List<String>> requestQueryParams = ctx.getRequestQueryParams();
|
||||
HttpServletRequest request = ctx.getRequest();
|
||||
String Authorization = request.getHeader("Authorization");
|
||||
String uri = ctx.getRequest().getRequestURI();
|
||||
logger.info("请求api:{}", uri);
|
||||
if ("OPTIONS".equalsIgnoreCase(request.getMethod().toUpperCase())) {
|
||||
ctx.getResponse().setStatus(HttpServletResponse.SC_OK);
|
||||
return ctx.getResponse();
|
||||
}
|
||||
if (Authorization == null || Authorization.length() == 0) {
|
||||
ctx.setSendZuulResponse(false);
|
||||
ctx.setResponseBody("{\"msg\":\"凭证过期\" ,\"code\":1002}");
|
||||
ctx.getResponse().setContentType("text/json; charset=utf-8");
|
||||
ctx.setResponseStatusCode(200);
|
||||
return ctx.getResponse();
|
||||
}
|
||||
|
||||
String token = Authorization.replaceFirst(JwtUtil.AUTHORIZATION_STARTER, "");
|
||||
Claims cs = JwtUtil.getClaimsFromToken(token, secret);
|
||||
|
||||
if (cs == null || cs.size() == 0) {
|
||||
ctx.setSendZuulResponse(false);
|
||||
ctx.setResponseBody("{\"msg\":\"凭证有误\" ,\"code\":1002}");
|
||||
ctx.getResponse().setContentType("text/json; charset=utf-8");
|
||||
ctx.setResponseStatusCode(200);
|
||||
return ctx.getResponse();
|
||||
}
|
||||
|
||||
String userId = (String) cs.get(JwtUtil.CLAIM_KEY_USERID);
|
||||
String phone = (String) cs.get(JwtUtil.CLAIM_KEY_PHONE);
|
||||
String type = (String) cs.get(JwtUtil.CLAIM_KEY_TYPE);
|
||||
|
||||
|
||||
//验证数据是否过期
|
||||
String tokenkey = "";
|
||||
if (StringUtils.isEmpty(type)) {
|
||||
tokenkey = TokenService.ONLINE_USER + userId + phone;
|
||||
} else {
|
||||
tokenkey = TokenService.ONLINE_USER + type + userId + phone;
|
||||
}
|
||||
|
||||
String checkToken = tokenService.getToken(tokenkey);
|
||||
if (StringUtils.isEmpty(checkToken)) {
|
||||
ctx.setSendZuulResponse(false);
|
||||
ctx.setResponseBody("{\"msg\":\"凭证过期\" ,\"code\":1002}");
|
||||
ctx.getResponse().setContentType("text/json; charset=utf-8");
|
||||
ctx.setResponseStatusCode(200);
|
||||
return ctx.getResponse();
|
||||
} else {
|
||||
if (checkToken.equals(Authorization)) {
|
||||
// tokenService.freshTime(TokenService.ONLINE_USER+userId);
|
||||
} else {
|
||||
ctx.setSendZuulResponse(false);
|
||||
ctx.setResponseBody("{\"msg\":\"凭证过期请重新登录\" ,\"code\":1002}");
|
||||
ctx.getResponse().setContentType("text/json; charset=utf-8");
|
||||
ctx.setResponseStatusCode(200);
|
||||
return ctx.getResponse();
|
||||
}
|
||||
}
|
||||
Map<String, String> zuulRequestHeaders = ctx.getZuulRequestHeaders();
|
||||
zuulRequestHeaders.put("phone", phone);
|
||||
zuulRequestHeaders.put("userId", userId);
|
||||
ctx.setZuulEngineRan();
|
||||
//记录用户活跃信息
|
||||
asyncTask.setLoginFlag(userId);
|
||||
return ctx.getResponse();
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.i100c.charge.gw.filter;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
|
||||
@Component
|
||||
public class ZuulRoutingFilter extends com.netflix.zuul.ZuulFilter {
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filterType() {
|
||||
return "routing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int filterOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldFilter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object run() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.i100c.charge.gw.model;
|
||||
|
||||
public class CommonResponse {
|
||||
|
||||
private Integer code; //返回码
|
||||
private String msg; //返回提示信息
|
||||
private Object extraInfo;
|
||||
private Object data; //返回数据
|
||||
|
||||
|
||||
public Object getExtraInfo() {
|
||||
return extraInfo;
|
||||
}
|
||||
|
||||
public void setExtraInfo(Object extraInfo) {
|
||||
this.extraInfo = extraInfo;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.i100c.charge.gw.model;
|
||||
|
||||
|
||||
|
||||
public class I100cResponse {
|
||||
|
||||
/**
|
||||
* 请求返回数据处理
|
||||
*/
|
||||
public static CommonResponse general(CommonResponse res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功请求
|
||||
*/
|
||||
public static CommonResponse success(Object data) {
|
||||
CommonResponse res = new CommonResponse();
|
||||
res.setCode(1000);
|
||||
res.setMsg("请求成功");
|
||||
res.setData(data);
|
||||
return general(res);
|
||||
}
|
||||
|
||||
public static CommonResponse success() {
|
||||
CommonResponse res = new CommonResponse();
|
||||
res.setCode(1000);
|
||||
res.setMsg("请求成功");
|
||||
return general(res);
|
||||
}
|
||||
|
||||
public static CommonResponse success(String msg) {
|
||||
CommonResponse res = new CommonResponse();
|
||||
res.setCode(1000);
|
||||
res.setMsg(msg);
|
||||
return general(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求抛出异常
|
||||
*/
|
||||
public static CommonResponse exception(String msg) {
|
||||
CommonResponse res = new CommonResponse();
|
||||
res.setCode(1001);
|
||||
res.setMsg(msg);
|
||||
return general(res);
|
||||
}
|
||||
|
||||
public static CommonResponse exception(String msg, int errorCode) {
|
||||
CommonResponse res = new CommonResponse();
|
||||
res.setCode(errorCode);
|
||||
res.setMsg(msg);
|
||||
return general(res);
|
||||
}
|
||||
|
||||
public static CommonResponse exception(String msg, int errorCode, Object extraInfo) {
|
||||
CommonResponse res = new CommonResponse();
|
||||
res.setCode(errorCode);
|
||||
res.setMsg(msg);
|
||||
res.setExtraInfo(extraInfo);
|
||||
return general(res);
|
||||
}
|
||||
|
||||
public static CommonResponse exception(String msg, Object data) {
|
||||
CommonResponse res = new CommonResponse();
|
||||
res.setCode(1001);
|
||||
res.setMsg(msg);
|
||||
res.setData(data);
|
||||
return general(res);
|
||||
}
|
||||
|
||||
public static CommonResponse unKonwException() {
|
||||
CommonResponse res = new CommonResponse();
|
||||
res.setCode(1001);
|
||||
res.setMsg("请稍后再试");
|
||||
return general(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义
|
||||
*/
|
||||
public static CommonResponse custom(Integer code, String msg) {
|
||||
CommonResponse res = new CommonResponse();
|
||||
res.setCode(code);
|
||||
res.setMsg(msg);
|
||||
return general(res);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.i100c.charge.gw.service;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Created by
|
||||
*
|
||||
* @author Administrator on
|
||||
* @date 2018/9/14.
|
||||
*/
|
||||
@Component
|
||||
public class AsyncTask {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AsyncTask.class);
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Async
|
||||
public void setLoginFlag(String userId) {
|
||||
try{
|
||||
tokenService.setLoginFlag(userId);
|
||||
}catch (Exception e){
|
||||
logger.error("setLogin Flag error userId:{} "+e,userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.i100c.charge.gw.service;
|
||||
|
||||
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class TokenService {
|
||||
public static final String ONLINE_USER = "online_user:";
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
public void setToken(String key, String token) {
|
||||
ValueOperations<String, String> value = redisTemplate.opsForValue();
|
||||
value.set(ONLINE_USER + key, token);
|
||||
}
|
||||
|
||||
public void freshTime(String key) {
|
||||
redisTemplate.expire(key, 10, TimeUnit.DAYS);
|
||||
}
|
||||
|
||||
public String getToken(String key) {
|
||||
return redisTemplate.boundValueOps(key).get();
|
||||
}
|
||||
|
||||
public void setLoginFlag(String userId) {
|
||||
Date date =new Date();
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
String nowdayTime = dateFormat.format(date);
|
||||
redisTemplate.opsForValue().setBit("LOGIN_DATE:"+nowdayTime, Long.valueOf(userId), true);
|
||||
|
||||
DateFormat dateFormat2 = new SimpleDateFormat("yyyyMMddHH");
|
||||
String nowdayTime2 = dateFormat2.format(date);
|
||||
redisTemplate.opsForValue().setBit("LOGIN_DATE:"+nowdayTime2, Long.valueOf(userId), true);
|
||||
|
||||
DateFormat dateFormat3 = new SimpleDateFormat("yyyyMM");
|
||||
String nowdayTime3 = dateFormat3.format(date);
|
||||
redisTemplate.opsForValue().setBit("LOGIN_DATE:"+nowdayTime3, Long.valueOf(userId), true);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
spring:
|
||||
application:
|
||||
name: gw-charge
|
||||
|
||||
profiles:
|
||||
active: dev
|
||||
http:
|
||||
multipart:
|
||||
enabled: true
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
|
||||
server:
|
||||
port: 7001
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
e1779179d92d48ff84fbc9ddf72ed1f1
|
@ -0,0 +1 @@
|
||||
fc4879a8afdcbd08da717b1a56cb41c9
|
After Width: | Height: | Size: 9.4 KiB |
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<script>
|
||||
!(function(n, e) {
|
||||
var t = n.documentElement,
|
||||
i = 'orientationchange' in window ? 'orientationchange' : 'resize',
|
||||
d = function() {
|
||||
var n = t.clientWidth;
|
||||
n &&
|
||||
(t.style.fontSize = 750 <= n ? '100px' : (n / 750) * 100 + 'px');
|
||||
};
|
||||
n.addEventListener &&
|
||||
(e.addEventListener(i, d, !1),
|
||||
n.addEventListener('DOMContentLoaded', d, !1));
|
||||
})(document, window);
|
||||
</script>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
|
||||
/>
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<link rel="manifest" href="./manifest.json" />
|
||||
<link rel="shortcut icon" href="./favicon.ico" />
|
||||
<title>充儿使用帮助</title>
|
||||
<link href="./static/css/main.8bedb333.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="text/javascript" src="./static/js/main.f2765746.js"></script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
e8d5c4084b62c6efbab2a046958aba27
|
After Width: | Height: | Size: 4.4 KiB |
Loading…
Reference in new issue