main
wangqing 10 months ago
parent bf7711423a
commit 12239fd9b2

@ -35,7 +35,10 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
@ -53,10 +56,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
</dependency>
<dependency>
<groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId>

@ -9,6 +9,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
@ -18,6 +19,7 @@ import util.IdWorker;
@SpringBootApplication
@EnableEurekaClient
@EnableDiscoveryClient
@EnableFeignClients
public class CommentApplication {
static Logger logger= LoggerFactory.getLogger(CommentApplication.class);
public static void main(String[] args) throws UnknownHostException {

@ -6,8 +6,12 @@ import api.Result;
import api.StatusCode;
import com.luoo.comment.pojo.*;
import com.luoo.comment.service.CommentService;
import constants.Constants;
import controller.BaseController;
import dto.UserLoginDto;
import dto.UserMessageDto;
import enums.MessageTypeEnum;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -35,6 +39,10 @@ public class CommentController extends BaseController {
@Autowired
private HttpServletRequest request;
@Autowired
private RabbitTemplate rabbitTemplate;
@GetMapping
public Result findAll(){
return Result.success(commentService.findAll());
@ -76,6 +84,20 @@ public class CommentController extends BaseController {
comment.setNickName(userLoginDto.getNickName());
comment.setLocation(getIpAddr(request));
commentService.save(comment);
// UserInfo userInfo =userInfoService.findById(userId);
// /**
// * 向friend发送消息
// */
// UserMessageDto userMessageDto = new UserMessageDto();
// userMessageDto.setType(MessageTypeEnum.FOLLOW.getType()); //消息类型 1私信 2新赞3新关注 4新评论 5.系统消息
// userMessageDto.setUserId(friendid);
// userMessageDto.setContent(userInfo.getNickName()+" 关注了你");
// userMessageDto.setTitle("您有新的粉丝");
// userMessageDto.setSendUserAvatar(Constants.RESOURCE_PREFIX+userInfo.getAvatar());
// userMessageDto.setSendUserId(userid);
// userMessageDto.setSendUserNickName(userInfo.getNickName());
// rabbitTemplate.convertAndSend("userMessage",userMessageDto);
return Result.success();
}

@ -49,23 +49,6 @@ public class UserCollectController {
UserLoginDto loginDto = jwtUtil.getUserLoginDto(authorization);
userCollectService.saveCollect(loginDto.getUserId(), objectId, collectType);
if(collectType==2) {
UserInfo userInfo =userInfoService.findById(loginDto.getUserId());
/**
* friend
*/
UserMessageDto userMessageDto = new UserMessageDto();
userMessageDto.setType(MessageTypeEnum.FOLLOW.getType()); //消息类型 1私信 2新赞3新关注 4新评论 5.系统消息
userMessageDto.setUserId(objectId);
userMessageDto.setContent(userInfo.getNickName()+" 关注了你");
userMessageDto.setTitle("您有新的粉丝");
userMessageDto.setSendUserAvatar(Constants.RESOURCE_PREFIX+userInfo.getAvatar());
userMessageDto.setSendUserId(userInfo.getId());
userMessageDto.setSendUserNickName(userInfo.getNickName());
rabbitTemplate.convertAndSend("userMessage",userMessageDto);
}
return Result.success();
}

Loading…
Cancel
Save