当前位置:网站首页>基于微信小程序的青少年生理健康知识小助手(免费获取源码+项目介绍+运行介绍+运行截图+论文)
基于微信小程序的青少年生理健康知识小助手(免费获取源码+项目介绍+运行介绍+运行截图+论文)
2022-07-01 05:30:00 【azhou的代码园】
技术架构
后端:JDK1.8+SingBoot+SpringMVC
前端:WXML+WXSS +css +js
数据库:MySQL
功能模块
前台用户:
用户登录
个人中心
心理测评
客服服务
青少年生理健康百科知识
后台管理员:
注册管理
心理测评管理
用户管理
青少年健康百科知识管理
代码展示:
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
var sessionKey = app.globalData.sessionKey;
console.log("userInfo", res.userInfo)
app.globalData.userInfo = res.userInfo
this.setData({
'userInfo': res.userInfo,
'hiddenName': true
})
wx.request({
url: 'http://localhost:8080/wx/getUserInfo',
header: {
"accept": "*/*",
'Content-Type': 'application/x-www-form-urlencoded',
},
data: {
'encryptedData': res.encryptedData,
'iv': res.iv,
'sessionKey': sessionKey,
},
method: 'POST',
success(res) {
console.log("userInfo:", res)
}
})
}
package com.azhou.code.aop;
import com.azhou.code.annotations.Limit;
import com.azhou.code.common.exception.MyException;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.RateLimiter;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.Map;
/**
* @description: 限流aop
* @author: azhou
* @Create: 2022-05-29 12:40
*/
@Slf4j
@Aspect
@Component
public class LimitAop {
private final Map<String, RateLimiter> limiterMap = Maps.newConcurrentMap();
@Around("@annotation(com.azhou.code.annotations.Limit)")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
// 拿limit的注解
Limit limit = method.getAnnotation(Limit.class);
if (limit != null) {
// key作用:不同的接口,不同的流量控制
String key = limit.key();
RateLimiter rateLimiter = null;
// 验证缓存是否有命中key
if (!limiterMap.containsKey(key)) {
// 创建令牌桶
rateLimiter = RateLimiter.create(limit.permitsPerSecond());
limiterMap.put(key, rateLimiter);
log.debug("新建了令牌桶={},容量={}", key, limit.permitsPerSecond());
}
rateLimiter = limiterMap.get(key);
// 拿令牌
boolean acquire = rateLimiter.tryAcquire(limit.timeout(), limit.timeunit());
// 拿不到命令,直接返回异常提示
if (!acquire) {
log.warn("令牌桶={},获取令牌失败", key);
throw new MyException(limit.msg());
}
}
return joinPoint.proceed();
}
}






边栏推荐
- 0xc000007b应用程序无法正常启动解决方案(亲测有效)
- Global and Chinese markets of superconductor 2022-2028: Research Report on technology, participants, trends, market size and share
- Speed regulation and stroke control based on Ti drv8424 driving stepper motor
- 数字金额加逗号;js给数字加三位一逗号间隔的两种方法;js数据格式化
- RecycleView的一些使用
- C# wpf 使用DockPanel实现截屏框
- Daily code 300 lines learning notes day 11
- Usage and principle of synchronized
- Common solutions for mobile terminals
- Software intelligence: the "world" and "boundary" of AI sentient beings in AAAs system
猜你喜欢

Rainbond结合NeuVector实践容器安全管理

Practice of combining rook CEPH and rainbow, a cloud native storage solution

多表操作-外键级联操作

Leetcode top 100 questions 1 Sum of two numbers

Copier le matériel de conseils de bébé ne peut pas être vide, comment résoudre?

了解 JVM 中几个相关问题 — JVM 内存布局、类加载机制、垃圾回收

Spanner 论文小结

Typeorm framework

Understand several related problems in JVM - JVM memory layout, class loading mechanism, garbage collection

Ebpf cilium practice (2) - underlying network observability
随机推荐
[SRS] use of Vhost isolated stream: push / pull Stream Address
QT waiting box production
如何选择导电滑环材料
Speed regulation and stroke control based on Ti drv8424 driving stepper motor
el-cascader回显失败;el-cascader回显不出来
了解 JVM 中几个相关问题 — JVM 内存布局、类加载机制、垃圾回收
Simple read / write verification of qdatastream
Precautions for use of conductive slip ring
How to select conductive slip ring material
[Yugong series] February 2022 Net architecture class 005 ABP vNext Net core web application getting started configuration
Use and principle of Park unpark
Unity项目心得总结
Global and Chinese markets of gps/gnss receiver modules 2022-2028: Research Report on technology, participants, trends, market size and share
复制宝贝提示材质不能为空,如何解决?
导电滑环短路的原因以及应对措施
Rust基础入门之变量绑定与解构
导电滑环使用的注意事项
【QT】qt加减乘除之后,保留小数点后两位
Data consistency between redis and database
Global and Chinese market of solder wire 2022-2028: Research Report on technology, participants, trends, market size and share