首页>代码>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; } }
最近下载更多
烟橙沐雨 LV1
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日
shen14755 LV3
2022年6月7日
testuser1234567 LV24
2022年5月23日
最近浏览更多
烟橙沐雨 LV1
3月21日
3334004690 LV3
3月6日
2890892945 LV2
2023年12月31日
空中飞尘 LV13
2023年11月25日
chenlie LV2
2023年11月21日
微信网友_6743761691316224
2023年11月20日
暂无贡献等级
微信网友_6641066057273344 LV1
2023年10月27日
irivn007 LV15
2023年10月19日
新工艺 LV7
2023年6月12日
1455384106 LV2
2023年5月8日