|
|
|
@ -3,11 +3,15 @@ package com.luoo.user.controller;
|
|
|
|
|
|
|
|
|
|
import api.Result;
|
|
|
|
|
import api.StatusCode;
|
|
|
|
|
import com.luoo.user.pojo.UserInfo;
|
|
|
|
|
import com.luoo.user.service.FriendService;
|
|
|
|
|
import com.luoo.user.service.UserInfoService;
|
|
|
|
|
import constants.Constants;
|
|
|
|
|
import controller.BaseController;
|
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
|
import dto.UserMessageDto;
|
|
|
|
|
import io.jsonwebtoken.Claims;
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
@ -26,6 +30,9 @@ public class FriendController extends BaseController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserInfoService userInfoService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RabbitTemplate rabbitTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加好友或者添加非好友(关注还是拉黑) 1是关注,2是拉黑
|
|
|
|
@ -37,7 +44,7 @@ public class FriendController extends BaseController {
|
|
|
|
|
|
|
|
|
|
//验证是否登录,并且拿到ID
|
|
|
|
|
String token = (String) request.getAttribute("claims_user");
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(token);
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto("Bearer "+token);
|
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
|
return Result.unauthorized(null);
|
|
|
|
|
}
|
|
|
|
@ -52,6 +59,20 @@ public class FriendController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
if (flag == 1) {
|
|
|
|
|
userInfoService.updatefanscountandfollowcount(1,userid,friendid);
|
|
|
|
|
|
|
|
|
|
UserInfo userInfo =userInfoService.findById(userid);
|
|
|
|
|
/**
|
|
|
|
|
* 向friend发送消息
|
|
|
|
|
*/
|
|
|
|
|
UserMessageDto userMessageDto = new UserMessageDto();
|
|
|
|
|
userMessageDto.setType(3); //消息类型 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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|