解决合并冲突,并实现种子junit单元测试
Change-Id: Ifff1a63aed76b380ea4767a1e6e1f31f3e9c0882
diff --git a/ruoyi-framework/pom.xml b/ruoyi-framework/pom.xml
index 0f21573..9007b9b 100644
--- a/ruoyi-framework/pom.xml
+++ b/ruoyi-framework/pom.xml
@@ -58,7 +58,12 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-system</artifactId>
</dependency>
-
+ <!-- Sa-Token 权限认证,在线文档:https://sa-token.cc -->
+ <dependency>
+ <groupId>cn.dev33</groupId>
+ <artifactId>sa-token-spring-boot3-starter</artifactId>
+ <version>1.38.0</version>
+ </dependency>
</dependencies>
<build>
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java
index 057c941..3bd45d9 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java
@@ -32,101 +32,102 @@
@Configuration
public class MyBatisConfig
{
- @Autowired
- private Environment env;
-
- static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
-
- public static String setTypeAliasesPackage(String typeAliasesPackage)
- {
- ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
- MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
- List<String> allResult = new ArrayList<String>();
- try
- {
- for (String aliasesPackage : typeAliasesPackage.split(","))
- {
- List<String> result = new ArrayList<String>();
- aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
- + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN;
- Resource[] resources = resolver.getResources(aliasesPackage);
- if (resources != null && resources.length > 0)
- {
- MetadataReader metadataReader = null;
- for (Resource resource : resources)
- {
- if (resource.isReadable())
- {
- metadataReader = metadataReaderFactory.getMetadataReader(resource);
- try
- {
- result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
- }
- catch (ClassNotFoundException e)
- {
- e.printStackTrace();
- }
- }
- }
- }
- if (result.size() > 0)
- {
- HashSet<String> hashResult = new HashSet<String>(result);
- allResult.addAll(hashResult);
- }
- }
- if (allResult.size() > 0)
- {
- typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0]));
- }
- else
- {
- throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包");
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- return typeAliasesPackage;
- }
-
- public Resource[] resolveMapperLocations(String[] mapperLocations)
- {
- ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
- List<Resource> resources = new ArrayList<Resource>();
- if (mapperLocations != null)
- {
- for (String mapperLocation : mapperLocations)
- {
- try
- {
- Resource[] mappers = resourceResolver.getResources(mapperLocation);
- resources.addAll(Arrays.asList(mappers));
- }
- catch (IOException e)
- {
- // ignore
- }
- }
- }
- return resources.toArray(new Resource[resources.size()]);
- }
-
- @Bean
- public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
- {
- String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
- String mapperLocations = env.getProperty("mybatis.mapperLocations");
- String configLocation = env.getProperty("mybatis.configLocation");
- typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
- VFS.addImplClass(SpringBootVFS.class);
-
- final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
- sessionFactory.setDataSource(dataSource);
- sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
- sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
- sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
- return sessionFactory.getObject();
- }
+ // 换成mybatis-plus了会自动加载
+// @Autowired
+// private Environment env;
+//
+// static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
+//
+// public static String setTypeAliasesPackage(String typeAliasesPackage)
+// {
+// ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
+// MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
+// List<String> allResult = new ArrayList<String>();
+// try
+// {
+// for (String aliasesPackage : typeAliasesPackage.split(","))
+// {
+// List<String> result = new ArrayList<String>();
+// aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
+// + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN;
+// Resource[] resources = resolver.getResources(aliasesPackage);
+// if (resources != null && resources.length > 0)
+// {
+// MetadataReader metadataReader = null;
+// for (Resource resource : resources)
+// {
+// if (resource.isReadable())
+// {
+// metadataReader = metadataReaderFactory.getMetadataReader(resource);
+// try
+// {
+// result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
+// }
+// catch (ClassNotFoundException e)
+// {
+// e.printStackTrace();
+// }
+// }
+// }
+// }
+// if (result.size() > 0)
+// {
+// HashSet<String> hashResult = new HashSet<String>(result);
+// allResult.addAll(hashResult);
+// }
+// }
+// if (allResult.size() > 0)
+// {
+// typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0]));
+// }
+// else
+// {
+// throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包");
+// }
+// }
+// catch (IOException e)
+// {
+// e.printStackTrace();
+// }
+// return typeAliasesPackage;
+// }
+//
+// public Resource[] resolveMapperLocations(String[] mapperLocations)
+// {
+// ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
+// List<Resource> resources = new ArrayList<Resource>();
+// if (mapperLocations != null)
+// {
+// for (String mapperLocation : mapperLocations)
+// {
+// try
+// {
+// Resource[] mappers = resourceResolver.getResources(mapperLocation);
+// resources.addAll(Arrays.asList(mappers));
+// }
+// catch (IOException e)
+// {
+// // ignore
+// }
+// }
+// }
+// return resources.toArray(new Resource[resources.size()]);
+// }
+//
+// @Bean
+// public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
+// {
+// String typeAliasesPackage = env.getProperty("mybatis-plus.typeAliasesPackage");
+// String mapperLocations = env.getProperty("mybatis-plus.mapperLocations");
+// String configLocation = env.getProperty("mybatis-plus.configLocation");
+// typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
+// VFS.addImplClass(SpringBootVFS.class);
+//
+// final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
+// sessionFactory.setDataSource(dataSource);
+// sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
+// sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
+// sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
+// return sessionFactory.getObject();
+// }
}
\ No newline at end of file
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
index e0be234..5230746 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -111,7 +111,7 @@
.authorizeHttpRequests((requests) -> {
permitAllUrl.getUrls().forEach(url -> requests.requestMatchers(url).permitAll());
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
- requests.requestMatchers("/login", "/register", "/captchaImage","testDownloadTorrent").permitAll()
+ requests.requestMatchers("/login", "/register", "/captchaImage","testDownloadTorrent","/announce").permitAll()
// 静态资源,可匿名访问
.requestMatchers(HttpMethod.GET, "/", "/*.html", "/**.html", "/**.css", "/**.js", "/profile/**").permitAll()
.requestMatchers("/swagger-ui.html", "/v3/api-docs/**", "/swagger-ui/**", "/druid/**").permitAll()
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
index 5575e77..a0a9e18 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
@@ -2,7 +2,6 @@
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@@ -103,7 +102,10 @@
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
recordLoginInfo(loginUser.getUserId());
- // 生成token
+ // 生成passkey
+
+
+
return tokenService.createToken(loginUser);
}