parent
3f6abd6793
commit
dce77d64af
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SonarLintProjectSettings">
|
||||
<option name="moduleMapping">
|
||||
<map>
|
||||
<entry key="file" value="oss" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@ -1,15 +1,14 @@
|
||||
package com.flyingpig.cloudmusic;
|
||||
package com.flyingpig.cloudmusic.auth;
|
||||
|
||||
import com.flyingpig.cloudmusic.config.MvcConfig;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
|
||||
@Import(MvcConfig.class)
|
||||
@EnableSwagger2
|
||||
@SpringBootApplication(scanBasePackages = "com.flyingpig")
|
||||
@SpringBootApplication
|
||||
@EnableAsync
|
||||
public class AuthApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -1,4 +1,4 @@
|
||||
package com.flyingpig.cloudmusic.config;
|
||||
package com.flyingpig.cloudmusic.auth.config;
|
||||
|
||||
import com.alibaba.fastjson.support.spring.FastJsonRedisSerializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -0,0 +1,29 @@
|
||||
package com.flyingpig.cloudmusic.auth.config;
|
||||
|
||||
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.config.Config;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class RedissonConfig {
|
||||
|
||||
@Value("${spring.redis.host:localhost}")
|
||||
private String redisHost;
|
||||
|
||||
|
||||
@Value("${spring.redis.port:6379}")
|
||||
private int redisPort;
|
||||
|
||||
@Bean
|
||||
public RedissonClient redissonClient() {
|
||||
// 配置
|
||||
Config config = new Config();
|
||||
config.useSingleServer().setAddress("redis://" + redisHost + ":" + redisPort);
|
||||
// 创建RedissonClient对象
|
||||
return Redisson.create(config);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.flyingpig.cloudmusic.config;
|
||||
package com.flyingpig.cloudmusic.auth.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -0,0 +1,16 @@
|
||||
package com.flyingpig.cloudmusic.auth.constant;
|
||||
|
||||
public class RedisConstants {
|
||||
|
||||
public static final String USER_INFO_KEY="user:info:";
|
||||
|
||||
public static final Long USER_INFO_TTL=30L;
|
||||
|
||||
public static final String USER_LOGIN_KEY="user:login:";
|
||||
|
||||
public static final Long USER_LOGIN_TTL = 30L;
|
||||
|
||||
public static final String EMAIL_VERIFYCODE_KEY="email:verifycode:";
|
||||
|
||||
public static final Long EMAIL_VERIFYCODE_TTL=120L;
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package com.flyingpig.cloudmusic.auth.controller;
|
||||
|
||||
|
||||
import com.flyingpig.cloudmusic.auth.constant.RedisConstants;
|
||||
import com.flyingpig.cloudmusic.auth.dataobject.entity.User;
|
||||
import com.flyingpig.cloudmusic.auth.dataobject.vo.EmailRegisterVO;
|
||||
import com.flyingpig.cloudmusic.auth.service.UserService;
|
||||
import com.flyingpig.cloudmusic.auth.util.EmailUtil;
|
||||
import com.flyingpig.cloudmusic.web.Result;
|
||||
import com.flyingpig.cloudmusic.web.StatusCode;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/email")
|
||||
@Api("与邮件处理相关的api")
|
||||
@Slf4j
|
||||
public class MailController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
@Autowired
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Autowired
|
||||
PasswordEncoder passwordEncoder;
|
||||
|
||||
@GetMapping("/verificationCode")
|
||||
@ApiOperation("用户获取验证码")
|
||||
public Result sendEmailVerificationCode(String email) {
|
||||
//检查email是否符合格式
|
||||
if (!EmailUtil.judgeEmailFormat(email)) {
|
||||
return Result.error(StatusCode.SERVERERROR, "邮箱不符合格式");
|
||||
}
|
||||
userService.sendVerificationCode(email);
|
||||
return Result.success("验证码已发送");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/register")
|
||||
@ApiOperation("通过验证码完成注册")
|
||||
public Result emailRegister(@RequestBody EmailRegisterVO emailRegisterVO) {
|
||||
System.out.println(emailRegisterVO.getEmail());
|
||||
String verificationCode = stringRedisTemplate.opsForValue().get(RedisConstants.EMAIL_VERIFYCODE_KEY + emailRegisterVO.getEmail());
|
||||
System.out.println(verificationCode);
|
||||
if (verificationCode != null && verificationCode.equals(emailRegisterVO.getVerificationCode())) {
|
||||
// 添加用户
|
||||
userService.addUser(new User()
|
||||
.setUsername(emailRegisterVO.getUsername())
|
||||
.setPassword(passwordEncoder.encode(emailRegisterVO.getPassword()))
|
||||
.setEmail(emailRegisterVO.getEmail()));
|
||||
return Result.success("添加成功,请联系管理员审核");
|
||||
} else {
|
||||
return Result.error(StatusCode.SERVERERROR, "验证码验证错误");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
package com.flyingpig.cloudmusic.dataobject.dto;
|
||||
package com.flyingpig.cloudmusic.auth.dataobject.dto;
|
||||
|
||||
|
||||
import com.flyingpig.cloudmusic.dataobject.entity.User;
|
||||
import com.flyingpig.cloudmusic.auth.dataobject.entity.User;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.flyingpig.cloudmusic.dataobject.vo;
|
||||
package com.flyingpig.cloudmusic.auth.dataobject.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -1,7 +1,7 @@
|
||||
package com.flyingpig.cloudmusic.mapper;
|
||||
package com.flyingpig.cloudmusic.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.flyingpig.cloudmusic.dataobject.entity.User;
|
||||
import com.flyingpig.cloudmusic.auth.dataobject.entity.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
@ -1,10 +1,10 @@
|
||||
package com.flyingpig.cloudmusic.service.impl;
|
||||
package com.flyingpig.cloudmusic.auth.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.flyingpig.cloudmusic.dataobject.dto.LoginUser;
|
||||
import com.flyingpig.cloudmusic.dataobject.entity.User;
|
||||
import com.flyingpig.cloudmusic.mapper.UserMapper;
|
||||
import com.flyingpig.cloudmusic.auth.dataobject.entity.User;
|
||||
import com.flyingpig.cloudmusic.auth.mapper.UserMapper;
|
||||
import com.flyingpig.cloudmusic.auth.dataobject.dto.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.flyingpig.cloudmusic.util;
|
||||
package com.flyingpig.cloudmusic.auth.util;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
@ -0,0 +1,56 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.flyingpig.cloud-music</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>common-cache</artifactId>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
<version>2.0.53</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>6.2.5.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.28</version> <!-- 版本号可根据需要调整 -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<version>3.21.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -1,4 +1,4 @@
|
||||
package com.flyingpig.cloudmusic.util.cache;
|
||||
package com.flyingpig.cloudmusic.cache;
|
||||
|
||||
/**
|
||||
* 缓存加载器
|
||||
@ -0,0 +1,13 @@
|
||||
package com.flyingpig.cloudmusic.cache.config;
|
||||
|
||||
import com.flyingpig.cloudmusic.cache.StringCacheUtil;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class CacheAutoConfiguration {
|
||||
@Bean
|
||||
public StringCacheUtil stringCacheUtil() {
|
||||
return new StringCacheUtil();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.flyingpig.cloudmusic.cache.config.CacheAutoConfiguration
|
||||
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
@ -0,0 +1,35 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.flyingpig.cloud-music</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common-file</artifactId>
|
||||
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.15.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,13 @@
|
||||
package com.flyingpig.cloudmusic.file.config;
|
||||
|
||||
import com.flyingpig.cloudmusic.file.AliOSSUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class AutoFileConfiguration {
|
||||
@Bean
|
||||
public AliOSSUtils aliOSSUtils() {
|
||||
return new AliOSSUtils();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.flyingpig.cloudmusic.file.config.AutoFileConfiguration
|
||||
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
@ -0,0 +1,42 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.flyingpig.cloud-music</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<artifactId>common-idempotent</artifactId>
|
||||
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.flyingpig.cloud-music</groupId>
|
||||
<artifactId>common-cache</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.flyingpig.cloud-music</groupId>
|
||||
<artifactId>common-security</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,16 @@
|
||||
package com.flyingpig.cloudmusic.idempotent.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 幂等属性配置
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = IdempotentProperties.PREFIX)
|
||||
public class IdempotentProperties {
|
||||
|
||||
public static final String PREFIX = "flyingpig.idempotent.token";
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.flyingpig.cloudmusic.idempotent.core;
|
||||
|
||||
import com.flyingpig.cloudmusic.idempotent.annotation.Idempotent;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
|
||||
|
||||
public abstract class AbstractIdempotentExecuteHandler implements IdempotentExecuteHandler {
|
||||
|
||||
/**
|
||||
* 构建幂等验证过程中所需要的参数包装器
|
||||
*
|
||||
* @param joinPoint AOP 方法处理
|
||||
* @return 幂等参数包装器
|
||||
*/
|
||||
protected abstract IdempotentParamWrapper buildWrapper(ProceedingJoinPoint joinPoint);
|
||||
|
||||
/**
|
||||
* 执行幂等处理逻辑
|
||||
*
|
||||
* @param joinPoint AOP 方法处理
|
||||
* @param idempotent 幂等注解
|
||||
*/
|
||||
public void execute(ProceedingJoinPoint joinPoint, Idempotent idempotent) {
|
||||
// 模板方法模式:构建幂等参数包装器
|
||||
IdempotentParamWrapper idempotentParamWrapper = buildWrapper(joinPoint).setIdempotent(idempotent);
|
||||
handler(idempotentParamWrapper);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package com.flyingpig.cloudmusic.idempotent.core;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 幂等上下文
|
||||
*/
|
||||
public final class IdempotentContext {
|
||||
|
||||
private static final ThreadLocal<Map<String, Object>> CONTEXT = new ThreadLocal<>();
|
||||
|
||||
public static Map<String, Object> get() {
|
||||
return CONTEXT.get();
|
||||
}
|
||||
|
||||
public static Object getKey(String key) {
|
||||
Map<String, Object> context = get();
|
||||
if (CollUtil.isNotEmpty(context)) {
|
||||
return context.get(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getString(String key) {
|
||||
Object actual = getKey(key);
|
||||
if (actual != null) {
|
||||
return actual.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void put(String key, Object val) {
|
||||
// 获得上下文
|
||||
Map<String, Object> context = get();
|
||||
if (CollUtil.isEmpty(context)) {
|
||||
// 如果为空,创建一个新的上下文
|
||||
context = Maps.newHashMap();
|
||||
}
|
||||
// 锁
|
||||
context.put(key, val);
|
||||
putContext(context);
|
||||
}
|
||||
|
||||
public static void putContext(Map<String, Object> context) {
|
||||
// 获得上下文
|
||||
Map<String, Object> threadContext = CONTEXT.get();
|
||||
if (CollUtil.isNotEmpty(threadContext)) {
|
||||
// 如果不为空,放入所有的值
|
||||
threadContext.putAll(context);
|
||||
return;
|
||||
}
|
||||
// 设置上下文
|
||||
CONTEXT.set(context);
|
||||
}
|
||||
|
||||
public static void clean() {
|
||||
CONTEXT.remove();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.flyingpig.cloudmusic.idempotent.core;
|
||||
|
||||
import com.flyingpig.cloudmusic.idempotent.annotation.Idempotent;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
|
||||
/**
|
||||
* 幂等执行处理器
|
||||
*/
|
||||
public interface IdempotentExecuteHandler {
|
||||
|
||||
/**
|
||||
* 幂等处理逻辑
|
||||
*
|
||||
* @param wrapper 幂等参数包装器
|
||||
*/
|
||||
void handler(IdempotentParamWrapper wrapper);
|
||||
|
||||
/**
|
||||
* 执行幂等处理逻辑
|
||||
*
|
||||
* @param joinPoint AOP 方法处理
|
||||
* @param idempotent 幂等注解
|
||||
*/
|
||||
void execute(ProceedingJoinPoint joinPoint, Idempotent idempotent);
|
||||
|
||||
/**
|
||||
* 异常流程处理
|
||||
*/
|
||||
default void exceptionProcessing() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 后置处理
|
||||
*/
|
||||
default void postProcessing() {
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.flyingpig.cloudmusic.idempotent.core;
|
||||
|
||||
|
||||
import com.flyingpig.cloudmusic.idempotent.core.bases.ApplicationContextHolder;
|
||||
import com.flyingpig.cloudmusic.idempotent.core.param.IdempotentParamService;
|
||||
import com.flyingpig.cloudmusic.idempotent.core.spel.IdempotentSpELByMQExecuteHandler;
|
||||
import com.flyingpig.cloudmusic.idempotent.core.spel.IdempotentSpELByRestAPIExecuteHandler;
|
||||
import com.flyingpig.cloudmusic.idempotent.enums.IdempotentSceneEnum;
|
||||
import com.flyingpig.cloudmusic.idempotent.enums.IdempotentTypeEnum;
|
||||
|
||||
/**
|
||||
* 幂等执行处理器工厂
|
||||
*/
|
||||
public final class IdempotentExecuteHandlerFactory {
|
||||
|
||||
/**
|
||||
* 获取幂等执行处理器
|
||||
*
|
||||
* @param scene 指定幂等验证场景类型
|
||||
* @param type 指定幂等处理类型
|
||||
* @return 幂等执行处理器
|
||||
*/
|
||||
public static IdempotentExecuteHandler getInstance(IdempotentSceneEnum scene, IdempotentTypeEnum type) {
|
||||
IdempotentExecuteHandler result = null;
|
||||
switch (scene) {
|
||||
case RESTAPI:
|
||||
switch (type) {
|
||||
case PARAM:
|
||||
result = ApplicationContextHolder.getBean(IdempotentParamService.class);
|
||||
break;
|
||||
case SPEL:
|
||||
result = ApplicationContextHolder.getBean(IdempotentSpELByRestAPIExecuteHandler.class);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MQ:
|
||||
result = ApplicationContextHolder.getBean(IdempotentSpELByMQExecuteHandler.class);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.flyingpig.cloudmusic.idempotent.core;
|
||||
|
||||
import com.flyingpig.cloudmusic.idempotent.annotation.Idempotent;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
|
||||
/**
|
||||
* 幂等参数包装
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public final class IdempotentParamWrapper {
|
||||
|
||||
/**
|
||||
* 幂等注解
|
||||
*/
|
||||
private Idempotent idempotent;
|
||||
|
||||
/**
|
||||
* AOP 处理连接点
|
||||
*/
|
||||
private ProceedingJoinPoint joinPoint;
|
||||
|
||||
/**
|
||||
* 锁标识
|
||||
*/
|
||||
private String lockKey;
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.flyingpig.cloudmusic.idempotent.core.bases;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Application context holder.
|
||||
*/
|
||||
public class ApplicationContextHolder implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext CONTEXT;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
ApplicationContextHolder.CONTEXT = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ioc container bean by type.
|
||||
*/
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return CONTEXT.getBean(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ioc container bean by name.
|
||||
*/
|
||||
public static Object getBean(String name) {
|
||||
return CONTEXT.getBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ioc container bean by name and type.
|
||||
*/
|
||||
public static <T> T getBean(String name, Class<T> clazz) {
|
||||
return CONTEXT.getBean(name, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a set of ioc container beans by type.
|
||||
*/
|
||||
public static <T> Map<String, T> getBeansOfType(Class<T> clazz) {
|
||||
return CONTEXT.getBeansOfType(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find whether the bean has annotations.
|
||||
*/
|
||||
public static <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) {
|
||||
return CONTEXT.findAnnotationOnBean(beanName, annotationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get application context.
|
||||
*/
|
||||
public static ApplicationContext getInstance() {
|
||||
return CONTEXT;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.flyingpig.cloudmusic.idempotent.core.spel;
|
||||
|
||||
|
||||
import com.flyingpig.cloudmusic.idempotent.core.IdempotentExecuteHandler;
|
||||
|
||||
/**
|
||||
* SpEL 方式幂等实现接口
|
||||
*/
|
||||
public interface IdempotentSpELService extends IdempotentExecuteHandler {
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.flyingpig.cloudmusic.idempotent.enums;
|
||||
|
||||
/**
|
||||
* 幂等验证场景枚举
|
||||
*/
|
||||
public enum IdempotentSceneEnum {
|
||||
|
||||
/**
|
||||
* 基于 RestAPI 场景验证
|
||||
*/
|
||||
RESTAPI,
|
||||
|
||||
/**
|
||||
* 基于 MQ 场景验证
|
||||
*/
|
||||
MQ
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.flyingpig.cloudmusic.idempotent.enums;
|
||||
|
||||
/**
|
||||
* 幂等验证类型枚举
|
||||
*/
|
||||
public enum IdempotentTypeEnum {
|
||||
|
||||
/**
|
||||
* 基于 Token 方式验证
|
||||
*/
|
||||
TOKEN,
|
||||
|
||||
/**
|
||||
* 基于方法参数方式验证
|
||||
*/
|
||||
PARAM,
|
||||
|
||||
/**
|
||||
* 基于 SpEL 表达式方式验证
|
||||
*/
|
||||
SPEL
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.flyingpig.cloudmusic.idempotent.toolkit;
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 日志工具类
|
||||
*/
|
||||
public class LogUtil {
|
||||
|
||||
/**
|
||||
* 获取 Logger
|
||||
*/
|
||||
public static Logger getLog(ProceedingJoinPoint joinPoint) {
|
||||
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
|
||||
return LoggerFactory.getLogger(methodSignature.getDeclaringType());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.flyingpig.cloudmusic.idempotent.toolkit;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.core.DefaultParameterNameDiscoverer;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* SpEL 表达式解析工具
|
||||
*/
|
||||
public class SpELUtil {
|
||||
|
||||
/**
|
||||
* 校验并返回实际使用的 spEL 表达式
|
||||
*
|
||||
* @param spEl spEL 表达式
|
||||
* @return 实际使用的 spEL 表达式
|
||||
*/
|
||||
public static Object parseKey(String spEl, Method method, Object[] contextObj) {
|
||||
// 校验,是否包含 # 或 T(,如果包含则需要解析
|
||||
ArrayList<String> spELFlag = Lists.newArrayList("#", "T(");
|
||||
Optional<String> optional = spELFlag.stream().filter(spEl::contains).findFirst();
|
||||
if (optional.isPresent()) {
|
||||
// 解析并返回
|
||||
return parse(spEl, method, contextObj);
|
||||
}
|
||||
// 直接返回
|
||||
return spEl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换参数为字符串
|
||||
*
|
||||
* @param spEl spEl 表达式
|
||||
* @param contextObj 上下文对象
|
||||
* @return 解析的字符串值
|
||||
*/
|
||||
public static Object parse(String spEl, Method method, Object[] contextObj) {
|
||||
DefaultParameterNameDiscoverer discoverer = new DefaultParameterNameDiscoverer();
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
// 解析 SpEL 表达式
|
||||
Expression exp = parser.parseExpression(spEl);
|
||||
// 获取方法参数名
|
||||
String[] params = discoverer.getParameterNames(method);
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
if (ArrayUtil.isNotEmpty(params)) {
|
||||
// 设置参数
|
||||
for (int len = 0; len < params.length; len++) {
|
||||
context.setVariable(params[len], contextObj[len]);
|
||||
}
|
||||
}
|
||||
// 解析并返回
|
||||
return exp.getValue(context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.flyingpig.cloudmusic.idempotent.config.IdempotentAutoConfiguration
|
||||
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
@ -0,0 +1,50 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.flyingpig.cloud-music</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common-security</artifactId>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.flyingpig.cloud-music</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.csp</groupId>
|
||||
<artifactId>sentinel-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -1,4 +1,4 @@
|
||||
package com.flyingpig.cloudmusic.aop;
|
||||
package com.flyingpig.cloudmusic.security.aop;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -1,6 +1,6 @@
|
||||
package com.flyingpig.cloudmusic.config;
|
||||
package com.flyingpig.cloudmusic.security.config;
|
||||
|
||||
import com.flyingpig.cloudmusic.interceptor.UserInfoInterceptor;
|
||||
import com.flyingpig.cloudmusic.security.interceptor.UserInfoInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@ -1,4 +1,5 @@
|
||||
package com.flyingpig.cloudmusic.interceptor;
|
||||
package com.flyingpig.cloudmusic.security.interceptor;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.flyingpig.cloudmusic.util;
|
||||
package com.flyingpig.cloudmusic.security.util;
|
||||
|
||||
|
||||
import io.jsonwebtoken.*;
|
||||
@ -1,6 +1,7 @@
|
||||
package com.flyingpig.cloudmusic.util;
|
||||
package com.flyingpig.cloudmusic.security.util;
|
||||
|
||||
import com.flyingpig.cloudmusic.interceptor.LocalUserInfo;
|
||||
|
||||
import com.flyingpig.cloudmusic.security.interceptor.LocalUserInfo;
|
||||
|
||||
public class UserContext {
|
||||
private static final ThreadLocal<LocalUserInfo> tl =new ThreadLocal<>();
|
||||
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.flyingpig.cloudmusic.security.config.MvcConfig
|
||||
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
@ -0,0 +1,34 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.flyingpig.cloud-music</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>common-sentinel</artifactId>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -1,17 +0,0 @@
|
||||
package com.flyingpig.cloudmusic.constant;
|
||||
|
||||
public class RabbitMQConstants {
|
||||
public static final String MUSIC_UPLOAD_EXCHANGE_NAME = "music_upload_exchange";
|
||||
public static final String MUSIC_UPLOAD_QUEUE_NAME1 = "music_queue1";
|
||||
public static final String MUSIC_UPLOAD_QUEUE_NAME2 = "music_queue2";
|
||||
public static final String MUSIC_LIKE_EXCHANGE_NAME = "music_like_exchange";
|
||||
public static final String MUSIC_LIKE_QUEUE_NAME1 = "music_like_queue1";
|
||||
public static final String MUSIC_LIKE_QUEUE_NAME2 = "music_like_queue2";
|
||||
|
||||
public static final String MUSIC_DISLIKE_EXCHANGE_NAME = "music_dislike_exchange";
|
||||
|
||||
public static final String MUSIC_DISLIKE_QUEUE_NAME1 = "music_dislike_queue1";
|
||||
public static final String MUSIC_DISLIKE_QUEUE_NAME2 = "music_dislike_queue2";
|
||||
|
||||
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
package com.flyingpig.cloudmusic.constant;
|
||||
|
||||
public class RedisConstants {
|
||||
|
||||
public static final String USER_INFO_KEY="user:info:";
|
||||
|
||||
public static final Long USER_INFO_TTL=30L;
|
||||
|
||||
public static final String USER_LOGIN_KEY="user:login:";
|
||||
|
||||
public static final Long USER_LOGIN_TTL = 30L;
|
||||
|
||||
public static final String EMAIL_VERIFYCODE_KEY="email:verifycode:";
|
||||
|
||||
public static final Long EMAIL_VERIFYCODE_TTL=120L;
|
||||
|
||||
public static final String MUSIC_RANKLIST_KEY="music:rankList:";
|
||||
|
||||
public static final String MUSIC_LIKE_KEY="music:like:";
|
||||
|
||||
public static final Long MUSIC_LIKE_TTL=30L;
|
||||
|
||||
public static final String MUSIC_LIKENUM_KEY="music:like-num:";
|
||||
|
||||
public static final Long MUSIC_LIKENUM_TTL=30L;
|
||||
|
||||
public static final String LIKE_LOCK_KEY = "lock:like:";
|
||||
|
||||
public static final String DISLIKE_LOCK_KEY = "lock:dislike:";
|
||||
|
||||
public static final String MUSIC_INFO_KEY="music:like-num:";
|
||||
|
||||
public static final Long MUSIC_INFO_TTL=30L;
|
||||
|
||||
public static final Long CACHE_NULL_TTL=30L;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package com.flyingpig.cloudmusic.util.cache;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class RedisData {
|
||||
private LocalDateTime expireTime;
|
||||
private Object data;
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
spring:
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
@ -1,5 +0,0 @@
|
||||
spring:
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue