|
@@ -0,0 +1,87 @@
|
|
|
|
+package com.bosshand.virgo.api.controller;
|
|
|
|
+
|
|
|
|
+import com.bosshand.virgo.api.model.Fans;
|
|
|
|
+import com.bosshand.virgo.api.service.FansService;
|
|
|
|
+import com.bosshand.virgo.core.response.Response;
|
|
|
|
+import com.bosshand.virgo.core.utils.ContextUtils;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("fans")
|
|
|
|
+@Api(tags = {"关注粉丝"})
|
|
|
|
+public class FansController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ FansService fansService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation("统计数量(fansCount:粉丝数量,attentionCount:关注数量, roomCount:房源数量)")
|
|
|
|
+ @RequestMapping(value = "/count", method = RequestMethod.GET)
|
|
|
|
+ public Response count() {
|
|
|
|
+ long userId = ContextUtils.getCurrentUser().getId();
|
|
|
|
+ int fansCount = fansService.getTotalCount(userId);
|
|
|
|
+ int attentionCount = fansService.getAttentionTotalCount(userId);
|
|
|
|
+ int roomCount = fansService.getRoomTotalCount(userId);
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ result.put("roomCount", roomCount);
|
|
|
|
+ result.put("fansCount", fansCount);
|
|
|
|
+ result.put("attentionCount", attentionCount);
|
|
|
|
+ return Response.ok(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("粉丝列表")
|
|
|
|
+ @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.GET)
|
|
|
|
+ public Response list(@PathVariable int currPage, @PathVariable int pageSize) {
|
|
|
|
+ long userId = ContextUtils.getCurrentUser().getId();
|
|
|
|
+ int totalCount = fansService.getTotalCount(userId);
|
|
|
|
+ List<Fans> dataList = fansService.getLimit(userId, currPage, pageSize);
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ result.put("dataList", dataList);
|
|
|
|
+ result.put("totalCount", totalCount);
|
|
|
|
+ return Response.ok(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("关注列表")
|
|
|
|
+ @RequestMapping(value = "/attention/{currPage}/{pageSize}", method = RequestMethod.GET)
|
|
|
|
+ public Response attentionList(@PathVariable int currPage, @PathVariable int pageSize) {
|
|
|
|
+ long userId = ContextUtils.getCurrentUser().getId();
|
|
|
|
+ int totalCount = fansService.getAttentionTotalCount(userId);
|
|
|
|
+ List<Fans> dataList = fansService.getAttentionLimit(userId, currPage, pageSize);
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ result.put("dataList", dataList);
|
|
|
|
+ result.put("totalCount", totalCount);
|
|
|
|
+ return Response.ok(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ApiOperation("关注用户(userId:关注用户id)")
|
|
|
|
+ @RequestMapping(value = "/{userId}", method = RequestMethod.GET)
|
|
|
|
+ public Response insert(@PathVariable long userId) {
|
|
|
|
+ long fansUserId = ContextUtils.getCurrentUser().getId();
|
|
|
|
+ Fans fans = fansService.get(userId, fansUserId);
|
|
|
|
+ if (fans != null) {
|
|
|
|
+ return Response.fail(100001, "已经关注过了");
|
|
|
|
+ }
|
|
|
|
+ fansService.insert(userId, fansUserId);
|
|
|
|
+ return Response.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("取消关注用户(userId:关注用户id)")
|
|
|
|
+ @RequestMapping(value = "/{userId}", method = RequestMethod.DELETE)
|
|
|
|
+ public Response cancel(@PathVariable long userId) {
|
|
|
|
+ long fansUserId = ContextUtils.getCurrentUser().getId();
|
|
|
|
+ fansService.delete(userId, fansUserId);
|
|
|
|
+ return Response.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|