修改配置文件
This commit is contained in:
@@ -41,11 +41,12 @@
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Sa-Token 权限认证,在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.28.0</version>
|
||||
<artifactId>sa-token-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
@@ -132,7 +133,6 @@
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-redis-jackson</artifactId>
|
||||
<version>1.38.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ivmiku.tutorial.config;
|
||||
|
||||
import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
|
||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@@ -11,7 +12,7 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册注解拦截器,并排除不需要注解鉴权的接口地址 (与登录拦截器无关)
|
||||
registry.addInterceptor(new SaAnnotationInterceptor())
|
||||
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
||||
.addPathPatterns("/**");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ivmiku.tutorial.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -47,11 +48,12 @@ public class PostController {
|
||||
@Operation(summary = "创建帖子")
|
||||
public Result createPost(@RequestParam("title") String title,
|
||||
@RequestParam("content") String content,
|
||||
@RequestParam("communityId") Long communityId,
|
||||
@RequestParam("imageFiles") MultipartFile[] imageFiles,
|
||||
@RequestParam("videoFile") MultipartFile videoFile,
|
||||
@RequestParam(value = "communityId") Long communityId,
|
||||
@RequestParam(value = "imageFiles", required = false) MultipartFile[] imageFiles,
|
||||
@RequestParam(value = "videoFile", required = false) MultipartFile videoFile,
|
||||
@RequestParam("isPublic") Integer isPublic,
|
||||
@RequestParam("location") String location) {
|
||||
@RequestParam(value = "location", required = false) String location) {
|
||||
System.out.println("Aaa");
|
||||
String userId = StpUtil.getLoginIdAsString();
|
||||
logger.info("用户ID:{}开始创建帖子", userId);
|
||||
|
||||
@@ -278,7 +280,7 @@ public class PostController {
|
||||
post.setTitle(title);
|
||||
post.setContent(content);
|
||||
post.setCommunityId(communityId);
|
||||
post.setIsDraft(0); // 0 表示草稿
|
||||
post.setIsDraft(1); // 0 表示草稿
|
||||
post.setLocation(location);
|
||||
|
||||
try {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TutorialController {
|
||||
@RequestParam(value = "imageFile", required = false) MultipartFile imageFile,
|
||||
@RequestParam(value = "videoFile", required = false) MultipartFile videoFile,
|
||||
@RequestParam("isOfficial") Integer isOfficial) {
|
||||
String userId = StpUtil.getLoginIdAsString(); // 获取 userOpenid
|
||||
String userId = (String) StpUtil.getLoginId(); // 获取 userOpenid
|
||||
logger.info("用户ID:{} 开始创建教程", userId);
|
||||
|
||||
Tutorials tutorial = new Tutorials();
|
||||
@@ -77,7 +77,7 @@ public class TutorialController {
|
||||
public Result getTutorial(@PathVariable Long id) {
|
||||
Tutorials tutorial = tutorialsService.getById(id);
|
||||
if (tutorial != null) {
|
||||
return Result.ok("教程获取成功");
|
||||
return Result.ok(tutorial);
|
||||
}
|
||||
return Result.error("未找到教程");
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class TutorialController {
|
||||
@Operation(summary = "获取所有教程")
|
||||
public Result listTutorials() {
|
||||
List<Tutorials> tutorials = tutorialsService.list();
|
||||
return Result.ok("教程列表获取成功");
|
||||
return Result.ok(tutorials);
|
||||
}
|
||||
// 根据教程标签ID获取教程列表
|
||||
@GetMapping("/listByTag/{tagId}")
|
||||
|
||||
@@ -204,7 +204,7 @@ public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements Po
|
||||
public List<Post> getDraftsByUserId(String userId) {
|
||||
return postMapper.selectList(new LambdaQueryWrapper<Post>()
|
||||
.eq(Post::getUserOpenid, userId)
|
||||
.eq(Post::getIsDraft, 0)); // 0 表示草稿
|
||||
.eq(Post::getIsDraft, 1)); // 0 表示草稿
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ spring.data.redis.host=127.0.0.1
|
||||
spring.data.redis.port=6379
|
||||
spring.data.redis.database=0
|
||||
|
||||
|
||||
spring.application.name=community
|
||||
|
||||
server.port=8073
|
||||
|
||||
5
pom.xml
5
pom.xml
@@ -178,6 +178,11 @@
|
||||
<artifactId>sa-token-spring-boot3-starter</artifactId>
|
||||
<version>${satoken-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-redis-jackson</artifactId>
|
||||
<version>${satoken-version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.dubbo/dubbo-registry-nacos -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
|
||||
Reference in New Issue
Block a user