Compare commits
14
Commits
9ed8e0d780
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0843049b5a | ||
|
|
7025c84a58 | ||
|
|
4276942ca4 | ||
|
|
bdaff206f2 | ||
|
|
849ddb78bd | ||
|
|
2a84b71920 | ||
|
|
4136dcc307 | ||
|
|
9f678d422e | ||
|
|
1e03f301aa | ||
|
|
e34ca42f3c | ||
|
|
b1a200aad1 | ||
|
|
4bd84c23b8 | ||
|
|
b76b7769a8 | ||
|
|
8946f9b98f |
@@ -0,0 +1,13 @@
|
|||||||
|
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
|
||||||
|
# Project exclude paths
|
||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
# Project exclude paths
|
# Project exclude paths
|
||||||
/Noodles-Detector/target/
|
|
||||||
|
|
||||||
HELP.md
|
HELP.md
|
||||||
target/
|
target/
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# 百盘搜
|
||||||
|
|
||||||
|
## 这个项目是做什么的?
|
||||||
|
|
||||||
|
- 网盘聚合搜索器
|
||||||
|
1.自动搜索对应的网盘资源(多种网盘,包括百度网盘,UC网盘,迅雷云盘,夸克网盘)然后转存到我的对应网盘的账号后,将分享链接返回。
|
||||||
|
2.一个强大的搜索入口,高度扩展性,可以扩展各种网盘,返回对应网盘的分享链接,接口速度快,多级缓存。
|
||||||
|
- 常见社交平台推广下载链接
|
||||||
|
类似B站这样的平台,可以自动发现某个类型的视频,然后将所有资料整理,自动转存后形成分享链接,并且自动评论到评论区。
|
||||||
|
|
||||||
|
## 功能模块
|
||||||
|
|
||||||
|
1. 云盘管理(设计上是四种云盘,但目前只支持百度云盘)
|
||||||
|
2. 资源管理
|
||||||
|
3. 评论管理(评论时间,评论的链接要能跳转看到)
|
||||||
|
4. 日志管理(都搜索了什么,要记录下来)
|
||||||
@@ -9,12 +9,12 @@
|
|||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.mzaxd</groupId>
|
<groupId>com.mzaxd</groupId>
|
||||||
<artifactId>Noodles</artifactId>
|
<artifactId>BPS</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>Noodles</name>
|
<name>BPS-Server</name>
|
||||||
<description>Noodles</description>
|
<description>BPS-Server</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>17</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -30,10 +30,11 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- druid -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
<scope>runtime</scope>
|
<version>1.2.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--lombok-->
|
<!--lombok-->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -55,7 +56,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.33</version>
|
<version>1.2.83</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--jwt依赖-->
|
<!--jwt依赖-->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -84,10 +85,6 @@
|
|||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>2.9.2</version>
|
<version>2.9.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
@@ -107,28 +104,11 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-aop</artifactId>
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.lionsoul/ip2region -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.lionsoul</groupId>
|
|
||||||
<artifactId>ip2region</artifactId>
|
|
||||||
<version>2.7.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!--工具类-->
|
<!--工具类-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>5.3.7</version>
|
<version>5.8.24</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.mail</groupId>
|
|
||||||
<artifactId>mail</artifactId>
|
|
||||||
<version>1.4.7</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>easyexcel</artifactId>
|
|
||||||
<version>3.2.1</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
|
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
|
||||||
@@ -143,17 +123,6 @@
|
|||||||
<artifactId>ganymed-ssh2</artifactId>
|
<artifactId>ganymed-ssh2</artifactId>
|
||||||
<version>262</version>
|
<version>262</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--监控-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>de.codecentric</groupId>
|
|
||||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
|
||||||
<version>2.7.8</version>
|
|
||||||
</dependency>
|
|
||||||
<!--暴露端点-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -171,6 +140,15 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>false</filtering>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*.exe</exclude>
|
||||||
|
</excludes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
#-------------------------------------------------------------------------------#
|
||||||
|
# Qodana analysis is configured by qodana.yaml file #
|
||||||
|
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
|
||||||
|
#-------------------------------------------------------------------------------#
|
||||||
|
version: "1.0"
|
||||||
|
|
||||||
|
#Specify inspection profile for code analysis
|
||||||
|
profile:
|
||||||
|
name: qodana.starter
|
||||||
|
|
||||||
|
#Enable inspections
|
||||||
|
#include:
|
||||||
|
# - name: <SomeEnabledInspectionId>
|
||||||
|
|
||||||
|
#Disable inspections
|
||||||
|
#exclude:
|
||||||
|
# - name: <SomeDisabledInspectionId>
|
||||||
|
# paths:
|
||||||
|
# - <path/where/not/run/inspection>
|
||||||
|
|
||||||
|
projectJDK: "17" #(Applied in CI/CD pipeline)
|
||||||
|
|
||||||
|
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
|
||||||
|
#bootstrap: sh ./prepare-qodana.sh
|
||||||
|
|
||||||
|
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
|
||||||
|
#plugins:
|
||||||
|
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
|
||||||
|
|
||||||
|
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
|
||||||
|
linter: jetbrains/qodana-jvm:latest
|
||||||
+4
-5
@@ -1,9 +1,8 @@
|
|||||||
package com.mzaxd.noodles;
|
package com.mzaxd.bps;
|
||||||
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,11 +10,11 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@MapperScan("com.mzaxd.noodles.mapper")
|
@MapperScan("com.mzaxd.bps.mapper")
|
||||||
public class NoodlesApplication {
|
public class BPSApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(NoodlesApplication.class, args);
|
SpringApplication.run(BPSApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package com.mzaxd.noodles.annotation;
|
package com.mzaxd.bps.annotation;
|
||||||
|
|
||||||
import com.mzaxd.noodles.enums.OperationEnum;
|
import com.mzaxd.bps.enums.OperationEnum;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.mzaxd.bps.aspect;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 13439
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Aspect
|
||||||
|
@Slf4j
|
||||||
|
public class SysLogAspect {
|
||||||
|
|
||||||
|
// @Resource
|
||||||
|
// private AuditLogService auditLogService;
|
||||||
|
//
|
||||||
|
// @Pointcut("@annotation(com.mzaxd.bps.annotation.SysLog)")
|
||||||
|
// public void logPointCut() {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //方法执行前后都操作
|
||||||
|
// @Around("logPointCut()")
|
||||||
|
// public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||||
|
// //执行方法
|
||||||
|
// Object result = point.proceed();
|
||||||
|
// //保存日志
|
||||||
|
// saveSysLog(point);
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void saveSysLog(ProceedingJoinPoint joinPoint) {
|
||||||
|
// MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
|
// Method method = signature.getMethod();
|
||||||
|
//
|
||||||
|
// AuditLog auditLog = new AuditLog();
|
||||||
|
// SysLog syslog = method.getAnnotation(SysLog.class);
|
||||||
|
// if (syslog != null) {
|
||||||
|
// //注解上的描述
|
||||||
|
// auditLog.setOperation(syslog.operation().getOperation());
|
||||||
|
// auditLog.setOperationType(syslog.operation().getOperationType());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //请求的参数
|
||||||
|
// Object[] args = joinPoint.getArgs();
|
||||||
|
// try {
|
||||||
|
// String params = JSON.toJSONString(args);
|
||||||
|
// auditLog.setParam(params);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// log.error(e.getMessage());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //保存系统日志
|
||||||
|
// auditLogService.save(auditLog);
|
||||||
|
// }
|
||||||
|
}
|
||||||
+6
-5
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.config;
|
package com.mzaxd.bps.config;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.parser.ParserConfig;
|
import com.alibaba.fastjson.parser.ParserConfig;
|
||||||
@@ -9,6 +9,7 @@ import org.springframework.data.redis.serializer.RedisSerializer;
|
|||||||
import org.springframework.data.redis.serializer.SerializationException;
|
import org.springframework.data.redis.serializer.SerializationException;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redis使用FastJson序列化
|
* Redis使用FastJson序列化
|
||||||
@@ -17,9 +18,9 @@ import java.nio.charset.Charset;
|
|||||||
*/
|
*/
|
||||||
public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
|
public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
|
||||||
|
|
||||||
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
|
||||||
|
|
||||||
private Class<T> clazz;
|
private final Class<T> clazz;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
|
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
|
||||||
@@ -40,7 +41,7 @@ public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T deserialize(byte[] bytes) throws SerializationException {
|
public T deserialize(byte[] bytes) throws SerializationException {
|
||||||
if (bytes == null || bytes.length <= 0) {
|
if (bytes == null || bytes.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String str = new String(bytes, DEFAULT_CHARSET);
|
String str = new String(bytes, DEFAULT_CHARSET);
|
||||||
@@ -52,4 +53,4 @@ public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
|
|||||||
protected JavaType getJavaType(Class<?> clazz) {
|
protected JavaType getJavaType(Class<?> clazz) {
|
||||||
return TypeFactory.defaultInstance().constructType(clazz);
|
return TypeFactory.defaultInstance().constructType(clazz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.mzaxd.bps.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传配置
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "file")
|
||||||
|
public class FileConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传路径
|
||||||
|
*/
|
||||||
|
private String uploadPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访问路径
|
||||||
|
*/
|
||||||
|
private String accessPath;
|
||||||
|
|
||||||
|
public String getUploadPath() {
|
||||||
|
return uploadPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUploadPath(String uploadPath) {
|
||||||
|
this.uploadPath = uploadPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccessPath() {
|
||||||
|
return accessPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessPath(String accessPath) {
|
||||||
|
this.accessPath = accessPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.config;
|
package com.mzaxd.bps.config;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||||
@@ -23,4 +23,4 @@ public class MyBatisPlusConfig {
|
|||||||
mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||||
return mybatisPlusInterceptor;
|
return mybatisPlusInterceptor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.config;
|
package com.mzaxd.bps.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -28,4 +28,4 @@ public class RedisConfig {
|
|||||||
template.afterPropertiesSet();
|
template.afterPropertiesSet();
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.config;
|
package com.mzaxd.bps.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
+2
-3
@@ -1,11 +1,10 @@
|
|||||||
package com.mzaxd.noodles.config;
|
package com.mzaxd.bps.config;
|
||||||
|
|
||||||
import com.mzaxd.noodles.filter.JwtAuthenticationTokenFilter;
|
import com.mzaxd.bps.filter.JwtAuthenticationTokenFilter;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.config;
|
package com.mzaxd.bps.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -23,7 +23,7 @@ public class SwaggerConfig {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
private ApiInfo apiInfo() {
|
private ApiInfo apiInfo() {
|
||||||
Contact contact = new Contact("一个人的团队", "http://www.my.com", "my@my.com");
|
Contact contact = new Contact("一个人的团队", "https://www.my.com", "my@my.com");
|
||||||
return new ApiInfoBuilder()
|
return new ApiInfoBuilder()
|
||||||
.title("文档标题")
|
.title("文档标题")
|
||||||
.description("文档描述")
|
.description("文档描述")
|
||||||
@@ -31,4 +31,4 @@ public class SwaggerConfig {
|
|||||||
.version("1.0.0") // 版本
|
.version("1.0.0") // 版本
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-4
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.config;
|
package com.mzaxd.bps.config;
|
||||||
|
|
||||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
@@ -47,8 +47,7 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
|
|
||||||
fastJsonConfig.setSerializeConfig(SerializeConfig.globalInstance);
|
fastJsonConfig.setSerializeConfig(SerializeConfig.globalInstance);
|
||||||
fastConverter.setFastJsonConfig(fastJsonConfig);
|
fastConverter.setFastJsonConfig(fastJsonConfig);
|
||||||
HttpMessageConverter<?> converter = fastConverter;
|
return fastConverter;
|
||||||
return converter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -56,4 +55,4 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
converters.add(fastJsonHttpMessageConverters());
|
converters.add(fastJsonHttpMessageConverters());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.config;
|
package com.mzaxd.bps.config;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
||||||
+1
-16
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.constant;
|
package com.mzaxd.bps.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author root
|
* @author root
|
||||||
@@ -8,36 +8,21 @@ public class RedisConstant {
|
|||||||
/**
|
/**
|
||||||
* Redis Key
|
* Redis Key
|
||||||
*
|
*
|
||||||
* @author mzaxd
|
|
||||||
* @date 2/7/23 12:59 PM
|
* @date 2/7/23 12:59 PM
|
||||||
* @param null
|
|
||||||
*/
|
|
||||||
public static final String DYNAMIC_DATA = "dynamicData:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Redis Key
|
|
||||||
*
|
|
||||||
* @author mzaxd
|
|
||||||
* @date 2/7/23 12:59 PM
|
|
||||||
* @param null
|
|
||||||
*/
|
*/
|
||||||
public static final String NOTIFY_CONTAINER_IDS = "notify:containerIds";
|
public static final String NOTIFY_CONTAINER_IDS = "notify:containerIds";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redis Key
|
* Redis Key
|
||||||
*
|
*
|
||||||
* @author mzaxd
|
|
||||||
* @date 2/7/23 12:59 PM
|
* @date 2/7/23 12:59 PM
|
||||||
* @param null
|
|
||||||
*/
|
*/
|
||||||
public static final String NOTIFY_HOST_IDS = "notify:hostIds";
|
public static final String NOTIFY_HOST_IDS = "notify:hostIds";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redis Key
|
* Redis Key
|
||||||
*
|
*
|
||||||
* @author mzaxd
|
|
||||||
* @date 2/7/23 12:59 PM
|
* @date 2/7/23 12:59 PM
|
||||||
* @param null
|
|
||||||
*/
|
*/
|
||||||
public static final String NOTIFY_VM_IDS = "notify:vmIds";
|
public static final String NOTIFY_VM_IDS = "notify:vmIds";
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.mzaxd.bps.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author root
|
||||||
|
*/
|
||||||
|
public class SystemConstant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正常状态(非第一次使用) 通用常量
|
||||||
|
*/
|
||||||
|
public static final Integer NORMAL_STATE = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志类型为用户
|
||||||
|
*/
|
||||||
|
public static final String LOG_USER = "用户";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未处理的通知
|
||||||
|
*/
|
||||||
|
public static final Integer NOTIFICATION_NOT_AFFIRM = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已处理的通知
|
||||||
|
*/
|
||||||
|
public static final Integer NOTIFICATION_AFFIRM = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知实例类型 物理机
|
||||||
|
*/
|
||||||
|
public static final Integer INSTANCETYPE_HOST = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知实例类型 虚拟机
|
||||||
|
*/
|
||||||
|
public static final Integer INSTANCETYPE_VM = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知实例类型 容器
|
||||||
|
*/
|
||||||
|
public static final Integer INSTANCETYPE_CONTAINER = 3;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.mzaxd.bps.controller;
|
||||||
|
|
||||||
|
import com.mzaxd.bps.config.FileConfig;
|
||||||
|
import com.mzaxd.bps.util.FileUtil;
|
||||||
|
import com.mzaxd.bps.util.Result;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传Controller
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/file")
|
||||||
|
public class FileController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FileConfig fileConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*/
|
||||||
|
@PostMapping("/upload")
|
||||||
|
public Result<String> upload(@RequestParam("file") MultipartFile file) throws IOException {
|
||||||
|
String fileName = FileUtil.upload(file, fileConfig.getUploadPath());
|
||||||
|
return Result.success(fileConfig.getAccessPath() + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文件
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{fileName}")
|
||||||
|
public Result<Boolean> delete(@PathVariable String fileName) {
|
||||||
|
return Result.success(FileUtil.delete(fileConfig.getUploadPath() + fileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package com.mzaxd.bps.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.mzaxd.bps.domain.entity.SourceCategory;
|
||||||
|
import com.mzaxd.bps.service.SourceCategoryService;
|
||||||
|
import com.mzaxd.bps.util.Result;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘分类Controller
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/source/category")
|
||||||
|
public class SourceCategoryController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SourceCategoryService sourceCategoryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询网盘分类
|
||||||
|
*/
|
||||||
|
@GetMapping("/page")
|
||||||
|
public Result<Page<SourceCategory>> page(
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) String name) {
|
||||||
|
LambdaQueryWrapper<SourceCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.like(name != null, SourceCategory::getName, name)
|
||||||
|
.orderByAsc(SourceCategory::getSort);
|
||||||
|
return Result.success(sourceCategoryService.page(new Page<>(pageNum, pageSize), queryWrapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有网盘分类
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<List<SourceCategory>> list() {
|
||||||
|
LambdaQueryWrapper<SourceCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SourceCategory::getStatus, 1)
|
||||||
|
.orderByAsc(SourceCategory::getSort);
|
||||||
|
return Result.success(sourceCategoryService.list(queryWrapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网盘分类详情
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public Result<SourceCategory> getById(@PathVariable Long id) {
|
||||||
|
return Result.success(sourceCategoryService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增网盘分类
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
public Result<Boolean> save(@RequestBody SourceCategory sourceCategory) {
|
||||||
|
return Result.success(sourceCategoryService.save(sourceCategory));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改网盘分类
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
public Result<Boolean> updateById(@RequestBody SourceCategory sourceCategory) {
|
||||||
|
return Result.success(sourceCategoryService.updateById(sourceCategory));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除网盘分类
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public Result<Boolean> removeById(@PathVariable Long id) {
|
||||||
|
return Result.success(sourceCategoryService.removeById(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.mzaxd.bps.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.mzaxd.bps.domain.entity.Source;
|
||||||
|
import com.mzaxd.bps.service.SourceService;
|
||||||
|
import com.mzaxd.bps.util.Result;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘资源Controller
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/source")
|
||||||
|
public class SourceController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SourceService sourceService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索网盘资源
|
||||||
|
*/
|
||||||
|
@GetMapping("/search")
|
||||||
|
public Result<Page<Source>> search(
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) String keyword,
|
||||||
|
@RequestParam(required = false) Long categoryId) {
|
||||||
|
return Result.success(sourceService.search(pageNum, pageSize, keyword, categoryId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询网盘资源
|
||||||
|
*/
|
||||||
|
@GetMapping("/page")
|
||||||
|
public Result<Page<Source>> page(
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) String title,
|
||||||
|
@RequestParam(required = false) Long sourceCategoryId) {
|
||||||
|
LambdaQueryWrapper<Source> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.like(title != null, Source::getTitle, title)
|
||||||
|
.eq(sourceCategoryId != null, Source::getSourceCategoryId, sourceCategoryId)
|
||||||
|
.orderByDesc(Source::getCreateTime);
|
||||||
|
return Result.success(sourceService.page(new Page<>(pageNum, pageSize), queryWrapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网盘资源详情
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public Result<Source> getById(@PathVariable Long id) {
|
||||||
|
return Result.success(sourceService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增网盘资源
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
public Result<Boolean> save(@RequestBody Source source) {
|
||||||
|
return Result.success(sourceService.save(source));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改网盘资源
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
public Result<Boolean> updateById(@RequestBody Source source) {
|
||||||
|
return Result.success(sourceService.updateById(source));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除网盘资源
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public Result<Boolean> removeById(@PathVariable Long id) {
|
||||||
|
return Result.success(sourceService.removeById(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.mzaxd.bps.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.mzaxd.bps.domain.entity.SourceLog;
|
||||||
|
import com.mzaxd.bps.service.SourceLogService;
|
||||||
|
import com.mzaxd.bps.util.Result;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘日志Controller
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/source/log")
|
||||||
|
public class SourceLogController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SourceLogService sourceLogService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询网盘日志
|
||||||
|
*/
|
||||||
|
@GetMapping("/page")
|
||||||
|
public Result<Page<SourceLog>> page(
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) Long sourceId) {
|
||||||
|
LambdaQueryWrapper<SourceLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(sourceId != null, SourceLog::getSourceId, sourceId)
|
||||||
|
.orderByDesc(SourceLog::getCreateTime);
|
||||||
|
return Result.success(sourceLogService.page(new Page<>(pageNum, pageSize), queryWrapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网盘日志详情
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public Result<SourceLog> getById(@PathVariable Long id) {
|
||||||
|
return Result.success(sourceLogService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增网盘日志
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
public Result<Boolean> save(@RequestBody SourceLog sourceLog) {
|
||||||
|
return Result.success(sourceLogService.save(sourceLog));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除网盘日志
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public Result<Boolean> removeById(@PathVariable Long id) {
|
||||||
|
return Result.success(sourceLogService.removeById(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.mzaxd.bps.domain;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class CloudFile {
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String path;
|
||||||
|
private long size;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime modifyTime;
|
||||||
|
private String md5;
|
||||||
|
private String shareLink;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.mzaxd.bps.domain;
|
||||||
|
|
||||||
|
import com.mzaxd.bps.service.impl.BaiduPcsService;
|
||||||
|
import com.mzaxd.bps.enums.CloudStorageType;
|
||||||
|
import com.mzaxd.bps.service.CloudStorageService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CloudStorageFactory {
|
||||||
|
private final Map<CloudStorageType, CloudStorageService> services = new HashMap<>();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public CloudStorageFactory(BaiduPcsService baiduPcsService) {
|
||||||
|
services.put(CloudStorageType.BAIDU, baiduPcsService);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudStorageService getService(CloudStorageType type) {
|
||||||
|
CloudStorageService service = services.get(type);
|
||||||
|
if (service == null) {
|
||||||
|
throw new IllegalArgumentException("Unsupported cloud storage type: " + type);
|
||||||
|
}
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package com.mzaxd.bps.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.mzaxd.bps.enums.AppHttpCodeEnum;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一响应结果类
|
||||||
|
*
|
||||||
|
* @author Mzaxd
|
||||||
|
* @param <T> 响应数据类型
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class ResponseResult<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态码
|
||||||
|
*/
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应消息
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应数据
|
||||||
|
*/
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建响应结果
|
||||||
|
*/
|
||||||
|
private ResponseResult(Builder<T> builder) {
|
||||||
|
this.code = builder.code;
|
||||||
|
this.message = builder.message;
|
||||||
|
this.data = builder.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建者类
|
||||||
|
*/
|
||||||
|
public static class Builder<T> {
|
||||||
|
private Integer code;
|
||||||
|
private String message;
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
public Builder<T> code(Integer code) {
|
||||||
|
this.code = code;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> message(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> data(T data) {
|
||||||
|
this.data = data;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseResult<T> build() {
|
||||||
|
return new ResponseResult<>(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建成功响应(无数据)
|
||||||
|
*/
|
||||||
|
public static <T> ResponseResult<T> success() {
|
||||||
|
return new Builder<T>()
|
||||||
|
.code(AppHttpCodeEnum.SUCCESS.getCode())
|
||||||
|
.message(AppHttpCodeEnum.SUCCESS.getMsg())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建成功响应(带数据)
|
||||||
|
*/
|
||||||
|
public static <T> ResponseResult<T> success(T data) {
|
||||||
|
return new Builder<T>()
|
||||||
|
.code(AppHttpCodeEnum.SUCCESS.getCode())
|
||||||
|
.message(AppHttpCodeEnum.SUCCESS.getMsg())
|
||||||
|
.data(data)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建成功响应(自定义消息和数据)
|
||||||
|
*/
|
||||||
|
public static <T> ResponseResult<T> success(String message, T data) {
|
||||||
|
return new Builder<T>()
|
||||||
|
.code(AppHttpCodeEnum.SUCCESS.getCode())
|
||||||
|
.message(message)
|
||||||
|
.data(data)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建失败响应
|
||||||
|
*/
|
||||||
|
public static <T> ResponseResult<T> failure(AppHttpCodeEnum errorEnum) {
|
||||||
|
return new Builder<T>()
|
||||||
|
.code(errorEnum.getCode())
|
||||||
|
.message(errorEnum.getMsg())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建失败响应(自定义消息)
|
||||||
|
*/
|
||||||
|
public static <T> ResponseResult<T> failure(AppHttpCodeEnum errorEnum, String message) {
|
||||||
|
return new Builder<T>()
|
||||||
|
.code(errorEnum.getCode())
|
||||||
|
.message(message)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建失败响应(完全自定义)
|
||||||
|
*/
|
||||||
|
public static <T> ResponseResult<T> failure(Integer code, String message) {
|
||||||
|
return new Builder<T>()
|
||||||
|
.code(code)
|
||||||
|
.message(message)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-12
@@ -1,19 +1,16 @@
|
|||||||
package com.mzaxd.noodles.domain.entity;
|
package com.mzaxd.bps.domain.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author 13439
|
* @author 13439
|
||||||
* @TableName audit_log
|
* @TableName audit_log
|
||||||
*/
|
*/
|
||||||
@@ -23,7 +20,7 @@ import lombok.experimental.Accessors;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@EqualsAndHashCode(of = "param")
|
@EqualsAndHashCode(of = "param")
|
||||||
public class AuditLog implements Serializable {
|
public class AuditLog {
|
||||||
/**
|
/**
|
||||||
* id
|
* id
|
||||||
*/
|
*/
|
||||||
@@ -57,7 +54,4 @@ public class AuditLog implements Serializable {
|
|||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Long createBy;
|
private Long createBy;
|
||||||
|
|
||||||
@TableField(exist = false)
|
}
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
}
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.domain.entity;
|
package com.mzaxd.bps.domain.entity;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
+6
-11
@@ -1,17 +1,15 @@
|
|||||||
package com.mzaxd.noodles.domain.entity;
|
package com.mzaxd.bps.domain.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @TableName notification
|
* @TableName notification
|
||||||
*/
|
*/
|
||||||
@TableName(value ="notification")
|
@TableName(value ="notification")
|
||||||
@@ -19,7 +17,7 @@ import lombok.experimental.Accessors;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class Notification implements Serializable {
|
public class Notification {
|
||||||
/**
|
/**
|
||||||
* 主键id
|
* 主键id
|
||||||
*/
|
*/
|
||||||
@@ -71,7 +69,4 @@ public class Notification implements Serializable {
|
|||||||
* 删除标志(0代表未删除,1代表已删除)
|
* 删除标志(0代表未删除,1代表已删除)
|
||||||
*/
|
*/
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
}
|
||||||
@TableField(exist = false)
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package com.mzaxd.bps.domain.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘资源实体类
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("source")
|
||||||
|
public class Source {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long sourceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类ID
|
||||||
|
*/
|
||||||
|
private Long sourceCategoryId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源URL
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源代码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频内容
|
||||||
|
*/
|
||||||
|
private String vodContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频封面
|
||||||
|
*/
|
||||||
|
private String vodPic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源类型
|
||||||
|
*/
|
||||||
|
private Integer isType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否定时
|
||||||
|
*/
|
||||||
|
private Integer isTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否删除
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDelete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览量
|
||||||
|
*/
|
||||||
|
private Integer pageViews;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.mzaxd.bps.domain.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘分类实体类
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("source_category")
|
||||||
|
public class SourceCategory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long sourceCategoryId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.mzaxd.bps.domain.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘日志实体类
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("source_log")
|
||||||
|
public class SourceLog {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long logId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源ID
|
||||||
|
*/
|
||||||
|
private Long sourceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IP地址
|
||||||
|
*/
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
+4
-9
@@ -1,24 +1,21 @@
|
|||||||
package com.mzaxd.noodles.domain.entity;
|
package com.mzaxd.bps.domain.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @TableName system_setting
|
* @TableName system_setting
|
||||||
*/
|
*/
|
||||||
@TableName(value ="system_setting")
|
@TableName(value ="system_setting")
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SystemSetting implements Serializable {
|
public class SystemSetting {
|
||||||
/**
|
/**
|
||||||
* id
|
* id
|
||||||
*/
|
*/
|
||||||
@@ -80,6 +77,4 @@ public class SystemSetting implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String background;
|
private String background;
|
||||||
|
|
||||||
@TableField(exist = false)
|
}
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
+4
-7
@@ -1,21 +1,20 @@
|
|||||||
package com.mzaxd.noodles.domain.entity;
|
package com.mzaxd.bps.domain.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author root
|
* @author root
|
||||||
* @TableName user
|
* @TableName user
|
||||||
*/
|
*/
|
||||||
@TableName(value ="user")
|
@TableName(value ="user")
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class User implements Serializable {
|
public class User {
|
||||||
/**
|
/**
|
||||||
* 主键id
|
* 主键id
|
||||||
*/
|
*/
|
||||||
@@ -81,6 +80,4 @@ public class User implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
@TableField(exist = false)
|
}
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package com.mzaxd.noodles.domain.message;
|
package com.mzaxd.bps.domain.message;
|
||||||
|
|
||||||
import com.mzaxd.noodledetector.util.Arith;
|
import com.mzaxd.bps.util.Arith;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.domain.message;
|
package com.mzaxd.bps.domain.message;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
+1
-2
@@ -1,11 +1,10 @@
|
|||||||
package com.mzaxd.noodles.domain.message;
|
package com.mzaxd.bps.domain.message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mzaxd
|
* @author Mzaxd
|
||||||
* @since 2023-02-05 10:50
|
* @since 2023-02-05 10:50
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.mzaxd.noodledetector.util.Arith;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.domain.message;
|
package com.mzaxd.bps.domain.message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mzaxd
|
* @author Mzaxd
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.domain.message;
|
package com.mzaxd.bps.domain.message;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.domain.message;
|
package com.mzaxd.bps.domain.message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mzaxd
|
* @author Mzaxd
|
||||||
@@ -38,7 +38,7 @@ public class Server {
|
|||||||
/**
|
/**
|
||||||
* Os相关信息
|
* Os相关信息
|
||||||
*/
|
*/
|
||||||
private com.mzaxd.noodles.domain.message.Os os = new Os();
|
private com.mzaxd.bps.domain.message.Os os = new Os();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CPU相关信息
|
* CPU相关信息
|
||||||
@@ -58,7 +58,7 @@ public class Server {
|
|||||||
/**
|
/**
|
||||||
* 磁盘相关信息
|
* 磁盘相关信息
|
||||||
*/
|
*/
|
||||||
private List<SysFile> sysFiles = new LinkedList<SysFile>();
|
private List<SysFile> sysFiles = new LinkedList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网络相关信息
|
* 网络相关信息
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.domain.message;
|
package com.mzaxd.bps.domain.message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mzaxd
|
* @author Mzaxd
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.domain.message;
|
package com.mzaxd.bps.domain.message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mzaxd
|
* @author Mzaxd
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.domain.search;
|
package com.mzaxd.bps.domain.search;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
package com.mzaxd.noodles.domain.search;
|
package com.mzaxd.bps.domain.search;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
package com.mzaxd.noodles.domain.search;
|
package com.mzaxd.bps.domain.search;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.mzaxd.bps.domain.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页结果封装类
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06 10:00:00
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PageVo<T> {
|
||||||
|
/**
|
||||||
|
* 总记录数
|
||||||
|
*/
|
||||||
|
private Long total;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据列表
|
||||||
|
*/
|
||||||
|
private List<T> rows;
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.mzaxd.bps.domain.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘分类返回对象
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06 10:00:00
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SourceCategoryVo {
|
||||||
|
/**
|
||||||
|
* 分类ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.mzaxd.bps.domain.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘日志返回对象
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06 10:00:00
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SourceLogVo {
|
||||||
|
/**
|
||||||
|
* 日志ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源ID
|
||||||
|
*/
|
||||||
|
private Long sourceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源标题
|
||||||
|
*/
|
||||||
|
private String sourceTitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IP地址
|
||||||
|
*/
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package com.mzaxd.bps.domain.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘资源返回对象
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06 10:00:00
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SourceVo {
|
||||||
|
/**
|
||||||
|
* 资源ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类ID
|
||||||
|
*/
|
||||||
|
private Long sourceCategoryId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类名称
|
||||||
|
*/
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源URL
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源代码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频内容
|
||||||
|
*/
|
||||||
|
private String vodContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频封面
|
||||||
|
*/
|
||||||
|
private String vodPic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源类型
|
||||||
|
*/
|
||||||
|
private Integer isType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否定时
|
||||||
|
*/
|
||||||
|
private Integer isTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览量
|
||||||
|
*/
|
||||||
|
private Integer pageViews;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
package com.mzaxd.noodles.domain.vo;
|
package com.mzaxd.bps.domain.vo;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+4
-8
@@ -1,9 +1,12 @@
|
|||||||
package com.mzaxd.noodles.enums;
|
package com.mzaxd.bps.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mzaxd
|
* @author Mzaxd
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
public enum AppHttpCodeEnum {
|
public enum AppHttpCodeEnum {
|
||||||
/**
|
/**
|
||||||
* 操作成功通用返回信息
|
* 操作成功通用返回信息
|
||||||
@@ -55,11 +58,4 @@ public enum AppHttpCodeEnum {
|
|||||||
this.msg = errorMessage;
|
this.msg = errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMsg() {
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.mzaxd.bps.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum BaiduPcsCommand {
|
||||||
|
LOGIN("login", "Login to Baidu PCS"),
|
||||||
|
SEARCH("search", "Search files"),
|
||||||
|
DOWNLOAD("download", "Download file"),
|
||||||
|
UPLOAD("upload", "Upload file"),
|
||||||
|
SHARE("share", "Create share link"),
|
||||||
|
LIST("list", "List files"),
|
||||||
|
META("meta", "Get file metadata"),
|
||||||
|
QUOTA("quota", "Get quota information");
|
||||||
|
|
||||||
|
private final String command;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
BaiduPcsCommand(String command, String description) {
|
||||||
|
this.command = command;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.mzaxd.bps.enums;
|
||||||
|
|
||||||
|
public enum CloudStorageType {
|
||||||
|
BAIDU("baidu", "BaiduPCS-GO"),
|
||||||
|
UC("uc", "UC Cloud"),
|
||||||
|
XUN_LEI("xunlei", "Xunlei Cloud"),
|
||||||
|
QUARK("quark", "Quark Cloud");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
CloudStorageType(String code, String name) {
|
||||||
|
this.code = code;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-8
@@ -1,4 +1,6 @@
|
|||||||
package com.mzaxd.noodles.enums;
|
package com.mzaxd.bps.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作日志-操作类型
|
* 操作日志-操作类型
|
||||||
@@ -6,6 +8,7 @@ package com.mzaxd.noodles.enums;
|
|||||||
* @author 13439
|
* @author 13439
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
public enum OperationEnum {
|
public enum OperationEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,11 +114,4 @@ public enum OperationEnum {
|
|||||||
this.operationType = operationType;
|
this.operationType = operationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOperation() {
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOperationType() {
|
|
||||||
return operationType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+5
-11
@@ -1,6 +1,7 @@
|
|||||||
package com.mzaxd.noodles.exception;
|
package com.mzaxd.bps.exception;
|
||||||
|
|
||||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
import com.mzaxd.bps.enums.AppHttpCodeEnum;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -8,24 +9,17 @@ import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
|||||||
* @date 11/27/22 3:19 AM
|
* @date 11/27/22 3:19 AM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class SystemException extends RuntimeException{
|
public class SystemException extends RuntimeException{
|
||||||
|
|
||||||
private final int code;
|
private final int code;
|
||||||
|
|
||||||
private final String msg;
|
private final String msg;
|
||||||
|
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMsg() {
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SystemException(AppHttpCodeEnum httpCodeEnum) {
|
public SystemException(AppHttpCodeEnum httpCodeEnum) {
|
||||||
super(httpCodeEnum.getMsg());
|
super(httpCodeEnum.getMsg());
|
||||||
this.code = httpCodeEnum.getCode();
|
this.code = httpCodeEnum.getCode();
|
||||||
this.msg = httpCodeEnum.getMsg();
|
this.msg = httpCodeEnum.getMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+12
-10
@@ -1,13 +1,14 @@
|
|||||||
package com.mzaxd.noodles.filter;
|
package com.mzaxd.bps.filter;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.mzaxd.noodles.domain.ResponseResult;
|
import com.mzaxd.bps.domain.ResponseResult;
|
||||||
import com.mzaxd.noodles.domain.entity.LoginUser;
|
import com.mzaxd.bps.domain.entity.LoginUser;
|
||||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
import com.mzaxd.bps.enums.AppHttpCodeEnum;
|
||||||
import com.mzaxd.noodles.util.JwtUtil;
|
import com.mzaxd.bps.util.JwtUtil;
|
||||||
import com.mzaxd.noodles.util.RedisCache;
|
import com.mzaxd.bps.util.RedisCache;
|
||||||
import com.mzaxd.noodles.util.WebUtils;
|
import com.mzaxd.bps.util.WebUtils;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -26,6 +27,7 @@ import java.util.Objects;
|
|||||||
* @author root
|
* @author root
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
@Slf4j
|
||||||
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@@ -45,10 +47,10 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
|||||||
try {
|
try {
|
||||||
claims = JwtUtil.parseJWT(token);
|
claims = JwtUtil.parseJWT(token);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error(e.getMessage());
|
||||||
//token超时 token非法
|
//token超时 token非法
|
||||||
//响应告诉前端需要重新登录
|
//响应告诉前端需要重新登录
|
||||||
ResponseResult result = ResponseResult.errorResult(AppHttpCodeEnum.NEED_LOGIN);
|
ResponseResult<?> result = ResponseResult.failure(AppHttpCodeEnum.NEED_LOGIN);
|
||||||
WebUtils.renderString(response, JSON.toJSONString(result));
|
WebUtils.renderString(response, JSON.toJSONString(result));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -58,7 +60,7 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
|||||||
//如果redis中没有用户信息
|
//如果redis中没有用户信息
|
||||||
if (Objects.isNull(loginUser)) {
|
if (Objects.isNull(loginUser)) {
|
||||||
//说明登录过期 需要重新登录
|
//说明登录过期 需要重新登录
|
||||||
ResponseResult result = ResponseResult.errorResult(AppHttpCodeEnum.NEED_LOGIN);
|
ResponseResult<?> result = ResponseResult.failure(AppHttpCodeEnum.NEED_LOGIN);
|
||||||
WebUtils.renderString(response, JSON.toJSONString(result));
|
WebUtils.renderString(response, JSON.toJSONString(result));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
+9
-7
@@ -1,9 +1,10 @@
|
|||||||
package com.mzaxd.noodles.handler;
|
package com.mzaxd.bps.handler;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.mzaxd.noodles.domain.ResponseResult;
|
import com.mzaxd.bps.domain.ResponseResult;
|
||||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
import com.mzaxd.bps.enums.AppHttpCodeEnum;
|
||||||
import com.mzaxd.noodles.util.WebUtils;
|
import com.mzaxd.bps.util.WebUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
import org.springframework.security.web.access.AccessDeniedHandler;
|
import org.springframework.security.web.access.AccessDeniedHandler;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -16,12 +17,13 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
* @author root
|
* @author root
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
@Slf4j
|
||||||
public class AccessDeniedHandlerImpl implements AccessDeniedHandler {
|
public class AccessDeniedHandlerImpl implements AccessDeniedHandler {
|
||||||
@Override
|
@Override
|
||||||
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws ServletException {
|
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws ServletException {
|
||||||
accessDeniedException.printStackTrace();
|
log.error(accessDeniedException.getMessage());
|
||||||
ResponseResult result = ResponseResult.errorResult(AppHttpCodeEnum.NO_OPERATOR_AUTH);
|
ResponseResult<?> result = ResponseResult.failure(AppHttpCodeEnum.NO_OPERATOR_AUTH);
|
||||||
//响应给前端
|
//响应给前端
|
||||||
WebUtils.renderString(response, JSON.toJSONString(result));
|
WebUtils.renderString(response, JSON.toJSONString(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+11
-9
@@ -1,9 +1,10 @@
|
|||||||
package com.mzaxd.noodles.handler;
|
package com.mzaxd.bps.handler;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.mzaxd.noodles.domain.ResponseResult;
|
import com.mzaxd.bps.domain.ResponseResult;
|
||||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
import com.mzaxd.bps.enums.AppHttpCodeEnum;
|
||||||
import com.mzaxd.noodles.util.WebUtils;
|
import com.mzaxd.bps.util.WebUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.authentication.BadCredentialsException;
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
import org.springframework.security.authentication.InsufficientAuthenticationException;
|
import org.springframework.security.authentication.InsufficientAuthenticationException;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
@@ -17,20 +18,21 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
* @author root
|
* @author root
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
@Slf4j
|
||||||
public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint {
|
public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) {
|
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) {
|
||||||
authException.printStackTrace();
|
log.error(authException.getMessage());
|
||||||
//InsufficientAuthenticationException
|
//InsufficientAuthenticationException
|
||||||
//BadCredentialsException
|
//BadCredentialsException
|
||||||
ResponseResult result;
|
ResponseResult<?> result;
|
||||||
if (authException instanceof BadCredentialsException) {
|
if (authException instanceof BadCredentialsException) {
|
||||||
result = ResponseResult.errorResult(AppHttpCodeEnum.LOGIN_ERROR.getCode(), authException.getMessage());
|
result = ResponseResult.failure(AppHttpCodeEnum.LOGIN_ERROR.getCode(), authException.getMessage());
|
||||||
} else if (authException instanceof InsufficientAuthenticationException) {
|
} else if (authException instanceof InsufficientAuthenticationException) {
|
||||||
result = ResponseResult.errorResult(AppHttpCodeEnum.NEED_LOGIN);
|
result = ResponseResult.failure(AppHttpCodeEnum.NEED_LOGIN);
|
||||||
} else {
|
} else {
|
||||||
result = ResponseResult.errorResult(AppHttpCodeEnum.SYSTEM_ERROR.getCode(), "认证或授权失败");
|
result = ResponseResult.failure(AppHttpCodeEnum.SYSTEM_ERROR.getCode(), "认证或授权失败");
|
||||||
}
|
}
|
||||||
//响应给前端
|
//响应给前端
|
||||||
WebUtils.renderString(response, JSON.toJSONString(result));
|
WebUtils.renderString(response, JSON.toJSONString(result));
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.mzaxd.bps.handler;
|
||||||
|
|
||||||
|
import com.mzaxd.bps.domain.ResponseResult;
|
||||||
|
import com.mzaxd.bps.enums.AppHttpCodeEnum;
|
||||||
|
import com.mzaxd.bps.exception.SystemException;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author root
|
||||||
|
*/
|
||||||
|
@RestControllerAdvice
|
||||||
|
@Slf4j
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
|
@ExceptionHandler(SystemException.class)
|
||||||
|
public ResponseResult<?> systemExceptionHandler(SystemException e) {
|
||||||
|
//打印异常信息
|
||||||
|
log.error("出现了异常! {}", e.getMessage());
|
||||||
|
//从异常对象中获取提示信息封装返回
|
||||||
|
return ResponseResult.failure(e.getCode(), e.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(Exception.class)
|
||||||
|
public ResponseResult<?> exceptionHandler(Exception e) {
|
||||||
|
//打印异常信息
|
||||||
|
log.error("出现了异常! {}", e.getMessage());
|
||||||
|
//从异常对象中获取提示信息封装返回
|
||||||
|
return ResponseResult.failure(AppHttpCodeEnum.SYSTEM_ERROR, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-4
@@ -1,7 +1,8 @@
|
|||||||
package com.mzaxd.noodles.handler;
|
package com.mzaxd.bps.handler;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||||
import com.mzaxd.noodles.util.SecurityUtils;
|
import com.mzaxd.bps.util.SecurityUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.ibatis.reflection.MetaObject;
|
import org.apache.ibatis.reflection.MetaObject;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ import java.util.Date;
|
|||||||
/**
|
/**
|
||||||
* @author root
|
* @author root
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class MyMetaObjectHandler implements MetaObjectHandler {
|
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||||
@Override
|
@Override
|
||||||
@@ -18,7 +20,7 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
|||||||
try {
|
try {
|
||||||
userId = SecurityUtils.getUserId();
|
userId = SecurityUtils.getUserId();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error(e.getMessage());
|
||||||
//表示是自己创建
|
//表示是自己创建
|
||||||
userId = -1L;
|
userId = -1L;
|
||||||
}
|
}
|
||||||
@@ -40,4 +42,4 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
|||||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||||
this.setFieldValByName("updateBy", userId, metaObject);
|
this.setFieldValByName("updateBy", userId, metaObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-3
@@ -1,13 +1,12 @@
|
|||||||
package com.mzaxd.noodles.mapper;
|
package com.mzaxd.bps.mapper;
|
||||||
|
|
||||||
import com.mzaxd.noodles.domain.entity.AuditLog;
|
import com.mzaxd.bps.domain.entity.AuditLog;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 13439
|
* @author 13439
|
||||||
* @description 针对表【audit_log】的数据库操作Mapper
|
* @description 针对表【audit_log】的数据库操作Mapper
|
||||||
* @createDate 2023-02-13 12:19:26
|
* @createDate 2023-02-13 12:19:26
|
||||||
* @Entity com.mzaxd.noodles.domain.entity.AuditLog
|
|
||||||
*/
|
*/
|
||||||
public interface AuditLogMapper extends BaseMapper<AuditLog> {
|
public interface AuditLogMapper extends BaseMapper<AuditLog> {
|
||||||
|
|
||||||
+2
-3
@@ -1,13 +1,12 @@
|
|||||||
package com.mzaxd.noodles.mapper;
|
package com.mzaxd.bps.mapper;
|
||||||
|
|
||||||
import com.mzaxd.noodles.domain.entity.Notification;
|
import com.mzaxd.bps.domain.entity.Notification;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 13439
|
* @author 13439
|
||||||
* @description 针对表【notification】的数据库操作Mapper
|
* @description 针对表【notification】的数据库操作Mapper
|
||||||
* @createDate 2023-02-16 16:04:53
|
* @createDate 2023-02-16 16:04:53
|
||||||
* @Entity com.mzaxd.noodles.domain.entity.Notification
|
|
||||||
*/
|
*/
|
||||||
public interface NotificationMapper extends BaseMapper<Notification> {
|
public interface NotificationMapper extends BaseMapper<Notification> {
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.mzaxd.bps.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mzaxd.bps.domain.entity.SourceCategory;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘分类Mapper接口
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SourceCategoryMapper extends BaseMapper<SourceCategory> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.mzaxd.bps.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mzaxd.bps.domain.entity.SourceLog;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘日志Mapper接口
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SourceLogMapper extends BaseMapper<SourceLog> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.mzaxd.bps.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mzaxd.bps.domain.entity.Source;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘资源Mapper接口
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SourceMapper extends BaseMapper<Source> {
|
||||||
|
}
|
||||||
+2
-3
@@ -1,13 +1,12 @@
|
|||||||
package com.mzaxd.noodles.mapper;
|
package com.mzaxd.bps.mapper;
|
||||||
|
|
||||||
import com.mzaxd.noodles.domain.entity.SystemSetting;
|
import com.mzaxd.bps.domain.entity.SystemSetting;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 13439
|
* @author 13439
|
||||||
* @description 针对表【system_setting】的数据库操作Mapper
|
* @description 针对表【system_setting】的数据库操作Mapper
|
||||||
* @createDate 2023-02-16 20:25:57
|
* @createDate 2023-02-16 20:25:57
|
||||||
* @Entity com.mzaxd.noodles.domain.entity.SystemSetting
|
|
||||||
*/
|
*/
|
||||||
public interface SystemSettingMapper extends BaseMapper<SystemSetting> {
|
public interface SystemSettingMapper extends BaseMapper<SystemSetting> {
|
||||||
|
|
||||||
+2
-3
@@ -1,13 +1,12 @@
|
|||||||
package com.mzaxd.noodles.mapper;
|
package com.mzaxd.bps.mapper;
|
||||||
|
|
||||||
import com.mzaxd.noodles.domain.entity.User;
|
import com.mzaxd.bps.domain.entity.User;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author root
|
* @author root
|
||||||
* @description 针对表【user】的数据库操作Mapper
|
* @description 针对表【user】的数据库操作Mapper
|
||||||
* @createDate 2023-01-28 09:16:07
|
* @createDate 2023-01-28 09:16:07
|
||||||
* @Entity com.mzaxd.noodles.domain.entity.User
|
|
||||||
*/
|
*/
|
||||||
public interface UserMapper extends BaseMapper<User> {
|
public interface UserMapper extends BaseMapper<User> {
|
||||||
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.mzaxd.bps.service;
|
||||||
|
|
||||||
|
import com.mzaxd.bps.domain.CloudFile;
|
||||||
|
import com.mzaxd.bps.enums.CloudStorageType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface CloudStorageService {
|
||||||
|
/**
|
||||||
|
* Initialize the cloud storage service
|
||||||
|
*/
|
||||||
|
void initialize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Login to the cloud storage
|
||||||
|
* @param credentials login credentials
|
||||||
|
* @return true if login successful
|
||||||
|
*/
|
||||||
|
boolean login(Map<String, String> credentials);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for files in the cloud storage
|
||||||
|
* @param keyword search keyword
|
||||||
|
* @return list of search results
|
||||||
|
*/
|
||||||
|
List<CloudFile> search(String keyword);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download a file from the cloud storage
|
||||||
|
* @param fileId file identifier
|
||||||
|
* @param localPath local path to save the file
|
||||||
|
* @return true if download successful
|
||||||
|
*/
|
||||||
|
boolean download(String fileId, String localPath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload a file to the cloud storage
|
||||||
|
* @param localPath local file path
|
||||||
|
* @param remotePath remote path to save the file
|
||||||
|
* @return true if upload successful
|
||||||
|
*/
|
||||||
|
boolean upload(String localPath, String remotePath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a share link for a file
|
||||||
|
* @param fileId file identifier
|
||||||
|
* @return share link
|
||||||
|
*/
|
||||||
|
String createShareLink(String fileId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of cloud storage
|
||||||
|
* @return cloud storage type
|
||||||
|
*/
|
||||||
|
CloudStorageType getType();
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.mzaxd.bps.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mzaxd.bps.domain.entity.SourceCategory;
|
||||||
|
import com.mzaxd.bps.domain.vo.SourceCategoryVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘分类表(SourceCategory)表服务接口
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06 10:00:00
|
||||||
|
*/
|
||||||
|
public interface SourceCategoryService extends IService<SourceCategory> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分类列表
|
||||||
|
*
|
||||||
|
* @return 分类列表
|
||||||
|
*/
|
||||||
|
List<SourceCategoryVo> getCategoryList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增分类
|
||||||
|
*
|
||||||
|
* @param category 分类信息
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean addCategory(SourceCategory category);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新分类
|
||||||
|
*
|
||||||
|
* @param category 分类信息
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean updateCategory(SourceCategory category);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分类
|
||||||
|
*
|
||||||
|
* @param id 分类ID
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean deleteCategory(Long id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.mzaxd.bps.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mzaxd.bps.domain.entity.SourceLog;
|
||||||
|
import com.mzaxd.bps.domain.vo.PageVo;
|
||||||
|
import com.mzaxd.bps.domain.vo.SourceLogVo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘日志Service接口
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
public interface SourceLogService extends IService<SourceLog> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取日志列表
|
||||||
|
*
|
||||||
|
* @param pageNum 页码
|
||||||
|
* @param pageSize 每页大小
|
||||||
|
* @param sourceId 资源ID
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
PageVo<SourceLogVo> getLogList(Integer pageNum, Integer pageSize, Long sourceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加日志
|
||||||
|
*
|
||||||
|
* @param sourceId 资源ID
|
||||||
|
* @param ip IP地址
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean addLog(Long sourceId, String ip);
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package com.mzaxd.bps.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mzaxd.bps.domain.entity.Source;
|
||||||
|
import com.mzaxd.bps.domain.vo.PageVo;
|
||||||
|
import com.mzaxd.bps.domain.vo.SourceVo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘资源Service接口
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
public interface SourceService extends IService<Source> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取资源列表
|
||||||
|
*
|
||||||
|
* @param pageNum 页码
|
||||||
|
* @param pageSize 每页大小
|
||||||
|
* @param title 标题
|
||||||
|
* @param categoryId 分类ID
|
||||||
|
* @param isTime 是否定时
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
PageVo<SourceVo> getSourceList(Integer pageNum, Integer pageSize, String title, Long categoryId, Integer isTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取资源详情
|
||||||
|
*
|
||||||
|
* @param id 资源ID
|
||||||
|
* @return 资源详情
|
||||||
|
*/
|
||||||
|
SourceVo getSourceDetail(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资源
|
||||||
|
*
|
||||||
|
* @param source 资源信息
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean addSource(Source source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新资源
|
||||||
|
*
|
||||||
|
* @param source 资源信息
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean updateSource(Source source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资源
|
||||||
|
*
|
||||||
|
* @param id 资源ID
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean deleteSource(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索网盘资源
|
||||||
|
*
|
||||||
|
* @param pageNum 页码
|
||||||
|
* @param pageSize 每页大小
|
||||||
|
* @param keyword 关键词
|
||||||
|
* @param categoryId 分类ID
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
Page<Source> search(Integer pageNum, Integer pageSize, String keyword, Long categoryId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package com.mzaxd.bps.service.impl;
|
||||||
|
|
||||||
|
import com.mzaxd.bps.enums.BaiduPcsCommand;
|
||||||
|
import com.mzaxd.bps.enums.CloudStorageType;
|
||||||
|
import com.mzaxd.bps.domain.CloudFile;
|
||||||
|
import com.mzaxd.bps.service.CloudStorageService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BaiduPcsService implements CloudStorageService {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(BaiduPcsService.class);
|
||||||
|
private static final String EXECUTABLE_NAME = "baidupcs-go";
|
||||||
|
private String executablePath;
|
||||||
|
private boolean initialized = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
String os = System.getProperty("os.name").toLowerCase();
|
||||||
|
String resourcePath = os.contains("win") ? "baidu/win/" : "baidu/linux/";
|
||||||
|
|
||||||
|
ClassPathResource resource = new ClassPathResource(resourcePath + EXECUTABLE_NAME);
|
||||||
|
File tempFile = File.createTempFile(EXECUTABLE_NAME, "");
|
||||||
|
Files.copy(resource.getInputStream(), tempFile.toPath());
|
||||||
|
tempFile.setExecutable(true);
|
||||||
|
|
||||||
|
executablePath = tempFile.getAbsolutePath();
|
||||||
|
initialized = true;
|
||||||
|
logger.info("BaiduPCS-GO initialized successfully at: {}", executablePath);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("Failed to initialize BaiduPCS-GO", e);
|
||||||
|
throw new RuntimeException("Failed to initialize BaiduPCS-GO", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean login(Map<String, String> credentials) {
|
||||||
|
String username = credentials.get("username");
|
||||||
|
String password = credentials.get("password");
|
||||||
|
|
||||||
|
if (username == null || password == null) {
|
||||||
|
throw new IllegalArgumentException("Username and password are required");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder(
|
||||||
|
executablePath,
|
||||||
|
BaiduPcsCommand.LOGIN.getCommand(),
|
||||||
|
username,
|
||||||
|
password
|
||||||
|
);
|
||||||
|
|
||||||
|
Process process = processBuilder.start();
|
||||||
|
return process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0;
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
logger.error("Login failed", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CloudFile> search(String keyword) {
|
||||||
|
try {
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder(
|
||||||
|
executablePath,
|
||||||
|
BaiduPcsCommand.SEARCH.getCommand(),
|
||||||
|
keyword
|
||||||
|
);
|
||||||
|
|
||||||
|
Process process = processBuilder.start();
|
||||||
|
if (process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0) {
|
||||||
|
// Parse the output and convert to CloudFile objects
|
||||||
|
// This is a simplified version, you'll need to implement proper parsing
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
logger.error("Search failed", e);
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean download(String fileId, String localPath) {
|
||||||
|
try {
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder(
|
||||||
|
executablePath,
|
||||||
|
BaiduPcsCommand.DOWNLOAD.getCommand(),
|
||||||
|
fileId,
|
||||||
|
localPath
|
||||||
|
);
|
||||||
|
|
||||||
|
Process process = processBuilder.start();
|
||||||
|
return process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0;
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
logger.error("Download failed", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean upload(String localPath, String remotePath) {
|
||||||
|
try {
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder(
|
||||||
|
executablePath,
|
||||||
|
BaiduPcsCommand.UPLOAD.getCommand(),
|
||||||
|
localPath,
|
||||||
|
remotePath
|
||||||
|
);
|
||||||
|
|
||||||
|
Process process = processBuilder.start();
|
||||||
|
return process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0;
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
logger.error("Upload failed", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createShareLink(String fileId) {
|
||||||
|
try {
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder(
|
||||||
|
executablePath,
|
||||||
|
BaiduPcsCommand.SHARE.getCommand(),
|
||||||
|
fileId
|
||||||
|
);
|
||||||
|
|
||||||
|
Process process = processBuilder.start();
|
||||||
|
if (process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0) {
|
||||||
|
// Parse the output to get the share link
|
||||||
|
// This is a simplified version, you'll need to implement proper parsing
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
logger.error("Create share link failed", e);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CloudStorageType getType() {
|
||||||
|
return CloudStorageType.BAIDU;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.mzaxd.bps.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mzaxd.bps.domain.entity.SourceCategory;
|
||||||
|
import com.mzaxd.bps.domain.vo.SourceCategoryVo;
|
||||||
|
import com.mzaxd.bps.mapper.SourceCategoryMapper;
|
||||||
|
import com.mzaxd.bps.service.SourceCategoryService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘分类表(SourceCategory)表服务实现类
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06 10:00:00
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SourceCategoryServiceImpl extends ServiceImpl<SourceCategoryMapper, SourceCategory> implements SourceCategoryService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SourceCategoryVo> getCategoryList() {
|
||||||
|
// 构建查询条件
|
||||||
|
LambdaQueryWrapper<SourceCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SourceCategory::getStatus, 0)
|
||||||
|
.orderByDesc(SourceCategory::getSort);
|
||||||
|
|
||||||
|
// 查询分类列表
|
||||||
|
List<SourceCategory> categories = list(queryWrapper);
|
||||||
|
|
||||||
|
// 转换为VO
|
||||||
|
return categories.stream().map(category -> {
|
||||||
|
SourceCategoryVo categoryVo = new SourceCategoryVo();
|
||||||
|
BeanUtils.copyProperties(category, categoryVo);
|
||||||
|
categoryVo.setId(category.getSourceCategoryId());
|
||||||
|
return categoryVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addCategory(SourceCategory category) {
|
||||||
|
return save(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateCategory(SourceCategory category) {
|
||||||
|
return updateById(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteCategory(Long id) {
|
||||||
|
return removeById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package com.mzaxd.bps.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mzaxd.bps.domain.entity.Source;
|
||||||
|
import com.mzaxd.bps.domain.entity.SourceLog;
|
||||||
|
import com.mzaxd.bps.domain.vo.PageVo;
|
||||||
|
import com.mzaxd.bps.domain.vo.SourceLogVo;
|
||||||
|
import com.mzaxd.bps.mapper.SourceLogMapper;
|
||||||
|
import com.mzaxd.bps.mapper.SourceMapper;
|
||||||
|
import com.mzaxd.bps.service.SourceLogService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘日志表(SourceLog)表服务实现类
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06 10:00:00
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SourceLogServiceImpl extends ServiceImpl<SourceLogMapper, SourceLog> implements SourceLogService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SourceMapper sourceMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageVo<SourceLogVo> getLogList(Integer pageNum, Integer pageSize, Long sourceId) {
|
||||||
|
// 构建查询条件
|
||||||
|
LambdaQueryWrapper<SourceLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (sourceId != null) {
|
||||||
|
queryWrapper.eq(SourceLog::getSourceId, sourceId);
|
||||||
|
}
|
||||||
|
queryWrapper.orderByDesc(SourceLog::getCreateTime);
|
||||||
|
|
||||||
|
// 分页查询
|
||||||
|
Page<SourceLog> page = new Page<>(pageNum, pageSize);
|
||||||
|
page(page, queryWrapper);
|
||||||
|
|
||||||
|
// 转换为VO
|
||||||
|
List<SourceLogVo> logVos = page.getRecords().stream().map(log -> {
|
||||||
|
SourceLogVo logVo = new SourceLogVo();
|
||||||
|
BeanUtils.copyProperties(log, logVo);
|
||||||
|
logVo.setId(log.getLogId());
|
||||||
|
|
||||||
|
// 查询资源标题
|
||||||
|
Source source = sourceMapper.selectById(log.getSourceId());
|
||||||
|
if (source != null) {
|
||||||
|
logVo.setSourceTitle(source.getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
return logVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 封装返回结果
|
||||||
|
PageVo<SourceLogVo> pageVo = new PageVo<>();
|
||||||
|
pageVo.setTotal(page.getTotal());
|
||||||
|
pageVo.setRows(logVos);
|
||||||
|
|
||||||
|
return pageVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addLog(Long sourceId, String ip) {
|
||||||
|
SourceLog log = new SourceLog();
|
||||||
|
log.setSourceId(sourceId);
|
||||||
|
log.setIp(ip);
|
||||||
|
return save(log);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
package com.mzaxd.bps.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mzaxd.bps.domain.entity.Source;
|
||||||
|
import com.mzaxd.bps.domain.entity.SourceCategory;
|
||||||
|
import com.mzaxd.bps.domain.vo.PageVo;
|
||||||
|
import com.mzaxd.bps.domain.vo.SourceVo;
|
||||||
|
import com.mzaxd.bps.mapper.SourceMapper;
|
||||||
|
import com.mzaxd.bps.mapper.SourceCategoryMapper;
|
||||||
|
import com.mzaxd.bps.service.SourceService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网盘资源表(Source)表服务实现类
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06 10:00:00
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> implements SourceService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SourceCategoryMapper sourceCategoryMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageVo<SourceVo> getSourceList(Integer pageNum, Integer pageSize, String title, Long categoryId, Integer isTime) {
|
||||||
|
// 构建查询条件
|
||||||
|
LambdaQueryWrapper<Source> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(Source::getStatus, 1)
|
||||||
|
.eq(Source::getIsDelete, 0);
|
||||||
|
|
||||||
|
if (StringUtils.hasText(title)) {
|
||||||
|
queryWrapper.like(Source::getTitle, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (categoryId != null) {
|
||||||
|
queryWrapper.eq(Source::getSourceCategoryId, categoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isTime != null) {
|
||||||
|
queryWrapper.eq(Source::getIsTime, isTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页查询
|
||||||
|
Page<Source> page = new Page<>(pageNum, pageSize);
|
||||||
|
page(page, queryWrapper);
|
||||||
|
|
||||||
|
// 转换为VO
|
||||||
|
List<SourceVo> sourceVos = page.getRecords().stream().map(source -> {
|
||||||
|
SourceVo sourceVo = new SourceVo();
|
||||||
|
BeanUtils.copyProperties(source, sourceVo);
|
||||||
|
sourceVo.setId(source.getSourceId());
|
||||||
|
|
||||||
|
// 查询分类名称
|
||||||
|
SourceCategory category = sourceCategoryMapper.selectById(source.getSourceCategoryId());
|
||||||
|
if (category != null) {
|
||||||
|
sourceVo.setCategoryName(category.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return sourceVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 封装返回结果
|
||||||
|
PageVo<SourceVo> pageVo = new PageVo<>();
|
||||||
|
pageVo.setTotal(page.getTotal());
|
||||||
|
pageVo.setRows(sourceVos);
|
||||||
|
|
||||||
|
return pageVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SourceVo getSourceDetail(Long id) {
|
||||||
|
// 查询资源
|
||||||
|
Source source = getById(id);
|
||||||
|
if (source == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换为VO
|
||||||
|
SourceVo sourceVo = new SourceVo();
|
||||||
|
BeanUtils.copyProperties(source, sourceVo);
|
||||||
|
sourceVo.setId(source.getSourceId());
|
||||||
|
|
||||||
|
// 查询分类名称
|
||||||
|
SourceCategory category = sourceCategoryMapper.selectById(source.getSourceCategoryId());
|
||||||
|
if (category != null) {
|
||||||
|
sourceVo.setCategoryName(category.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 增加浏览量
|
||||||
|
source.setPageViews(source.getPageViews() + 1);
|
||||||
|
updateById(source);
|
||||||
|
|
||||||
|
return sourceVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addSource(Source source) {
|
||||||
|
return save(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateSource(Source source) {
|
||||||
|
return updateById(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteSource(Long id) {
|
||||||
|
return removeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Source> search(Integer pageNum, Integer pageSize, String keyword, Long categoryId) {
|
||||||
|
LambdaQueryWrapper<Source> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
// 关键词搜索(标题、描述、代码)
|
||||||
|
if (StringUtils.hasText(keyword)) {
|
||||||
|
queryWrapper.and(wrapper -> wrapper
|
||||||
|
.like(Source::getTitle, keyword)
|
||||||
|
.or()
|
||||||
|
.like(Source::getDescription, keyword)
|
||||||
|
.or()
|
||||||
|
.like(Source::getCode, keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分类筛选
|
||||||
|
if (categoryId != null) {
|
||||||
|
queryWrapper.eq(Source::getSourceCategoryId, categoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 只查询未删除的资源
|
||||||
|
queryWrapper.eq(Source::getIsDelete, 0)
|
||||||
|
.eq(Source::getStatus, 1)
|
||||||
|
.orderByDesc(Source::getCreateTime);
|
||||||
|
|
||||||
|
return page(new Page<>(pageNum, pageSize), queryWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodledetector.util;
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mzaxd
|
* @author Mzaxd
|
||||||
+4
-2
@@ -1,5 +1,6 @@
|
|||||||
package com.mzaxd.noodles.util;
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -9,6 +10,7 @@ import java.util.stream.Collectors;
|
|||||||
* @author Mzaxd
|
* @author Mzaxd
|
||||||
* @since 2022-11-22 15:36
|
* @since 2022-11-22 15:36
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class BeanCopyUtils {
|
public class BeanCopyUtils {
|
||||||
|
|
||||||
private BeanCopyUtils() {
|
private BeanCopyUtils() {
|
||||||
@@ -22,7 +24,7 @@ public class BeanCopyUtils {
|
|||||||
//实现属性copy
|
//实现属性copy
|
||||||
BeanUtils.copyProperties(source, result);
|
BeanUtils.copyProperties(source, result);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
//返回结果
|
//返回结果
|
||||||
return result;
|
return result;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.util;
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
import oshi.SystemInfo;
|
import oshi.SystemInfo;
|
||||||
import oshi.hardware.CentralProcessor;
|
import oshi.hardware.CentralProcessor;
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件操作工具类
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
public class FileUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
* @param file 文件
|
||||||
|
* @param path 保存路径
|
||||||
|
* @return 文件名
|
||||||
|
*/
|
||||||
|
public static String upload(MultipartFile file, String path) throws IOException {
|
||||||
|
// 获取文件名
|
||||||
|
String originalFilename = file.getOriginalFilename();
|
||||||
|
// 获取文件后缀
|
||||||
|
String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||||
|
// 生成新文件名
|
||||||
|
String fileName = UUID.randomUUID().toString() + suffix;
|
||||||
|
// 创建文件对象
|
||||||
|
File dest = new File(path + fileName);
|
||||||
|
// 判断路径是否存在,不存在则创建
|
||||||
|
if (!dest.getParentFile().exists()) {
|
||||||
|
dest.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
// 保存文件
|
||||||
|
file.transferTo(dest);
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文件
|
||||||
|
*
|
||||||
|
* @param path 文件路径
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
public static boolean delete(String path) {
|
||||||
|
File file = new File(path);
|
||||||
|
if (file.exists() && file.isFile()) {
|
||||||
|
return file.delete();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodledetector.util;
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
+2
-3
@@ -1,10 +1,9 @@
|
|||||||
package com.mzaxd.noodles.util;
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.JwtBuilder;
|
import io.jsonwebtoken.JwtBuilder;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
@@ -119,4 +118,4 @@ public class JwtUtil {
|
|||||||
.parseClaimsJws(jwt)
|
.parseClaimsJws(jwt)
|
||||||
.getBody();
|
.getBody();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-18
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.util;
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
import org.springframework.data.redis.core.BoundSetOperations;
|
import org.springframework.data.redis.core.BoundSetOperations;
|
||||||
import org.springframework.data.redis.core.HashOperations;
|
import org.springframework.data.redis.core.HashOperations;
|
||||||
@@ -71,7 +71,7 @@ public class RedisCache {
|
|||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
public boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
||||||
return redisTemplate.expire(key, timeout, unit);
|
return Boolean.TRUE.equals(redisTemplate.expire(key, timeout, unit));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,18 +101,8 @@ public class RedisCache {
|
|||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public boolean deleteObject(final String key) {
|
public void deleteObject(final String key) {
|
||||||
return redisTemplate.delete(key);
|
redisTemplate.delete(key);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除集合对象
|
|
||||||
*
|
|
||||||
* @param collection 多个对象
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public long deleteObject(final Collection collection) {
|
|
||||||
return redisTemplate.delete(collection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,9 +136,8 @@ public class RedisCache {
|
|||||||
*/
|
*/
|
||||||
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
|
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
|
||||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||||
Iterator<T> it = dataSet.iterator();
|
for (T t : dataSet) {
|
||||||
while (it.hasNext()) {
|
setOperation.add(t);
|
||||||
setOperation.add(it.next());
|
|
||||||
}
|
}
|
||||||
return setOperation;
|
return setOperation;
|
||||||
}
|
}
|
||||||
@@ -252,4 +241,4 @@ public class RedisCache {
|
|||||||
public void incrementCacheMapValue(String key, String hKey, long v) {
|
public void incrementCacheMapValue(String key, String hKey, long v) {
|
||||||
redisTemplate.boundHashOps(key).increment(hKey, v);
|
redisTemplate.boundHashOps(key).increment(hKey, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一响应结果
|
||||||
|
*
|
||||||
|
* @author mzaxd
|
||||||
|
* @since 2024-04-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Result<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态码
|
||||||
|
*/
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提示信息
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据
|
||||||
|
*/
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功
|
||||||
|
*/
|
||||||
|
public static <T> Result<T> success() {
|
||||||
|
return success(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功
|
||||||
|
*/
|
||||||
|
public static <T> Result<T> success(T data) {
|
||||||
|
Result<T> result = new Result<>();
|
||||||
|
result.setCode(200);
|
||||||
|
result.setMessage("success");
|
||||||
|
result.setData(data);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 失败
|
||||||
|
*/
|
||||||
|
public static <T> Result<T> error(String message) {
|
||||||
|
return error(500, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 失败
|
||||||
|
*/
|
||||||
|
public static <T> Result<T> error(Integer code, String message) {
|
||||||
|
Result<T> result = new Result<>();
|
||||||
|
result.setCode(code);
|
||||||
|
result.setMessage(message);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-4
@@ -1,11 +1,10 @@
|
|||||||
package com.mzaxd.noodles.util;
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
import com.mzaxd.noodles.domain.search.SearchCategory;
|
import com.mzaxd.bps.domain.search.SearchCategory;
|
||||||
import com.mzaxd.noodles.domain.search.SearchItem;
|
import com.mzaxd.bps.domain.search.SearchItem;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ThinkBook
|
* @author ThinkBook
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
package com.mzaxd.noodles.util;
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
import com.mzaxd.noodles.domain.entity.LoginUser;
|
import com.mzaxd.bps.domain.entity.LoginUser;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
|
||||||
@@ -31,4 +31,4 @@ public class SecurityUtils {
|
|||||||
public static Long getUserId() {
|
public static Long getUserId() {
|
||||||
return getLoginUser().getUser().getId();
|
return getLoginUser().getUser().getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 13439
|
||||||
|
*/
|
||||||
|
public class SshLinkUtil {
|
||||||
|
|
||||||
|
}
|
||||||
+12
-12
@@ -1,4 +1,4 @@
|
|||||||
package com.mzaxd.noodles.util;
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -23,10 +23,10 @@ import java.util.Properties;
|
|||||||
**/
|
**/
|
||||||
public class SystemInfoUtils {
|
public class SystemInfoUtils {
|
||||||
private static final int OSHI_WAIT_SECOND = 1000;
|
private static final int OSHI_WAIT_SECOND = 1000;
|
||||||
private static SystemInfo systemInfo = new SystemInfo();
|
private static final SystemInfo systemInfo = new SystemInfo();
|
||||||
private static HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
private static final HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
||||||
private static OperatingSystem operatingSystem = systemInfo.getOperatingSystem();
|
private static final OperatingSystem operatingSystem = systemInfo.getOperatingSystem();
|
||||||
|
|
||||||
public static JSONObject getCpuInfo() {
|
public static JSONObject getCpuInfo() {
|
||||||
JSONObject cpuInfo = new JSONObject();
|
JSONObject cpuInfo = new JSONObject();
|
||||||
CentralProcessor processor = hardware.getProcessor();
|
CentralProcessor processor = hardware.getProcessor();
|
||||||
@@ -55,7 +55,7 @@ public class SystemInfoUtils {
|
|||||||
cpuInfo.put("idle", new DecimalFormat("#.##%").format(1.0 - (idle * 1.0 / totalCpu)));
|
cpuInfo.put("idle", new DecimalFormat("#.##%").format(1.0 - (idle * 1.0 / totalCpu)));
|
||||||
return cpuInfo;
|
return cpuInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统jvm信息
|
* 系统jvm信息
|
||||||
*/
|
*/
|
||||||
@@ -81,7 +81,7 @@ public class SystemInfoUtils {
|
|||||||
cpuInfo.put("jdkHome", props.getProperty("java.home"));
|
cpuInfo.put("jdkHome", props.getProperty("java.home"));
|
||||||
return cpuInfo;
|
return cpuInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统内存信息
|
* 系统内存信息
|
||||||
*/
|
*/
|
||||||
@@ -102,7 +102,7 @@ public class SystemInfoUtils {
|
|||||||
cpuInfo.put("usageRate", new DecimalFormat("#.##%").format((totalByte - acaliableByte) * 1.0 / totalByte));
|
cpuInfo.put("usageRate", new DecimalFormat("#.##%").format((totalByte - acaliableByte) * 1.0 / totalByte));
|
||||||
return cpuInfo;
|
return cpuInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统盘符信息
|
* 系统盘符信息
|
||||||
*/
|
*/
|
||||||
@@ -135,7 +135,7 @@ public class SystemInfoUtils {
|
|||||||
}
|
}
|
||||||
return sysFiles;
|
return sysFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统信息
|
* 系统信息
|
||||||
*/
|
*/
|
||||||
@@ -154,7 +154,7 @@ public class SystemInfoUtils {
|
|||||||
cpuInfo.put("userDir", props.getProperty("user.dir"));
|
cpuInfo.put("userDir", props.getProperty("user.dir"));
|
||||||
return cpuInfo;
|
return cpuInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所有系统信息
|
* 所有系统信息
|
||||||
*/
|
*/
|
||||||
@@ -167,7 +167,7 @@ public class SystemInfoUtils {
|
|||||||
info.put("sysFileInfo", getSysFileInfo());
|
info.put("sysFileInfo", getSysFileInfo());
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单位转换
|
* 单位转换
|
||||||
*/
|
*/
|
||||||
@@ -189,4 +189,4 @@ public class SystemInfoUtils {
|
|||||||
double tbNumber = gbNumber / FORMAT;
|
double tbNumber = gbNumber / FORMAT;
|
||||||
return new DecimalFormat("#.##TB").format(tbNumber);
|
return new DecimalFormat("#.##TB").format(tbNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+8
-4
@@ -1,13 +1,17 @@
|
|||||||
package com.mzaxd.noodles.util;
|
package com.mzaxd.bps.util;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author root
|
* @author root
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class WebUtils {
|
public class WebUtils {
|
||||||
/**
|
/**
|
||||||
* 将字符串渲染到客户端
|
* 将字符串渲染到客户端
|
||||||
@@ -23,7 +27,7 @@ public class WebUtils {
|
|||||||
response.setCharacterEncoding("utf-8");
|
response.setCharacterEncoding("utf-8");
|
||||||
response.getWriter().print(string);
|
response.getWriter().print(string);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +35,7 @@ public class WebUtils {
|
|||||||
public static void setDownLoadHeader(String filename, HttpServletResponse response) throws UnsupportedEncodingException {
|
public static void setDownLoadHeader(String filename, HttpServletResponse response) throws UnsupportedEncodingException {
|
||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
response.setCharacterEncoding("utf-8");
|
response.setCharacterEncoding("utf-8");
|
||||||
String fname= URLEncoder.encode(filename,"UTF-8").replaceAll("\\+", "%20");
|
String fname= URLEncoder.encode(filename, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||||
response.setHeader("Content-disposition","attachment; filename="+fname);
|
response.setHeader("Content-disposition","attachment; filename="+fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package com.mzaxd.noodles.aspect;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.mzaxd.noodles.annotation.SysLog;
|
|
||||||
import com.mzaxd.noodles.domain.entity.AuditLog;
|
|
||||||
import com.mzaxd.noodles.enums.OperationEnum;
|
|
||||||
import com.mzaxd.noodles.service.AuditLogService;
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
|
||||||
import org.aspectj.lang.annotation.Around;
|
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
|
||||||
import org.aspectj.lang.annotation.Pointcut;
|
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 13439
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@Aspect
|
|
||||||
public class SysLogAspect {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AuditLogService auditLogService;
|
|
||||||
|
|
||||||
@Pointcut("@annotation(com.mzaxd.noodles.annotation.SysLog)")
|
|
||||||
public void logPointCut() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//方法执行前后都操作
|
|
||||||
@Around("logPointCut()")
|
|
||||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
|
||||||
//执行方法
|
|
||||||
Object result = point.proceed();
|
|
||||||
//保存日志
|
|
||||||
saveSysLog(point);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveSysLog(ProceedingJoinPoint joinPoint) {
|
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
|
||||||
Method method = signature.getMethod();
|
|
||||||
|
|
||||||
AuditLog log = new AuditLog();
|
|
||||||
SysLog syslog = method.getAnnotation(SysLog.class);
|
|
||||||
if (syslog != null) {
|
|
||||||
//注解上的描述
|
|
||||||
log.setOperation(syslog.operation().getOperation());
|
|
||||||
log.setOperationType(syslog.operation().getOperationType());
|
|
||||||
}
|
|
||||||
|
|
||||||
//请求的参数
|
|
||||||
Object[] args = joinPoint.getArgs();
|
|
||||||
try {
|
|
||||||
String params = JSON.toJSONString(args);
|
|
||||||
log.setParam(params);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
//保存系统日志
|
|
||||||
auditLogService.save(log);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.mzaxd.noodles.config;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.mzaxd.noodles.constant.RabbitMqConstant;
|
|
||||||
import org.springframework.amqp.core.Binding;
|
|
||||||
import org.springframework.amqp.core.BindingBuilder;
|
|
||||||
import org.springframework.amqp.core.DirectExchange;
|
|
||||||
import org.springframework.amqp.core.Queue;
|
|
||||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
|
||||||
import org.springframework.amqp.support.converter.MessageConverter;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mzaxd
|
|
||||||
* @since 2023-02-06 12:51
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class RabbitMqConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Queue rabbitmqDemoDirectQueue() {
|
|
||||||
/**
|
|
||||||
* 1、name: 队列名称
|
|
||||||
* 2、durable: 是否持久化
|
|
||||||
* 3、exclusive: 是否独享、排外的。如果设置为true,定义为排他队列。则只有创建者可以使用此队列。也就是private私有的。
|
|
||||||
* 4、autoDelete: 是否自动删除。也就是临时队列。当最后一个消费者断开连接后,会自动删除。
|
|
||||||
* */
|
|
||||||
return new Queue(RabbitMqConstant.DYNAMIC_DATA_TOPIC, true, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public DirectExchange rabbitmqDemoDirectExchange() {
|
|
||||||
//Direct交换机
|
|
||||||
return new DirectExchange(RabbitMqConstant.DYNAMIC_DATA_EXCHANGE, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Binding bindDirect() {
|
|
||||||
//链式写法,绑定交换机和队列,并设置匹配键
|
|
||||||
return BindingBuilder
|
|
||||||
//绑定队列
|
|
||||||
.bind(rabbitmqDemoDirectQueue())
|
|
||||||
//到交换机
|
|
||||||
.to(rabbitmqDemoDirectExchange())
|
|
||||||
//并设置匹配键
|
|
||||||
.with(RabbitMqConstant.DYNAMIC_DATA_ROUTING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MessageConverter jsonMessageConverter(ObjectMapper objectMapper) {
|
|
||||||
return new Jackson2JsonMessageConverter(objectMapper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.mzaxd.noodles.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mzaxd
|
|
||||||
* @since 2023-02-05 11:38
|
|
||||||
*/
|
|
||||||
public class OsConstant {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作系统为Linux
|
|
||||||
*/
|
|
||||||
public static final String LINUX = "linux";
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.mzaxd.noodles.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author root
|
|
||||||
*/
|
|
||||||
public class RabbitMqConstant {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RabbitMQ的队列主题名称
|
|
||||||
*/
|
|
||||||
public static final String DYNAMIC_DATA_TOPIC = "DynamicDataTopic";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RabbitMQ的direct交换机名称
|
|
||||||
*/
|
|
||||||
public static final String DYNAMIC_DATA_EXCHANGE = "DynamicDataExchange";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RabbitMQ的direct交换机和队列绑定的匹配键 DirectRouting
|
|
||||||
*/
|
|
||||||
public static final String DYNAMIC_DATA_ROUTING = "DynamicDataRouting";
|
|
||||||
}
|
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
package com.mzaxd.noodles.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author root
|
|
||||||
*/
|
|
||||||
public class SystemConstant {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 宿主机id等于0表示没有宿主机,即物理机
|
|
||||||
*/
|
|
||||||
public static final Integer PHYSICAL_MACHINE = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主机在线
|
|
||||||
*/
|
|
||||||
public static final Integer HOST_MACHINE_STATE_ONLINE = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主机离线
|
|
||||||
*/
|
|
||||||
public static final Integer HOST_MACHINE_STATE_OFFLINE = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主机睡眠
|
|
||||||
*/
|
|
||||||
public static final Integer HOST_MACHINE_STATE_SLEEP = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主机状态未知
|
|
||||||
*/
|
|
||||||
public static final Integer HOST_MACHINE_STATE_UNKNOWN = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 物理机 host_machine_id 是 0
|
|
||||||
*/
|
|
||||||
public static final Long HOST_MACHINE_ID_HOST = 0L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 成功id
|
|
||||||
*/
|
|
||||||
public static final Integer SUCCESS_CODE = 200;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 容器正在运行
|
|
||||||
*/
|
|
||||||
public static final Integer CONTAINER_STATE_RUNNING = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 容器停止
|
|
||||||
*/
|
|
||||||
public static final Integer CONTAINER_STATE_EXITED = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 容器暂停
|
|
||||||
*/
|
|
||||||
public static final Integer CONTAINER_STATE_PAUSED = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 容器状态未知
|
|
||||||
*/
|
|
||||||
public static final Integer CONTAINER_STATE_UNKNOWN = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正常状态(非第一次使用) 通用常量
|
|
||||||
*/
|
|
||||||
public static final Integer NORMAL_STATE = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志类型为用户
|
|
||||||
*/
|
|
||||||
public static final String LOG_USER = "用户";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提醒方式-不提醒
|
|
||||||
*/
|
|
||||||
public static final Integer NOTIFY_NO = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提醒方式-浏览器
|
|
||||||
*/
|
|
||||||
public static final Integer NOTIFY_BROWSER = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提醒方式-邮件
|
|
||||||
*/
|
|
||||||
public static final Integer NOTIFY_EMAIL = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提醒方式-浏览器和邮件
|
|
||||||
*/
|
|
||||||
public static final Integer NOTIFY_BROWSER_EMAIL = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知类型 掉线
|
|
||||||
*/
|
|
||||||
public static final Integer OFFLINE_NOTIFICATION = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知类型 统计
|
|
||||||
*/
|
|
||||||
public static final Integer STATISTICS_NOTIFICATION = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 未处理的通知
|
|
||||||
*/
|
|
||||||
public static final Integer NOTIFICATION_NOT_AFFIRM = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已处理的通知
|
|
||||||
*/
|
|
||||||
public static final Integer NOTIFICATION_AFFIRM = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端页面通知提醒页面对应的tab
|
|
||||||
*/
|
|
||||||
public static final Integer FRONTEND_NOTIFICATION_NOT_AFFIRM = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端页面通知提醒页面对应的tab
|
|
||||||
*/
|
|
||||||
public static final Integer FRONTEND_NOTIFICATION_AFFIRM = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端页面通知提醒页面对应的tab
|
|
||||||
*/
|
|
||||||
public static final Integer FRONTEND_NOTIFICATION_ALL = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端页面通知提醒页面对应的tab
|
|
||||||
*/
|
|
||||||
public static final Integer FRONTEND_NOTIFICATION_TYPE_OFFLINE = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端页面通知提醒页面对应的tab
|
|
||||||
*/
|
|
||||||
public static final Integer FRONTEND_NOTIFICATION_TYPE_STATISTICS = 4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知实例类型 无
|
|
||||||
*/
|
|
||||||
public static final Integer INSTANCETYPE_NONE = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知实例类型 物理机
|
|
||||||
*/
|
|
||||||
public static final Integer INSTANCETYPE_HOST = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知实例类型 虚拟机
|
|
||||||
*/
|
|
||||||
public static final Integer INSTANCETYPE_VM = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知实例类型 容器
|
|
||||||
*/
|
|
||||||
public static final Integer INSTANCETYPE_CONTAINER = 3;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.mzaxd.noodles.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author root
|
|
||||||
*/
|
|
||||||
public class UrlConstant {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* isTrueUrl判断地址是否有效的链接
|
|
||||||
*/
|
|
||||||
public static final String DETECTOR_IS_TRUE_URL = "/isTrueUrl";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主机信息链接
|
|
||||||
*/
|
|
||||||
public static final String DETECTOR_GET_INFO = "/getInfo";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主机信息链接
|
|
||||||
*/
|
|
||||||
public static final String DETECTOR_GET_DISK_INFO = "/getDiskInfo";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主机信息链接
|
|
||||||
*/
|
|
||||||
public static final String DETECTOR_GET_NETWORK_IF_INFO = "/getNetworkIfInfo";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取探测器uuid
|
|
||||||
*/
|
|
||||||
public static final String DETECTOR_GET_DETECTOR_ID = "/getDetectorID";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知探测器开始发送动态数据
|
|
||||||
*/
|
|
||||||
public static final String DETECTOR_START_SEND_DYNAMIC_DATA = "/startSendDynamicDataFromMq";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知探测器停止发送动态数据
|
|
||||||
*/
|
|
||||||
public static final String DETECTOR_STOP_SEND_DYNAMIC_DATA = "/stopSendDynamicDataFromMq";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 协议
|
|
||||||
*/
|
|
||||||
public static final String PROTOCOL = "protocol";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ip
|
|
||||||
*/
|
|
||||||
public static final String IP = "IP";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 端口号
|
|
||||||
*/
|
|
||||||
public static final String PORT = "port";
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package com.mzaxd.noodles.controller;
|
|
||||||
|
|
||||||
import com.mzaxd.noodles.annotation.SysLog;
|
|
||||||
import com.mzaxd.noodles.domain.ResponseResult;
|
|
||||||
import com.mzaxd.noodles.domain.entity.User;
|
|
||||||
import com.mzaxd.noodles.enums.OperationEnum;
|
|
||||||
import com.mzaxd.noodles.service.LoginService;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author root
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/auth")
|
|
||||||
public class AuthController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private LoginService loginService;
|
|
||||||
|
|
||||||
@PostMapping("/login")
|
|
||||||
public ResponseResult login(@RequestBody User user) {
|
|
||||||
return loginService.login(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SysLog(operation = OperationEnum.USER_FIRST_USE)
|
|
||||||
@PostMapping("/updateAccount")
|
|
||||||
public ResponseResult updateAccount(@RequestBody User user) {
|
|
||||||
return loginService.updateAccount(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/logout")
|
|
||||||
public ResponseResult logout() {
|
|
||||||
return loginService.logout();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/deleteAccount")
|
|
||||||
public ResponseResult deleteAccount() {
|
|
||||||
return loginService.deleteAccount();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package com.mzaxd.noodles.controller;
|
|
||||||
|
|
||||||
import com.mzaxd.noodles.annotation.SysLog;
|
|
||||||
import com.mzaxd.noodles.domain.ResponseResult;
|
|
||||||
import com.mzaxd.noodles.domain.vo.ContainerVo;
|
|
||||||
import com.mzaxd.noodles.enums.OperationEnum;
|
|
||||||
import com.mzaxd.noodles.service.ContainerService;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author root
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/container")
|
|
||||||
public class ContainerController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ContainerService containerService;
|
|
||||||
|
|
||||||
@GetMapping("/containerList/summaryStatistics")
|
|
||||||
public ResponseResult containerListSummaryStatistics() {
|
|
||||||
return containerService.containerListSummaryStatistics();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/containerList")
|
|
||||||
public ResponseResult containerListWithCondition(
|
|
||||||
@RequestParam(value = "q", required = false) String nameLike,
|
|
||||||
@RequestParam(value = "selectedHost", required = false) List<Integer> selectedHost,
|
|
||||||
@RequestParam(value = "selectedStatus", required = false) List<Integer> selectedStatus,
|
|
||||||
@RequestParam("perPage") Integer perPage,
|
|
||||||
@RequestParam("currentPage") Integer currentPage) {
|
|
||||||
return containerService.containerListWithCondition(nameLike, selectedHost, selectedStatus, perPage, currentPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/allHost")
|
|
||||||
public ResponseResult hostDrawer() {
|
|
||||||
return containerService.getAllHost();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SysLog(operation = OperationEnum.CONTAINER_DELETE)
|
|
||||||
@DeleteMapping("/delete/{id}")
|
|
||||||
public ResponseResult deleteContainer(@PathVariable("id") Integer id) {
|
|
||||||
return containerService.deleteContainerById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SysLog(operation = OperationEnum.CONTAINER_ADD)
|
|
||||||
@PostMapping("/addContainer")
|
|
||||||
public ResponseResult addContainer(@RequestBody Map<String, ContainerVo> container) {
|
|
||||||
return containerService.addContainer(container.get("container"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public ResponseResult getContainer(@PathVariable("id") Integer id) {
|
|
||||||
return containerService.getContainer(id);
|
|
||||||
}
|
|
||||||
@SysLog(operation = OperationEnum.CONTAINER_UPDATE)
|
|
||||||
@PostMapping("/updateContainer")
|
|
||||||
public ResponseResult updateVm(@RequestBody Map<String, ContainerVo> container) {
|
|
||||||
return containerService.updateContainer(container.get("container"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/allContainer")
|
|
||||||
public ResponseResult allContainer() {
|
|
||||||
return containerService.getAllContainer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/associatedContainers")
|
|
||||||
public ResponseResult getAssociatedContainers(
|
|
||||||
@RequestParam("hostId") Integer hostId,
|
|
||||||
@RequestParam("perPage") Integer perPage,
|
|
||||||
@RequestParam("currentPage") Integer currentPage) {
|
|
||||||
return containerService.getAssociatedContainers(hostId, perPage, currentPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.mzaxd.noodles.controller;
|
|
||||||
|
|
||||||
import com.mzaxd.noodles.domain.ResponseResult;
|
|
||||||
import com.mzaxd.noodles.service.DashboardService;
|
|
||||||
import com.mzaxd.noodles.service.EveryDayDataService;
|
|
||||||
import com.mzaxd.noodles.service.HostDetectorService;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 13439
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/dashboard")
|
|
||||||
public class DashboardController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private HostDetectorService detectorService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private EveryDayDataService everyDayDataService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private DashboardService dashboardService;
|
|
||||||
|
|
||||||
@GetMapping("/getMemInfo")
|
|
||||||
public ResponseResult getMemInfo() {
|
|
||||||
return detectorService.getMemInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/getAuditLogCountYesterday")
|
|
||||||
public ResponseResult getAuditLogCountYesterday() {
|
|
||||||
return everyDayDataService.getAuditLogCountYesterday();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/getInstancesHistory")
|
|
||||||
public ResponseResult getInstancesHistory() {
|
|
||||||
return everyDayDataService.getInstancesHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/getInstancesRealTimeData")
|
|
||||||
public ResponseResult getInstancesRealTimeData() {
|
|
||||||
return dashboardService.getInstancesRealTimeData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/getRecentConsoleList")
|
|
||||||
public ResponseResult getRecentConsoleList() {
|
|
||||||
return dashboardService.getRecentConsoleList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/getAffectedServirList")
|
|
||||||
public ResponseResult getAffectedServirList() {
|
|
||||||
return dashboardService.getAffectedServirList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.mzaxd.noodles.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.mzaxd.noodles.constant.UrlConstant;
|
|
||||||
import com.mzaxd.noodles.domain.ResponseResult;
|
|
||||||
import com.mzaxd.noodles.service.HostDetectorService;
|
|
||||||
import com.mzaxd.noodles.util.UrlUtil;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author root
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/detector")
|
|
||||||
public class DetectorController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private HostDetectorService hostDetectorService;
|
|
||||||
|
|
||||||
@GetMapping("/isValidUrl/{protocol}/{ip}/{port}")
|
|
||||||
public ResponseResult isValidUrl(@PathVariable String protocol,@PathVariable String ip, @PathVariable String port) {
|
|
||||||
return hostDetectorService.isValidUrl(protocol,ip,port);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
package com.mzaxd.noodles.controller;
|
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.mzaxd.noodles.annotation.SysLog;
|
|
||||||
import com.mzaxd.noodles.domain.ResponseResult;
|
|
||||||
import com.mzaxd.noodles.domain.entity.HostMachine;
|
|
||||||
import com.mzaxd.noodles.domain.vo.HostVo;
|
|
||||||
import com.mzaxd.noodles.domain.vo.VmVo;
|
|
||||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
|
||||||
import com.mzaxd.noodles.enums.OperationEnum;
|
|
||||||
import com.mzaxd.noodles.service.HostMachineService;
|
|
||||||
import com.mzaxd.noodles.util.WebUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author root
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/host")
|
|
||||||
public class HostController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private HostMachineService hostMachineService;
|
|
||||||
|
|
||||||
@GetMapping("/drawer")
|
|
||||||
public ResponseResult hostDrawer() {
|
|
||||||
return hostMachineService.getHostDrawer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/vmList")
|
|
||||||
public ResponseResult vmListWithCondition(
|
|
||||||
@RequestParam(value = "q", required = false) String nameLike,
|
|
||||||
@RequestParam(value = "selectedKernel", required = false) List<Integer> selectedKernel,
|
|
||||||
@RequestParam(value = "selectedHost", required = false) List<Integer> selectedHost,
|
|
||||||
@RequestParam(value = "selectedStatus", required = false) List<Integer> selectedStatus,
|
|
||||||
@RequestParam("perPage") Integer perPage,
|
|
||||||
@RequestParam("currentPage") Integer currentPage) {
|
|
||||||
return hostMachineService.vmListWithCondition(nameLike, selectedKernel, selectedHost, selectedStatus, perPage, currentPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/vmList/summaryStatistics")
|
|
||||||
public ResponseResult vmListSummaryStatistics() {
|
|
||||||
return hostMachineService.vmListSummaryStatistics();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SysLog(operation = OperationEnum.VM_ADD)
|
|
||||||
@PostMapping("/addVm")
|
|
||||||
public ResponseResult addVm(@RequestBody Map<String, VmVo> vmVo) {
|
|
||||||
return hostMachineService.addVm(vmVo.get("vm"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SysLog(operation = OperationEnum.VM_UPDATE)
|
|
||||||
@PostMapping("/updateVm")
|
|
||||||
public ResponseResult updateVm(@RequestBody Map<String, VmVo> vmVo) {
|
|
||||||
return hostMachineService.updateVm(vmVo.get("vm"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SysLog(operation = OperationEnum.VM_DELETE)
|
|
||||||
@DeleteMapping("/deleteVm/{id}")
|
|
||||||
public ResponseResult deleteVm(@PathVariable("id") Integer id) {
|
|
||||||
return hostMachineService.deleteVmById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SysLog(operation = OperationEnum.HOST_DELETE)
|
|
||||||
@DeleteMapping("/deleteHost/{id}")
|
|
||||||
public ResponseResult deleteHost(@PathVariable("id") Integer id) {
|
|
||||||
return hostMachineService.deleteHostById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/vm/{id}")
|
|
||||||
public ResponseResult<VmVo> getVmById(@PathVariable("id") Integer id) {
|
|
||||||
return hostMachineService.getVmById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SysLog(operation = OperationEnum.HOST_UPDATE)
|
|
||||||
@PostMapping("/updateHost")
|
|
||||||
public ResponseResult updateHost(@RequestBody Map<String, HostVo> hostVo) {
|
|
||||||
return hostMachineService.updateHost(hostVo.get("host"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/host/{id}")
|
|
||||||
public ResponseResult<HostVo> getHostById(@PathVariable("id") Integer id) {
|
|
||||||
return hostMachineService.getHostById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/hostList")
|
|
||||||
public ResponseResult hostListWithCondition(
|
|
||||||
@RequestParam(value = "q", required = false) String nameLike,
|
|
||||||
@RequestParam(value = "selectedStatus", required = false) List<Integer> selectedStatus,
|
|
||||||
@RequestParam("perPage") Integer perPage,
|
|
||||||
@RequestParam("currentPage") Integer currentPage) {
|
|
||||||
return hostMachineService.hostListWithCondition(nameLike, selectedStatus, perPage, currentPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SysLog(operation = OperationEnum.HOST_ADD)
|
|
||||||
@PostMapping("/addHost")
|
|
||||||
public ResponseResult addHost(@RequestBody Map<String, HostVo> hostVo) {
|
|
||||||
return hostMachineService.addHost(hostVo.get("host"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/hostDetail/{id}")
|
|
||||||
public ResponseResult getHostDetail(@PathVariable("id") Integer id) {
|
|
||||||
return hostMachineService.getHostDetail(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/associatedVms")
|
|
||||||
public ResponseResult getAssociatedVms(
|
|
||||||
@RequestParam("hostId") Integer hostId,
|
|
||||||
@RequestParam("perPage") Integer perPage,
|
|
||||||
@RequestParam("currentPage") Integer currentPage) {
|
|
||||||
return hostMachineService.getAssociatedVms(hostId, perPage, currentPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/associatedDisks/{id}")
|
|
||||||
public ResponseResult getAssociatedDisks(@PathVariable("id") Integer id){
|
|
||||||
return hostMachineService.getAssociatedDisks(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/associatedNetworkIfs/{id}")
|
|
||||||
public ResponseResult getAssociatedNetworkIfs(@PathVariable("id") Integer id) {
|
|
||||||
return hostMachineService.getAssociatedNetworkIfs(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/startSendDynamicData/{id}")
|
|
||||||
public ResponseResult startSendDynamicData(@PathVariable("id") Integer hostId) {
|
|
||||||
return hostMachineService.startSendDynamicData(hostId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/stopSendDynamicData/{id}")
|
|
||||||
public ResponseResult stopSendDynamicData(@PathVariable("id") Integer hostId) {
|
|
||||||
return hostMachineService.stopSendDynamicData(hostId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user