首页>代码>spring mvc开发简单sns系统,实现了feed,上传,分享,评论,关注,好友等功能>/src/main/java/com/lvwang/osf/control/FollowController.java
                
                package com.lvwang.osf.control;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.lvwang.osf.model.Notification;
import com.lvwang.osf.model.User;
import com.lvwang.osf.service.FollowService;
import com.lvwang.osf.service.NotificationService;
import com.lvwang.osf.service.UserService;
import com.lvwang.osf.util.Dic;
@Controller
@RequestMapping("/follow")
public class FollowController {
	
	@Autowired
	@Qualifier("followService")
	private FollowService followService;
	
	@Autowired
	@Qualifier("userService")
	private UserService userService;
	
	@Autowired
	@Qualifier("notificationService")
	private NotificationService notificationService;
	
	
	@ResponseBody
	@RequestMapping("/{following_user_id}")
	public Map<String, Object> follow(@PathVariable("following_user_id") int following_user_id,
									  HttpSession session) {
		User user = (User) session.getAttribute("user");
		Map<String, Object> map = followService.newFollowing(user.getId(), 
															 user.getUser_name(), 
															 following_user_id, 
															 userService.findById(following_user_id).getUser_name());
		Notification notification = new Notification(Dic.NOTIFY_TYPE_FOLLOW, 
												     0, 
												     Dic.OBJECT_TYPE_USER, 
												     following_user_id, 
												     following_user_id, 
												     user.getId());
		notificationService.doNotify(notification);
		return map;
	}
	
	@ResponseBody
	@RequestMapping("/undo/{following_user_id}")
	public Map<String, Object> undoFollow(@PathVariable("following_user_id") int following_user_id,
							   HttpSession session) {
		User user = (User) session.getAttribute("user");
		Map<String, Object> map = followService.undoFollow(user.getId(),following_user_id);
		return map;
	}
	
	
	
}
 最近下载更多
最近下载更多
                
                微笑刺客     LV21
                2024年11月24日
            
            
        
                goccgoccgocc     LV4
                2024年5月23日
            
            
        
                烟橙沐雨     LV1
                2024年3月21日
            
            
        
                hosinvm     LV7
                2022年11月18日
            
            
        
                dfsfvsr     LV2
                2022年11月8日
            
            
        
                疯子庭     LV8
                2022年10月10日
            
            
        
                1140215796     LV6
                2022年8月28日
            
            
        
                是anan呀     LV2
                2022年7月7日
            
            
        
                wbg_TS     LV1
                2022年7月7日
            
            
        
                wei_471416461     LV1
                2022年6月25日
            
            
         最近浏览更多
最近浏览更多
                
                Daima000     LV4
                2024年12月3日
            
            
        
                微笑刺客     LV21
                2024年11月24日
            
            
        
                1481421104     LV3
                2024年11月14日
            
            
        
                dongandmin     LV9
                2024年11月13日
            
            
        
                goccgoccgocc     LV4
                2024年5月9日
            
            
        
                2860615178     LV4
                2024年5月2日
            
            
        
                烟橙沐雨     LV1
                2024年3月21日
            
            
        
                3334004690     LV11
                2024年3月6日
            
            
        
                2890892945     LV2
                2023年12月31日
            
            
        
                空中飞尘     LV13
                2023年11月25日
            
            
        
 
                 
                 
    