add:增加后台管理系统
This commit is contained in:
@@ -77,5 +77,23 @@
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Sa-Token 整合 jwt -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-jwt</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
22
nl-common/src/main/java/org/nl/config/MybatisPlusConfig.java
Normal file
22
nl-common/src/main/java/org/nl/config/MybatisPlusConfig.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package org.nl.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;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2026/1/13
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
43
nl-common/src/main/java/org/nl/enums/TaskSourceEnum.java
Normal file
43
nl-common/src/main/java/org/nl/enums/TaskSourceEnum.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package org.nl.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/11/27
|
||||
*/
|
||||
@Getter
|
||||
public enum TaskSourceEnum {
|
||||
|
||||
/**
|
||||
* APP
|
||||
*/
|
||||
APP("1", "app", "app"),
|
||||
/**
|
||||
* 屏幕
|
||||
*/
|
||||
SCREEN("2", "screen", "屏幕"),
|
||||
/**
|
||||
* 外部API
|
||||
*/
|
||||
EXTERNAL_API("3", "API", "外部API"),
|
||||
/**
|
||||
* 二维码
|
||||
*/
|
||||
QRCODE("4", "QRCode", "二维码"),
|
||||
/**
|
||||
* 后台管理系统
|
||||
*/
|
||||
BACKGROUNDMANAGEMENT("5", "BackGroundManagement", "后台管理系统");
|
||||
|
||||
private String code;
|
||||
private String name;
|
||||
private String desc;
|
||||
|
||||
|
||||
TaskSourceEnum(String code, String name, String desc) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
28
nl-common/src/main/java/org/nl/satoken/SaTokenConfig.java
Normal file
28
nl-common/src/main/java/org/nl/satoken/SaTokenConfig.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package org.nl.satoken;
|
||||
|
||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/10/22
|
||||
*/
|
||||
@Configuration
|
||||
public class SaTokenConfig implements WebMvcConfigurer {
|
||||
|
||||
@Resource
|
||||
private SecurityProperties securityProperties;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(securityProperties.getExcludes());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.nl.satoken;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/10/22
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "security")
|
||||
public class SecurityProperties {
|
||||
|
||||
/**
|
||||
* 排除路径
|
||||
*/
|
||||
private String[] excludes;
|
||||
|
||||
}
|
||||
@@ -41,5 +41,7 @@ public class FileProperties {
|
||||
private String path;
|
||||
|
||||
private String qrcode;
|
||||
|
||||
private String avatar;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -28,7 +29,7 @@ public class QRCodeUtil {
|
||||
* @param width 二维码宽度(像素)
|
||||
* @param height 二维码高度(像素)
|
||||
* @param filePath 保存路径(需包含.png后缀)
|
||||
* @return 生成的二维码文件路径,失败时返回null
|
||||
* @return 生成文件大小KB,失败时返回null
|
||||
*/
|
||||
public static String generateQRCode(String data, int width, int height, String filePath,String fileName) {
|
||||
|
||||
@@ -64,7 +65,11 @@ public class QRCodeUtil {
|
||||
File qrCodeFile = new File(filePath, fileName);
|
||||
ImageIO.write(image, "png", qrCodeFile);
|
||||
log.info("二维码已生成并保存到: {}", filePath);
|
||||
return filePath;
|
||||
double fileSizeKB = qrCodeFile.length() / 1024.0;
|
||||
// 保留后小数点后2位
|
||||
String formattedNumber = String.format("%.2f", fileSizeKB);
|
||||
log.info("文件大小: {}KB", formattedNumber);
|
||||
return formattedNumber;
|
||||
} catch (Exception e) {
|
||||
log.info("生成二维码错误:{}", e.getMessage());
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user