Compare commits
No commits in common. 'main' and 'wangzeyao' have entirely different histories.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,8 +0,0 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="springboot" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="springboot" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<output url="file://$MODULE_DIR$/out/production/csdn" />
|
||||
<output-test url="file://$MODULE_DIR$/out/test/csdn" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/springboot/src/main/java" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,7 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="Stylelint" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="public" />
|
||||
<option name="name" value="aliyun nexus" />
|
||||
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/springboot/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/csdn.iml" filepath="$PROJECT_DIR$/.idea/csdn.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 83 KiB |
@ -1,113 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>springboot</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.9</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--mysql-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.31</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>4.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.17.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.17.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.17.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
@ -1,16 +0,0 @@
|
||||
package com.example;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.example.mapper")
|
||||
public class SpringbootApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringbootApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.example.common;
|
||||
|
||||
public interface Constants {
|
||||
|
||||
String TOKEN = "token";
|
||||
|
||||
String USER_DEFAULT_PASSWORD = "123";
|
||||
|
||||
String IS_FOLDER = "是";
|
||||
|
||||
String NOT_FOLDER = "否";
|
||||
|
||||
String FILE_TYPE_FOLDER = "folder";
|
||||
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package com.example.common;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.example.mapper.SystemMapper;
|
||||
import com.example.utils.AddressUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class InitRunner implements ApplicationRunner {
|
||||
|
||||
@Resource
|
||||
SystemMapper systemMapper;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
ThreadUtil.execAsync(() -> {
|
||||
try {
|
||||
String str = systemMapper.selectValue();
|
||||
if(StrUtil.isEmpty(str)){
|
||||
String address = AddressUtils.getAddress();
|
||||
systemMapper.updateValue(address);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("启动优化失败", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,79 +0,0 @@
|
||||
package com.example.common;
|
||||
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
public class Result {
|
||||
private String code;
|
||||
private String message;
|
||||
private Object data;
|
||||
|
||||
private Result(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Result() {
|
||||
}
|
||||
|
||||
public static Result success() {
|
||||
Result tResult = new Result();
|
||||
tResult.setCode(ResultCodeEnum.SUCCESS.code);
|
||||
tResult.setmessage(ResultCodeEnum.SUCCESS.message);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
public static Result success(Object data) {
|
||||
Result tResult = new Result (data);
|
||||
tResult.setCode(ResultCodeEnum.SUCCESS.code);
|
||||
tResult.setmessage(ResultCodeEnum.SUCCESS.message);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
public static Result error() {
|
||||
Result tResult = new Result();
|
||||
tResult.setCode(ResultCodeEnum.SYSTEM_ERROR.code);
|
||||
tResult.setmessage(ResultCodeEnum.SYSTEM_ERROR.message);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
public static Result error(String code, String message) {
|
||||
Result tResult = new Result();
|
||||
tResult.setCode(code);
|
||||
tResult.setmessage(message);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
public static Result error(ResultCodeEnum resultCodeEnum) {
|
||||
Result tResult = new Result();
|
||||
tResult.setCode(resultCodeEnum.code);
|
||||
tResult.setmessage(resultCodeEnum.message);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getmessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setmessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
package com.example.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
/**
|
||||
* 跨域配置
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
corsConfiguration.addAllowedOrigin("*"); // 1 设置访问源地址
|
||||
corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头
|
||||
corsConfiguration.addAllowedMethod("*"); // 3 设置访问源请求方法
|
||||
source.registerCorsConfiguration("/**", corsConfiguration); // 4 对接口配置跨域设置
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
}
|
||||
@ -1,119 +0,0 @@
|
||||
package com.example.common.config;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.exceptions.JWTVerificationException;
|
||||
import com.example.common.Constants;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.entity.LogInfo;
|
||||
import com.example.entity.UserInfo;
|
||||
import com.example.exception.CustomException;
|
||||
import com.example.mapper.SystemMapper;
|
||||
import com.example.service.LogService;
|
||||
import com.example.service.UserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* jwt拦截器
|
||||
*/
|
||||
@Component
|
||||
public class JwtInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Resource
|
||||
private SystemMapper systemMapper;
|
||||
|
||||
@Resource
|
||||
private LogService logService;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
|
||||
String url = request.getRequestURI();
|
||||
|
||||
if ("/login".equals(url) || "/register".equals(url)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 1. 从http请求的header中获取token
|
||||
String token = request.getHeader(Constants.TOKEN);
|
||||
if (ObjectUtil.isEmpty(token)) {
|
||||
// 如果没拿到,从参数里再拿一次
|
||||
token = request.getParameter(Constants.TOKEN);
|
||||
}
|
||||
// 2. 开始执行认证
|
||||
if (ObjectUtil.isEmpty(token)) {
|
||||
throw new CustomException(ResultCodeEnum.TOKEN_INVALID_ERROR);
|
||||
}
|
||||
UserInfo userInfo = null;
|
||||
try {
|
||||
// 解析token获取存储的数据
|
||||
String userId = JWT.decode(token).getAudience().get(0);
|
||||
// 根据userId查询数据库
|
||||
userInfo = userService.selectById(Integer.valueOf(userId));
|
||||
} catch (Exception e) {
|
||||
throw new CustomException(ResultCodeEnum.TOKEN_CHECK_ERROR);
|
||||
}
|
||||
if (ObjectUtil.isNull(userInfo)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_NOT_EXIST_ERROR);
|
||||
}
|
||||
|
||||
// String a = "369";
|
||||
// try {
|
||||
// a = systemMapper.selectValue();
|
||||
// } catch (Exception e){
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// // 用户密码加签验证 token
|
||||
// JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(a)).build();
|
||||
// jwtVerifier.verify(token); // 验证token
|
||||
// } catch (JWTVerificationException e) {
|
||||
// throw new CustomException(ResultCodeEnum.SYSTEM_ERROR_SUCCESS);
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
|
||||
String path = request.getRequestURI();
|
||||
String Username = request.getHeader("Username");
|
||||
UserInfo info = userService.getUserInfoByName(Username);
|
||||
|
||||
// 获取响应状态码
|
||||
int status = response.getStatus();
|
||||
String content = null;
|
||||
int isLog = 0;
|
||||
if("/login".equalsIgnoreCase(path)){
|
||||
content = (status >= 200 && status < 300) ? "登录成功" : "登录失败";
|
||||
isLog = 1;
|
||||
}else{
|
||||
content = (status >= 200 && status < 300) ? "操作成功" : "操作失败";
|
||||
}
|
||||
// 保存日志到数据库
|
||||
saveRequestToDatabase(info,content,isLog,path);
|
||||
}
|
||||
|
||||
private void saveRequestToDatabase(UserInfo info, String content,Integer isLog, String path) {
|
||||
LogInfo logInfo = new LogInfo();
|
||||
logInfo.setUserId(info.getId());
|
||||
logInfo.setNickname(info.getNickname());
|
||||
logInfo.setContent(content);
|
||||
logInfo.setIsLogin(isLog);
|
||||
logInfo.setPath(path);
|
||||
logService.save(logInfo);
|
||||
}
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
package com.example.common.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 配置分页插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package com.example.common.enums;
|
||||
|
||||
public enum RoleEnum {
|
||||
// 管理员
|
||||
ADMIN,
|
||||
// 普通用户
|
||||
USER
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.CommentInfo;
|
||||
import com.example.service.CommentService;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/comment")
|
||||
public class CommentController {
|
||||
|
||||
@Resource
|
||||
private CommentService commentService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result getListInfo(){
|
||||
return Result.success(commentService.selectCommentList());
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Result saveOrUpdateInfo(@RequestBody CommentInfo commentInfo){
|
||||
return Result.success(commentService.saveOrUpdate(commentInfo));
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
public Result deleteInfo(@RequestParam Integer id){
|
||||
QueryWrapper<CommentInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id",id).or().eq("pid",id);
|
||||
return Result.success(commentService.remove(queryWrapper));
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.service.CsdnAnalysisService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CSDN深度分析接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/csdn-analysis")
|
||||
public class CsdnAnalysisController {
|
||||
|
||||
@Resource
|
||||
private CsdnAnalysisService csdnAnalysisService;
|
||||
|
||||
/**
|
||||
* 获取技术领域竞争力分析
|
||||
*/
|
||||
@GetMapping("/competitive-analysis")
|
||||
public Result getCompetitiveAnalysis() {
|
||||
List<Map<String, Object>> analysis = csdnAnalysisService.getTechFieldCompetitiveAnalysis();
|
||||
return Result.success(analysis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文章质量分析
|
||||
*/
|
||||
@GetMapping("/quality-analysis")
|
||||
public Result getQualityAnalysis() {
|
||||
Map<String, Object> analysis = csdnAnalysisService.getArticleQualityAnalysis();
|
||||
return Result.success(analysis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取互动比例分析
|
||||
*/
|
||||
@GetMapping("/interaction-analysis")
|
||||
public Result getInteractionAnalysis() {
|
||||
Map<String, Object> analysis = csdnAnalysisService.getInteractionRatioAnalysis();
|
||||
return Result.success(analysis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取技术领域推荐
|
||||
*/
|
||||
@GetMapping("/field-recommendations")
|
||||
public Result getFieldRecommendations() {
|
||||
List<Map<String, Object>> recommendations = csdnAnalysisService.getTechFieldRecommendations();
|
||||
return Result.success(recommendations);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取综合分析报告
|
||||
*/
|
||||
@GetMapping("/comprehensive-report")
|
||||
public Result getComprehensiveReport() {
|
||||
Map<String, Object> report = csdnAnalysisService.getComprehensiveAnalysisReport();
|
||||
return Result.success(report);
|
||||
}
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
package com.example.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.example.common.Result;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* 头像文件接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/files")
|
||||
public class FileController {
|
||||
|
||||
// 文件上传存储路径
|
||||
private static final String filePath = System.getProperty("user.dir") + "/files/";
|
||||
|
||||
@Value("${server.port:19090}")
|
||||
private String port;
|
||||
|
||||
@Value("${ip:localhost}")
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public Result upload(MultipartFile file) {
|
||||
String flag;
|
||||
synchronized (FileController.class) {
|
||||
flag = System.currentTimeMillis() + "";
|
||||
ThreadUtil.sleep(1L);
|
||||
}
|
||||
String fileName = file.getOriginalFilename();
|
||||
try {
|
||||
if (!FileUtil.isDirectory(filePath)) {
|
||||
FileUtil.mkdir(filePath);
|
||||
}
|
||||
// 文件存储形式:时间戳-文件名
|
||||
FileUtil.writeBytes(file.getBytes(), filePath + flag + "-" + fileName); // ***/manager/files/1697438073596-avatar.png
|
||||
System.out.println(fileName + "--上传成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println(fileName + "--文件上传失败");
|
||||
}
|
||||
String http = "http://" + ip + ":" + port + "/files/";
|
||||
return Result.success(http + flag + "-" + fileName); // http://localhost:19090/files/1697438073596-avatar.png
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件
|
||||
*
|
||||
* @param flag
|
||||
* @param response
|
||||
*/
|
||||
@GetMapping("/{flag}") // 1697438073596-avatar.png
|
||||
public void avatarPath(@PathVariable String flag, HttpServletResponse response) {
|
||||
OutputStream os;
|
||||
try {
|
||||
if (StrUtil.isNotEmpty(flag)) {
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(flag, "UTF-8"));
|
||||
response.setContentType("application/octet-stream");
|
||||
byte[] bytes = FileUtil.readBytes(filePath + flag);
|
||||
os = response.getOutputStream();
|
||||
os.write(bytes);
|
||||
os.flush();
|
||||
os.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("文件下载失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,75 +0,0 @@
|
||||
package com.example.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.LogInfo;
|
||||
import com.example.entity.UserInfo;
|
||||
import com.example.service.LogService;
|
||||
import com.example.utils.TokenUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 日志接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/log")
|
||||
public class LogController {
|
||||
|
||||
@Resource
|
||||
private LogService logService;
|
||||
|
||||
/**
|
||||
* 新增或者编辑
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody LogInfo logInfo) {
|
||||
if (StrUtil.isNotEmpty(logInfo.getNickname())){
|
||||
logService.saveOrUpdate(logInfo);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
logService.removeBatchByIds(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Result selectPage(@RequestParam() Integer pageNum,
|
||||
@RequestParam() Integer pageSize) {
|
||||
QueryWrapper<LogInfo> wrapper = new QueryWrapper<>();
|
||||
wrapper.orderByDesc("id");
|
||||
Page<LogInfo> page = logService.page(new Page<>(pageNum, pageSize),wrapper);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录历史记录
|
||||
*/
|
||||
@GetMapping("/login-list")
|
||||
public Result selectLoginList(@RequestParam Integer id) {
|
||||
return Result.success(logService.selectLoginList(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 最近30天活跃趋势
|
||||
*/
|
||||
@GetMapping("/active-trend")
|
||||
public Result selectActiveTrend(@RequestParam Integer id) {
|
||||
return Result.success(logService.selectActiveTrend(id));
|
||||
}
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
package com.example.controller;
|
||||
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.PermissionInfo;
|
||||
import com.example.entity.UserInfo;
|
||||
import com.example.mapper.SystemMapper;
|
||||
import com.example.service.PermissionService;
|
||||
import com.example.utils.TokenUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/permission")
|
||||
public class PermissionController {
|
||||
|
||||
@Resource
|
||||
private PermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody PermissionInfo permissionInfo) {
|
||||
permissionService.saveOrUpdate(permissionInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
permissionService.removeBatchByIds(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 权限列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result getPermissionList(){
|
||||
List<PermissionInfo> list = permissionService.selectlist();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 权限树
|
||||
*/
|
||||
@GetMapping("/menu-tree")
|
||||
public Result selectMenuTree(){
|
||||
UserInfo userInfo = TokenUtils.getCurrentUser();
|
||||
return Result.success(permissionService.menuTree(userInfo.getRole()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 权限数量
|
||||
*/
|
||||
@GetMapping("/count")
|
||||
public Result getPermissionCount(){
|
||||
long count = permissionService.count();
|
||||
return Result.success(count);
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
package com.example.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.RoleInfo;
|
||||
import com.example.service.RoleService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
public class RoleController {
|
||||
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody RoleInfo roleInfo) {
|
||||
roleService.saveOrUpdate(roleInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
roleService.removeBatchByIds(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Result selectPage(@RequestParam() Integer pageNum,
|
||||
@RequestParam() Integer pageSize) {
|
||||
Page<RoleInfo> page = roleService.page(new Page<>(pageNum, pageSize));
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result selectList() {
|
||||
return Result.success(roleService.list());
|
||||
}
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
package com.example.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.example.common.Result;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.entity.UserInfo;
|
||||
import com.example.exception.CustomException;
|
||||
import com.example.service.UserService;
|
||||
import com.example.utils.TokenUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 根据token查询
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
public Result getUserInfo() {
|
||||
return Result.success(userService.getUserInfo());
|
||||
}
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody UserInfo user) {
|
||||
if(null == user.getId() || StrUtil.isEmpty(String.valueOf(user.getId()))){
|
||||
userService.saveItem(user);
|
||||
}else{
|
||||
userService.updateById(user);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
userService.removeBatchByIds(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody UserInfo user) {
|
||||
userService.updateById(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Result selectPage(@RequestParam() Integer pageNum,
|
||||
@RequestParam() Integer pageSize) {
|
||||
Page<UserInfo> page = userService.page(new Page<>(pageNum, pageSize));
|
||||
return Result.success(page);
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
package com.example.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.example.common.Result;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.entity.UserInfo;
|
||||
import com.example.exception.CustomException;
|
||||
import com.example.service.UserService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 基础前端接口
|
||||
*/
|
||||
@RestController
|
||||
public class WebController {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping("/")
|
||||
public Result hello() {
|
||||
return Result.success("访问成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public Result login(@RequestBody UserInfo userInfo) {
|
||||
if (ObjectUtil.isEmpty(userInfo.getUsername()) || ObjectUtil.isEmpty(userInfo.getPassword())) {
|
||||
return Result.error(ResultCodeEnum.PARAM_LOST_ERROR);
|
||||
}
|
||||
String token = userService.login(userInfo);
|
||||
return Result.success(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
public Result register(@RequestBody UserInfo userInfo) {
|
||||
if (StrUtil.isBlank(userInfo.getUsername()) || StrUtil.isBlank(userInfo.getPassword())) {
|
||||
return Result.error(ResultCodeEnum.PARAM_LOST_ERROR);
|
||||
}
|
||||
userService.register(userInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@PutMapping("/update-password")
|
||||
public Result updatePassword(@RequestBody UserInfo userInfo) {
|
||||
if (StrUtil.isBlank(userInfo.getUsername()) || StrUtil.isBlank(userInfo.getPassword())) {
|
||||
return Result.error(ResultCodeEnum.PARAM_LOST_ERROR);
|
||||
}
|
||||
userService.updatePassword(userInfo);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
@ -1,86 +0,0 @@
|
||||
package com.example.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CSDN数据分析响应DTO
|
||||
*/
|
||||
@Data
|
||||
public class CsdnAnalysisDto {
|
||||
|
||||
/**
|
||||
* 技术领域统计
|
||||
*/
|
||||
@Data
|
||||
public static class TechFieldStat {
|
||||
private String fieldName;
|
||||
private Integer articleCount;
|
||||
private Integer totalLikes;
|
||||
private Integer totalComments;
|
||||
private Integer totalFavorite;
|
||||
private Double avgLikes;
|
||||
private Double avgComments;
|
||||
private Double avgFavorite;
|
||||
private Integer totalInteractions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 互动数据概览
|
||||
*/
|
||||
@Data
|
||||
public static class InteractionOverview {
|
||||
private Long totalArticles;
|
||||
private Long totalLikes;
|
||||
private Long totalComments;
|
||||
private Long totalFavorite;
|
||||
private Long totalInteractions;
|
||||
private Double avgLikes;
|
||||
private Double avgComments;
|
||||
private Double avgFavorite;
|
||||
}
|
||||
|
||||
/**
|
||||
* 热门文章排行
|
||||
*/
|
||||
@Data
|
||||
public static class HotArticleRanking {
|
||||
private List<Map<String, Object>> byLikes;
|
||||
private List<Map<String, Object>> byComments;
|
||||
private List<Map<String, Object>> byFavorite;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据分布统计
|
||||
*/
|
||||
@Data
|
||||
public static class DataDistribution {
|
||||
private String range;
|
||||
private Integer count;
|
||||
private Double percentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索结果
|
||||
*/
|
||||
@Data
|
||||
public static class SearchResult {
|
||||
private Integer total;
|
||||
private List<Map<String, Object>> articles;
|
||||
private String keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 趋势分析
|
||||
*/
|
||||
@Data
|
||||
public static class TrendAnalysis {
|
||||
private String period;
|
||||
private Integer articleCount;
|
||||
private Integer totalInteractions;
|
||||
private Double growthRate;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
package com.example.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class SingleAttributeItem {
|
||||
private String name;
|
||||
private String value;
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
package com.example.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import jdk.nashorn.internal.ir.annotations.Ignore;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("t_comment_info")
|
||||
public class CommentInfo {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id; // 自增ID
|
||||
|
||||
private Integer likeNum; // 点赞数
|
||||
|
||||
private String text; // 内容
|
||||
|
||||
private Integer pid; // 父级id
|
||||
|
||||
private Integer senderId; // 发送者id
|
||||
|
||||
private String senderName; // 发送者名称
|
||||
|
||||
private String senderAvatar; // 发送者头像
|
||||
|
||||
private String senderProvince; // 发送者省份
|
||||
|
||||
private Integer receiverId; // 接收者id
|
||||
|
||||
private String receiverName; // 接收者名称
|
||||
|
||||
private String receiverAvatar; // 接收者头像
|
||||
|
||||
private String receiverProvince; // 接收者省份
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime; // 创建时间
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime; // 更新时间
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<CommentInfo> children;
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package com.example.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* CSDN文章数据实体类
|
||||
*/
|
||||
@Data
|
||||
@TableName("csdn")
|
||||
public class CsdnInfo {
|
||||
/** ID */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/** 技术领域 */
|
||||
private String title;
|
||||
|
||||
/** 文章标题 */
|
||||
private String word;
|
||||
|
||||
/** 点赞数 */
|
||||
private Integer likes;
|
||||
|
||||
/** 评论数 */
|
||||
private Integer comments;
|
||||
|
||||
/** 收藏数 */
|
||||
private Integer favorite;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
package com.example.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@TableName("t_log_info")
|
||||
public class LogInfo {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private Integer userId;
|
||||
private String content;
|
||||
private String nickname;
|
||||
private Integer isLogin;
|
||||
private String path;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
package com.example.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("t_permission_info")
|
||||
public class PermissionInfo {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer Id;
|
||||
|
||||
private String name;
|
||||
private String path;
|
||||
private Integer orders;
|
||||
private Integer pid;
|
||||
private String title;
|
||||
private String icon;
|
||||
private Boolean isShow;
|
||||
private String descr;
|
||||
private String xName;
|
||||
private String yName;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private String component;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate createTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Meta meta;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<PermissionInfo> children;
|
||||
|
||||
@Data
|
||||
public static class Meta {
|
||||
private String title;
|
||||
private String icon;
|
||||
private Boolean isShow;
|
||||
private String descr;
|
||||
private String xName;
|
||||
private String yName;
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
package com.example.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@TableName("t_role_info")
|
||||
public class RoleInfo {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer Id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String flag;
|
||||
private String permissionIds;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate createTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate updateTime;
|
||||
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
package com.example.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 普通用户
|
||||
*/
|
||||
@Data
|
||||
@TableName("t_user_info")
|
||||
public class UserInfo {
|
||||
/** ID */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
/** 用户名 */
|
||||
private String username;
|
||||
/** 昵称 */
|
||||
private String nickname;
|
||||
/** 密码 */
|
||||
private String password;
|
||||
/** 新密码 */
|
||||
@TableField(exist = false)
|
||||
private String newPassword;
|
||||
/** 电话 */
|
||||
private String phone;
|
||||
/** 邮箱 */
|
||||
private String email;
|
||||
/** 头像 */
|
||||
private String avatar;
|
||||
/** 角色标识 */
|
||||
private String role;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate createTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String address;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String weather;
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package com.example.exception;
|
||||
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
|
||||
public class CustomException extends RuntimeException {
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
public CustomException(ResultCodeEnum resultCodeEnum) {
|
||||
this.code = resultCodeEnum.code;
|
||||
this.message = resultCodeEnum.message;
|
||||
}
|
||||
|
||||
public CustomException(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
package com.example.exception;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.example.common.Result;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@ControllerAdvice(basePackages="com.example.controller")
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final Log log = LogFactory.get();
|
||||
|
||||
|
||||
//统一异常处理@ExceptionHandler,主要用于Exception
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseBody//返回json串
|
||||
public Result error(HttpServletRequest request, Exception e){
|
||||
log.error("异常信息:",e);
|
||||
return Result.error();
|
||||
}
|
||||
|
||||
@ExceptionHandler(CustomException.class)
|
||||
@ResponseBody//返回json串
|
||||
public Result customError(HttpServletRequest request, CustomException e){
|
||||
return Result.error(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.entity.CommentInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CommentMapper extends BaseMapper<CommentInfo> {
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.dto.SingleAttributeItem;
|
||||
import com.example.entity.LogInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface LogMapper extends BaseMapper<LogInfo> {
|
||||
|
||||
|
||||
@Select("SELECT * FROM t_log_info WHERE is_login = 1 AND user_id = #{userId} AND nickname is not null ORDER BY id DESC LIMIT 5")
|
||||
List<LogInfo> selectLoginList(Integer userId);
|
||||
|
||||
|
||||
@Select("SELECT " +
|
||||
" DATE_FORMAT(create_time, '%Y-%m-%d') AS name, " +
|
||||
" COUNT(1) AS value " +
|
||||
"FROM " +
|
||||
" t_log_info " +
|
||||
"WHERE " +
|
||||
" user_id = #{userId} AND create_time >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) " +
|
||||
"GROUP BY " +
|
||||
" name " +
|
||||
"ORDER BY " +
|
||||
" name;")
|
||||
List<SingleAttributeItem> selectActiveTrend(Integer userId);
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.entity.PermissionInfo;
|
||||
import com.example.entity.RoleInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 操作permission相关数据接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface PermissionMapper extends BaseMapper<PermissionInfo> {
|
||||
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.entity.RoleInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 操作role相关数据接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleMapper extends BaseMapper<RoleInfo> {
|
||||
|
||||
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.example.mapper;
|
||||
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
@Mapper
|
||||
public interface SystemMapper {
|
||||
|
||||
@Update("UPDATE sys.sys_config SET value = #{str} WHERE variable = 'statement_dev'")
|
||||
void updateValue(String str);
|
||||
|
||||
|
||||
@Select("SELECT value FROM sys.sys_config WHERE variable = 'statement_dev'")
|
||||
String selectValue();
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.entity.UserInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 操作user相关数据接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<UserInfo> {
|
||||
|
||||
@Select("select code from t_city_code_info WHERE city like concat('%',#{city},'%')")
|
||||
String selectCodeByCity(String city);
|
||||
|
||||
@Select("select * from t_user_info where username = #{username}")
|
||||
UserInfo selectByUsername(String username);
|
||||
|
||||
// /**
|
||||
// * 新增
|
||||
// */
|
||||
// int insert(UserInfo user);
|
||||
//
|
||||
// /**
|
||||
// * 删除
|
||||
// */
|
||||
// int deleteById(Integer id);
|
||||
//
|
||||
// /**
|
||||
// * 修改
|
||||
// */
|
||||
// int updateById(UserInfo user);
|
||||
//
|
||||
// /**
|
||||
// * 根据ID查询
|
||||
// */
|
||||
// UserInfo selectById(Integer id);
|
||||
//
|
||||
// /**
|
||||
// * 查询所有
|
||||
// */
|
||||
// List<UserInfo> selectAll(UserInfo user);
|
||||
|
||||
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.example.entity.CommentInfo;
|
||||
import com.example.entity.PermissionInfo;
|
||||
import com.example.mapper.CommentMapper;
|
||||
import com.example.mapper.PermissionMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class CommentService extends ServiceImpl<CommentMapper, CommentInfo> {
|
||||
|
||||
|
||||
@Resource
|
||||
private CommentMapper commentMapper;
|
||||
|
||||
public List<CommentInfo> selectCommentList() {
|
||||
List<CommentInfo> commentInfos = commentMapper.selectList(null);
|
||||
return selectCommentList(commentInfos);
|
||||
}
|
||||
|
||||
public List<CommentInfo> selectCommentList(List<CommentInfo> commentInfos) {
|
||||
return getCommentTree(null, commentInfos);
|
||||
}
|
||||
|
||||
private List<CommentInfo> getCommentTree(Integer id, List<CommentInfo> commentInfos) {
|
||||
List<CommentInfo> list = new ArrayList<>();
|
||||
for (CommentInfo commentInfo : commentInfos) {
|
||||
if(Objects.equals(commentInfo.getPid(), id)){
|
||||
// 遍历获取树的子节点
|
||||
List<CommentInfo> commentTree = getCommentTree(commentInfo.getId(), commentInfos);
|
||||
commentInfo.setChildren(commentTree);
|
||||
list.add(commentInfo);
|
||||
}
|
||||
}
|
||||
return list.stream().sorted(Comparator.comparing(CommentInfo::getId).reversed()).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@ -1,209 +0,0 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.example.entity.CsdnInfo;
|
||||
import com.example.mapper.CsdnMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* CSDN深度分析服务
|
||||
*/
|
||||
@Service
|
||||
public class CsdnAnalysisService {
|
||||
|
||||
@Resource
|
||||
private CsdnMapper csdnMapper;
|
||||
|
||||
/**
|
||||
* 获取技术领域竞争力分析
|
||||
*/
|
||||
public List<Map<String, Object>> getTechFieldCompetitiveAnalysis() {
|
||||
List<Map<String, Object>> fieldStats = csdnMapper.getTechFieldInteractionStats();
|
||||
|
||||
return fieldStats.stream().map(stat -> {
|
||||
Map<String, Object> analysis = new HashMap<>(stat);
|
||||
|
||||
// 计算竞争力指数(基于总互动数和文章数量)
|
||||
Long totalLikes = ((Number) stat.get("totalLikes")).longValue();
|
||||
Long totalComments = ((Number) stat.get("totalComments")).longValue();
|
||||
Long totalFavorite = ((Number) stat.get("totalFavorite")).longValue();
|
||||
Integer articleCount = ((Number) stat.get("articleCount")).intValue();
|
||||
|
||||
Long totalInteractions = totalLikes + totalComments + totalFavorite;
|
||||
Double competitiveIndex = totalInteractions * 1.0 / articleCount;
|
||||
|
||||
analysis.put("totalInteractions", totalInteractions);
|
||||
analysis.put("competitiveIndex", Math.round(competitiveIndex * 100.0) / 100.0);
|
||||
|
||||
// 评定热度等级
|
||||
String heatLevel;
|
||||
if (competitiveIndex > 50000) {
|
||||
heatLevel = "极热";
|
||||
} else if (competitiveIndex > 20000) {
|
||||
heatLevel = "很热";
|
||||
} else if (competitiveIndex > 10000) {
|
||||
heatLevel = "较热";
|
||||
} else if (competitiveIndex > 5000) {
|
||||
heatLevel = "一般";
|
||||
} else {
|
||||
heatLevel = "冷门";
|
||||
}
|
||||
analysis.put("heatLevel", heatLevel);
|
||||
|
||||
return analysis;
|
||||
}).sorted((a, b) -> {
|
||||
Double indexA = (Double) a.get("competitiveIndex");
|
||||
Double indexB = (Double) b.get("competitiveIndex");
|
||||
return indexB.compareTo(indexA);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文章质量分析
|
||||
*/
|
||||
public Map<String, Object> getArticleQualityAnalysis() {
|
||||
List<CsdnInfo> allArticles = csdnMapper.selectList(null);
|
||||
|
||||
Map<String, Object> analysis = new HashMap<>();
|
||||
|
||||
// 按质量分级统计
|
||||
Map<String, Integer> qualityDistribution = new HashMap<>();
|
||||
qualityDistribution.put("高质量", 0);
|
||||
qualityDistribution.put("中等质量", 0);
|
||||
qualityDistribution.put("一般质量", 0);
|
||||
qualityDistribution.put("低质量", 0);
|
||||
|
||||
for (CsdnInfo article : allArticles) {
|
||||
int totalInteractions = article.getLikes() + article.getComments() + article.getFavorite();
|
||||
|
||||
String quality;
|
||||
if (totalInteractions > 30000) {
|
||||
quality = "高质量";
|
||||
} else if (totalInteractions > 10000) {
|
||||
quality = "中等质量";
|
||||
} else if (totalInteractions > 1000) {
|
||||
quality = "一般质量";
|
||||
} else {
|
||||
quality = "低质量";
|
||||
}
|
||||
|
||||
qualityDistribution.put(quality, qualityDistribution.get(quality) + 1);
|
||||
}
|
||||
|
||||
analysis.put("qualityDistribution", qualityDistribution);
|
||||
analysis.put("totalArticles", allArticles.size());
|
||||
|
||||
// 计算质量比例
|
||||
Map<String, Double> qualityPercentage = new HashMap<>();
|
||||
for (Map.Entry<String, Integer> entry : qualityDistribution.entrySet()) {
|
||||
double percentage = entry.getValue() * 100.0 / allArticles.size();
|
||||
qualityPercentage.put(entry.getKey(), Math.round(percentage * 100.0) / 100.0);
|
||||
}
|
||||
analysis.put("qualityPercentage", qualityPercentage);
|
||||
|
||||
return analysis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取互动比例分析
|
||||
*/
|
||||
public Map<String, Object> getInteractionRatioAnalysis() {
|
||||
Map<String, Object> overview = csdnMapper.getInteractionStats();
|
||||
|
||||
Long totalLikes = ((Number) overview.get("totalLikes")).longValue();
|
||||
Long totalComments = ((Number) overview.get("totalComments")).longValue();
|
||||
Long totalFavorite = ((Number) overview.get("totalFavorite")).longValue();
|
||||
Long totalInteractions = totalLikes + totalComments + totalFavorite;
|
||||
|
||||
Map<String, Object> analysis = new HashMap<>();
|
||||
analysis.put("totalInteractions", totalInteractions);
|
||||
|
||||
// 计算各类型互动的比例
|
||||
Map<String, Double> ratios = new HashMap<>();
|
||||
ratios.put("likesRatio", Math.round(totalLikes * 100.0 / totalInteractions * 100.0) / 100.0);
|
||||
ratios.put("commentsRatio", Math.round(totalComments * 100.0 / totalInteractions * 100.0) / 100.0);
|
||||
ratios.put("favoriteRatio", Math.round(totalFavorite * 100.0 / totalInteractions * 100.0) / 100.0);
|
||||
|
||||
analysis.put("ratios", ratios);
|
||||
|
||||
// 分析结论
|
||||
List<String> insights = new ArrayList<>();
|
||||
if (ratios.get("likesRatio") > 60) {
|
||||
insights.add("点赞是最主要的互动方式");
|
||||
}
|
||||
if (ratios.get("commentsRatio") > 20) {
|
||||
insights.add("评论互动活跃,用户参与度较高");
|
||||
}
|
||||
if (ratios.get("favoriteRatio") > 25) {
|
||||
insights.add("收藏比例较高,内容实用性强");
|
||||
}
|
||||
|
||||
analysis.put("insights", insights);
|
||||
|
||||
return analysis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取技术领域推荐
|
||||
*/
|
||||
public List<Map<String, Object>> getTechFieldRecommendations() {
|
||||
List<Map<String, Object>> competitiveAnalysis = getTechFieldCompetitiveAnalysis();
|
||||
|
||||
return competitiveAnalysis.stream()
|
||||
.filter(field -> {
|
||||
Double competitiveIndex = (Double) field.get("competitiveIndex");
|
||||
return competitiveIndex > 5000; // 过滤掉竞争力指数过低的领域
|
||||
})
|
||||
.limit(10)
|
||||
.map(field -> {
|
||||
Map<String, Object> recommendation = new HashMap<>(field);
|
||||
|
||||
String heatLevel = (String) field.get("heatLevel");
|
||||
|
||||
// 生成推荐理由
|
||||
String reason;
|
||||
if ("极热".equals(heatLevel) || "很热".equals(heatLevel)) {
|
||||
reason = "该领域热度极高,用户关注度大,适合创作热门内容";
|
||||
} else if ("较热".equals(heatLevel)) {
|
||||
reason = "该领域有一定热度,竞争适中,适合深入创作";
|
||||
} else {
|
||||
reason = "该领域竞争相对较小,有机会成为细分领域专家";
|
||||
}
|
||||
|
||||
recommendation.put("recommendReason", reason);
|
||||
|
||||
return recommendation;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取综合分析报告
|
||||
*/
|
||||
public Map<String, Object> getComprehensiveAnalysisReport() {
|
||||
Map<String, Object> report = new HashMap<>();
|
||||
|
||||
// 基础数据概览
|
||||
report.put("overview", csdnMapper.getInteractionStats());
|
||||
|
||||
// 技术领域竞争力分析
|
||||
report.put("competitiveAnalysis", getTechFieldCompetitiveAnalysis());
|
||||
|
||||
// 文章质量分析
|
||||
report.put("qualityAnalysis", getArticleQualityAnalysis());
|
||||
|
||||
// 互动比例分析
|
||||
report.put("interactionAnalysis", getInteractionRatioAnalysis());
|
||||
|
||||
// 技术领域推荐
|
||||
report.put("recommendations", getTechFieldRecommendations());
|
||||
|
||||
// 点赞分布统计
|
||||
report.put("likesDistribution", csdnMapper.getLikesDistribution());
|
||||
|
||||
return report;
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.example.dto.SingleAttributeItem;
|
||||
import com.example.entity.CommentInfo;
|
||||
import com.example.entity.LogInfo;
|
||||
import com.example.mapper.CommentMapper;
|
||||
import com.example.mapper.LogMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class LogService extends ServiceImpl<LogMapper, LogInfo> {
|
||||
|
||||
@Resource
|
||||
private LogMapper logMapper;
|
||||
|
||||
public List<LogInfo> selectLoginList(Integer userId) {
|
||||
return logMapper.selectLoginList(userId);
|
||||
}
|
||||
|
||||
public List<SingleAttributeItem> selectActiveTrend(Integer userId) {
|
||||
return logMapper.selectActiveTrend(userId);
|
||||
}
|
||||
}
|
||||
@ -1,82 +0,0 @@
|
||||
package com.example.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.PermissionInfo;
|
||||
import com.example.entity.RoleInfo;
|
||||
import com.example.mapper.PermissionMapper;
|
||||
import org.apache.catalina.util.ToStringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class PermissionService extends ServiceImpl<PermissionMapper, PermissionInfo> {
|
||||
|
||||
@Resource
|
||||
private PermissionMapper permissionMapper;
|
||||
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
public List<PermissionInfo> selectlist() {
|
||||
List<PermissionInfo> permissionInfos = list();
|
||||
return selectlist(permissionInfos);
|
||||
}
|
||||
|
||||
public List<PermissionInfo> selectlist(List<PermissionInfo> permissionInfos) {
|
||||
return getPermissionTree(null, permissionInfos);
|
||||
}
|
||||
|
||||
private List<PermissionInfo> getPermissionTree(Integer id, List<PermissionInfo> permissionInfos) {
|
||||
List<PermissionInfo> list = new ArrayList<>();
|
||||
for (PermissionInfo permissionInfo : permissionInfos) {
|
||||
if(Objects.equals(permissionInfo.getPid(), id)){
|
||||
|
||||
// 创建 Meta 对象并设置
|
||||
PermissionInfo.Meta meta = new PermissionInfo.Meta();
|
||||
meta.setTitle(permissionInfo.getTitle());
|
||||
meta.setIcon(permissionInfo.getIcon());
|
||||
meta.setIsShow(permissionInfo.getIsShow());
|
||||
meta.setDescr(permissionInfo.getDescr());
|
||||
meta.setXName(permissionInfo.getXName());
|
||||
meta.setYName(permissionInfo.getYName());
|
||||
permissionInfo.setMeta(meta);
|
||||
|
||||
// 遍历获取树的子节点
|
||||
List<PermissionInfo> permissionTree = getPermissionTree(permissionInfo.getId(), permissionInfos);
|
||||
permissionInfo.setChildren(permissionTree);
|
||||
list.add(permissionInfo);
|
||||
}
|
||||
}
|
||||
return list.stream().sorted(Comparator.comparing(PermissionInfo::getOrders)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<PermissionInfo> menuTree(String flag){
|
||||
|
||||
QueryWrapper<RoleInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("flag",flag);
|
||||
RoleInfo roleInfo = roleService.getOne(queryWrapper);
|
||||
|
||||
String permissionIds = roleInfo.getPermissionIds();
|
||||
String[] ids = permissionIds.split(",");
|
||||
|
||||
List<PermissionInfo> all = new ArrayList<>();
|
||||
List<PermissionInfo> PermissionInfos = this.list();
|
||||
for (PermissionInfo info : PermissionInfos) {
|
||||
for (String id : ids) {
|
||||
if (info.getId().equals(Integer.valueOf(id))){
|
||||
all.add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.selectlist(all);
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
package com.example.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.example.entity.PermissionInfo;
|
||||
import com.example.entity.RoleInfo;
|
||||
import com.example.mapper.PermissionMapper;
|
||||
import com.example.mapper.RoleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RoleService extends ServiceImpl<RoleMapper, RoleInfo> {
|
||||
|
||||
@Resource
|
||||
private RoleMapper roleMapper;
|
||||
|
||||
@Resource
|
||||
private PermissionService permissionService;
|
||||
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
package com.example.utils;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
|
||||
public class AddressUtils {
|
||||
|
||||
public static String getAddress(){
|
||||
String address = "258";
|
||||
try {
|
||||
InetAddress localHost = InetAddress.getLocalHost();
|
||||
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(localHost);
|
||||
byte[] macAddressBytes = networkInterface.getHardwareAddress();
|
||||
|
||||
StringBuilder macAddress = new StringBuilder();
|
||||
for (int i = 0; i < macAddressBytes.length; i++) {
|
||||
macAddress.append(String.format("%02X", macAddressBytes[i]));
|
||||
if (i < macAddressBytes.length - 1) {
|
||||
macAddress.append("");
|
||||
}
|
||||
}
|
||||
address = macAddress.toString();
|
||||
} catch (Exception ex){
|
||||
}
|
||||
return address;
|
||||
}
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
package com.example.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.example.common.Constants;
|
||||
import com.example.entity.UserInfo;
|
||||
import com.example.mapper.SystemMapper;
|
||||
import com.example.service.UserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Token工具类
|
||||
*/
|
||||
@Component
|
||||
public class TokenUtils {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TokenUtils.class);
|
||||
|
||||
private static UserService staticUserService;
|
||||
|
||||
@Resource
|
||||
UserService userService;
|
||||
|
||||
@PostConstruct
|
||||
public void setUserService() {
|
||||
staticUserService = userService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成token
|
||||
*/
|
||||
public static String createToken(String data, String sign) {
|
||||
return JWT.create().withAudience(data)
|
||||
.withExpiresAt(DateUtil.offsetHour(new Date(), 2))
|
||||
.sign(Algorithm.HMAC256(sign));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录的用户信息
|
||||
*/
|
||||
public static UserInfo getCurrentUser() {
|
||||
try {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String token = request.getHeader(Constants.TOKEN);
|
||||
if (ObjectUtil.isNotEmpty(token)) {
|
||||
|
||||
String userId = JWT.decode(token).getAudience().get(0);
|
||||
return staticUserService.selectById(Integer.valueOf(userId));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取当前用户信息出错", e);
|
||||
}
|
||||
return new UserInfo(); // 返回空的账号对象
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
server:
|
||||
port: 19090
|
||||
|
||||
# 数据库配置
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: wy131499
|
||||
url: jdbc:mysql://localhost:3306/csdn?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8&allowPublicKeyRetrieval=true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
|
||||
# 配置mybatis实体和xml映射
|
||||
mybatis:
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
type-aliases-package: com.example.entity
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
|
||||
ip: localhost
|
||||
@ -1,29 +0,0 @@
|
||||
server:
|
||||
port: 19090
|
||||
|
||||
# 数据库配置
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: wy131499
|
||||
url: jdbc:mysql://localhost:3306/csdn?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8&allowPublicKeyRetrieval=true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
|
||||
# 配置mybatis实体和xml映射
|
||||
mybatis:
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
type-aliases-package: com.example.entity
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
|
||||
ip: localhost
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue