|
@@ -0,0 +1,100 @@
|
|
|
|
+package com.bosshand.virgo.api.controller;
|
|
|
|
+
|
|
|
|
+import com.bosshand.virgo.api.model.RoomCollection;
|
|
|
|
+import com.bosshand.virgo.api.model.RoomEvaluate;
|
|
|
|
+import com.bosshand.virgo.api.model.RoomReservation;
|
|
|
|
+import com.bosshand.virgo.api.model.RoomVisitor;
|
|
|
|
+import com.bosshand.virgo.api.service.RoomService;
|
|
|
|
+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.*;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("roomOperation")
|
|
|
|
+@Api(tags = {"房源用户操作(访客,收藏,评价,预约)"})
|
|
|
|
+public class RoomController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ RoomService roomService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation("获取访客记录")
|
|
|
|
+ @RequestMapping(value = "/visitor/{currPage}/{pageSize}", method = RequestMethod.POST)
|
|
|
|
+ public Response list(@RequestBody RoomVisitor roomVisitor, @PathVariable int currPage, @PathVariable int pageSize) {
|
|
|
|
+ int totalCount = roomService.getTotalCount(roomVisitor);
|
|
|
|
+ List<RoomVisitor> dataList = roomService.getLimit(roomVisitor, currPage, pageSize);
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ result.put("dataList", dataList);
|
|
|
|
+ result.put("totalCount", totalCount);
|
|
|
|
+ return Response.ok(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("新增访客")
|
|
|
|
+ @RequestMapping(value = "/visitor", method = RequestMethod.POST)
|
|
|
|
+ public Response insert(@RequestBody RoomVisitor roomVisitor) {
|
|
|
|
+ roomService.insert(roomVisitor);
|
|
|
|
+ return Response.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("当前用户收藏房源")
|
|
|
|
+ @RequestMapping(value = "/collection/{projectItemTargetRoomId}", method = RequestMethod.GET)
|
|
|
|
+ public Response insert(@PathVariable long projectItemTargetRoomId) {
|
|
|
|
+ long userId = ContextUtils.getCurrentUser().getId();
|
|
|
|
+ RoomCollection collection = roomService.get(projectItemTargetRoomId, userId);
|
|
|
|
+ if (collection != null) {
|
|
|
|
+ return Response.fail(100001, "该用户已收藏此房源");
|
|
|
|
+ }
|
|
|
|
+ RoomCollection roomCollection = new RoomCollection();
|
|
|
|
+ roomCollection.setProjectItemTargetRoomId(projectItemTargetRoomId);
|
|
|
|
+ roomCollection.setUserId(userId);
|
|
|
|
+ roomService.insert(roomCollection);
|
|
|
|
+ return Response.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("当前用户取消收藏房源")
|
|
|
|
+ @RequestMapping(value = "/collection/{projectItemTargetRoomId}", method = RequestMethod.DELETE)
|
|
|
|
+ public Response delete(@PathVariable long projectItemTargetRoomId) {
|
|
|
|
+ long userId = ContextUtils.getCurrentUser().getId();
|
|
|
|
+ roomService.deleteCollection(projectItemTargetRoomId, userId);
|
|
|
|
+ return Response.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("获取房源评价")
|
|
|
|
+ @RequestMapping(value = "/evaluate/{currPage}/{pageSize}", method = RequestMethod.POST)
|
|
|
|
+ public Response list(@RequestBody RoomEvaluate roomEvaluate, @PathVariable int currPage, @PathVariable int pageSize) {
|
|
|
|
+ int totalCount = roomService.getTotalCount(roomEvaluate);
|
|
|
|
+ List<RoomEvaluate> dataList = roomService.getLimit(roomEvaluate, currPage, pageSize);
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ result.put("dataList", dataList);
|
|
|
|
+ result.put("totalCount", totalCount);
|
|
|
|
+ return Response.ok(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("新增评价")
|
|
|
|
+ @RequestMapping(value = "/evaluate", method = RequestMethod.POST)
|
|
|
|
+ public Response insert(@RequestBody RoomEvaluate roomEvaluate) {
|
|
|
|
+ roomService.insert(roomEvaluate);
|
|
|
|
+ return Response.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("获取预约看房")
|
|
|
|
+ @RequestMapping(value = "/reservation/list", method = RequestMethod.POST)
|
|
|
|
+ public Response list(@RequestBody RoomReservation roomReservation) {
|
|
|
|
+ return Response.ok(roomService.getList(roomReservation));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("新增预约看房")
|
|
|
|
+ @RequestMapping(value = "/reservation", method = RequestMethod.POST)
|
|
|
|
+ public Response insert(@RequestBody RoomReservation roomReservation) {
|
|
|
|
+ roomService.insert(roomReservation);
|
|
|
|
+ return Response.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|