-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,452 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
Code/Backend/demo2/src/main/java/com/example/demo/Demo2Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.demo; | ||
|
||
import cn.dev33.satoken.SaManager; | ||
import org.mybatis.spring.annotation.MapperScan; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.stereotype.Controller; | ||
|
||
@Controller | ||
@MapperScan("com.example.demo.mapper") | ||
@SpringBootApplication | ||
public class Demo2Application { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("hello world"); | ||
System.out.println("启动成功:Sa-Token配置如下:" + SaManager.getConfig()); | ||
SpringApplication.run(Demo2Application.class, args); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
Code/Backend/demo2/src/main/java/com/example/demo/common/SaToken/SaTokenConfigure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.demo.common.SaToken; | ||
|
||
import cn.dev33.satoken.interceptor.SaAnnotationInterceptor; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
/** | ||
* Sa-Token 配置类 | ||
*/ | ||
@Configuration | ||
public class SaTokenConfigure implements WebMvcConfigurer { | ||
// @Override | ||
// public void addInterceptors(InterceptorRegistry registry) { | ||
// registry.addInterceptor(new SaAnnotationInterceptor()) | ||
// .addPathPatterns() | ||
// .excludePathPatterns("/**"); | ||
// } | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
Code/Backend/demo2/src/main/java/com/example/demo/common/SaToken/StpInterfaceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.demo.common.SaToken; | ||
|
||
import cn.dev33.satoken.stp.StpInterface; | ||
import org.springframework.stereotype.Component; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
/** | ||
* 自定义权限验证接口扩展 | ||
*/ | ||
@Component | ||
public class StpInterfaceImpl implements StpInterface { | ||
|
||
// 返回一个账号所拥有的权限码集合 | ||
@Override | ||
public List<String> getPermissionList(Object loginId, String loginType) { | ||
return Arrays.asList("101", "user-add", "user-delete", "user-update", "user-get", "article-get"); | ||
} | ||
|
||
// 返回一个账号所拥有的角色标识集合 | ||
@Override | ||
public List<String> getRoleList(Object loginId, String loginType) { | ||
return Arrays.asList("admin", "super-admin"); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
Code/Backend/demo2/src/main/java/com/example/demo/common/ServerConst.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.demo.common; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@ToString | ||
@Data | ||
public class ServerConst { | ||
private String address = "http://localhost:8081/"; | ||
public String getAddress() | ||
{ | ||
return address; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
Code/Backend/demo2/src/main/java/com/example/demo/config/MailConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.example.demo.config; | ||
|
||
public class MailConfig { | ||
} |
34 changes: 34 additions & 0 deletions
34
Code/Backend/demo2/src/main/java/com/example/demo/config/WebConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.example.demo.config; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; | ||
@Configuration | ||
public class WebConfig extends WebMvcConfigurationSupport { | ||
|
||
|
||
@Override | ||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
registry.addResourceHandler("/**").addResourceLocations("file:/home/jjw/Desktop/server/"); | ||
// registry.addResourceHandler("/**").addResourceLocations("file:F:\\ALL\\demo2\\src\\main\\resources\\static\\"); | ||
// registry.addResourceHandler("/images/**").addResourceLocations("file:F:\\ALL\\demo2\\src\\main\\resources\\static\\images\\allgoods\\"); | ||
} | ||
|
||
// @Override | ||
/** | ||
* 争对跨域问题: | ||
* 1. 跨域路径 | ||
* 2. 请求来源 | ||
* 3. 跨域方法 | ||
* 4. 最大响应时间 | ||
* 5. 允许携带数据 | ||
*/ | ||
|
||
// public void addCorsMappings(CorsRegistry registry) { | ||
// registry.addMapping("/**") | ||
// .allowedOrigins("http://localhost:8081", "null") | ||
// .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE") | ||
// .maxAge(3600) | ||
// .allowCredentials(true); | ||
// } | ||
} |
Oops, something went wrong.