Commit 86342a55 authored by 刘基明's avatar 刘基明

comment 真实用户

parent 0c9f7e93
...@@ -4,7 +4,6 @@ import org.springframework.boot.SpringApplication; ...@@ -4,7 +4,6 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
...@@ -12,7 +11,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -12,7 +11,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement @EnableTransactionManagement
@EnableCaching @EnableCaching
@EnableScheduling @EnableScheduling
@ComponentScan({"com.tanpu.common", "com.tanpu.community"})
@EnableFeignClients @EnableFeignClients
public class CommunityApplication { public class CommunityApplication {
......
...@@ -29,11 +29,12 @@ public class CommonImportConfig { ...@@ -29,11 +29,12 @@ public class CommonImportConfig {
webLogAdvisor.setOrder(Ordered.HIGHEST_PRECEDENCE); webLogAdvisor.setOrder(Ordered.HIGHEST_PRECEDENCE);
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
pointcut.setExpression("execution(* com.tanpu.trade.web.*Controller.*(..))"); pointcut.setExpression("execution(* com.tanpu.community.controller.*Controller.*(..))");
webLogAdvisor.setPointcut(pointcut); webLogAdvisor.setPointcut(pointcut);
webLogAdvisor.setAdvice(webLogInterceptor); webLogAdvisor.setAdvice(webLogInterceptor);
return webLogAdvisor; return webLogAdvisor;
} }
} }
package com.tanpu.community.config;
import com.tanpu.common.auth.LoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;
/**
* created by xd on 2021/6/21
*/
@Slf4j
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
@Resource
private LoginInterceptor loginInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
log.info("addInterceptors");
registry.addInterceptor(loginInterceptor).addPathPatterns("/**");
}
}
...@@ -35,8 +35,7 @@ public class CommentController { ...@@ -35,8 +35,7 @@ public class CommentController {
@PostMapping(value = "/publishComment") @PostMapping(value = "/publishComment")
@ResponseBody @ResponseBody
public CommonResp<Void> publishCommet(@RequestBody CreateCommentReq req) { public CommonResp<Void> publishCommet(@RequestBody CreateCommentReq req) {
// String userId = userHolder.getUserInfo().getId(); String userId = userHolder.getUserId();
String userId = "liujm";
commentManager.comment(req, userId); commentManager.comment(req, userId);
return CommonResp.success(); return CommonResp.success();
} }
...@@ -46,9 +45,7 @@ public class CommentController { ...@@ -46,9 +45,7 @@ public class CommentController {
@PostMapping(value = "/queryComment") @PostMapping(value = "/queryComment")
@ResponseBody @ResponseBody
public CommonResp<Page<CommentQo>> queryComment(@RequestBody QueryCommentReq req) { public CommonResp<Page<CommentQo>> queryComment(@RequestBody QueryCommentReq req) {
//todo String userId = userHolder.getUserId();
// String userId = userHolder.getUserInfo().getId();
String userId = "liujm";
List<CommentQo> result = commentManager.queryComments(req.getThemeId(), userId); List<CommentQo> result = commentManager.queryComments(req.getThemeId(), userId);
return CommonResp.success(PageUtils.page(req.getPage(), result)); return CommonResp.success(PageUtils.page(req.getPage(), result));
} }
...@@ -57,8 +54,7 @@ public class CommentController { ...@@ -57,8 +54,7 @@ public class CommentController {
@PostMapping(value = "/likeComment") @PostMapping(value = "/likeComment")
@ResponseBody @ResponseBody
public CommonResp<Void> likeComment(@RequestBody LikeCommentReq req) { public CommonResp<Void> likeComment(@RequestBody LikeCommentReq req) {
// String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
String userId = "liujm";
commentManager.likeComment(req, userId); commentManager.likeComment(req, userId);
return CommonResp.success(); return CommonResp.success();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment