|
@@ -1,20 +1,25 @@
|
|
|
package fcb.project.manager.core.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import fcb.project.manager.base.entity.TmAudit;
|
|
|
import fcb.project.manager.base.entity.TmEstate;
|
|
|
import fcb.project.manager.base.entity.TmHouse;
|
|
|
+import fcb.project.manager.base.enums.DeleteStatus;
|
|
|
+import fcb.project.manager.base.service.impl.TmAuditServiceImpl;
|
|
|
+import fcb.project.manager.base.service.impl.TmEstateServiceImpl;
|
|
|
import fcb.project.manager.base.service.impl.TmHouseServiceImpl;
|
|
|
import fcb.project.manager.base.utils.DataUtils;
|
|
|
import fdage.back.sdk.base.entity.Result;
|
|
|
import fdage.back.sdk.base.enums.ResultCodeEnum;
|
|
|
import fdage.back.sdk.base.exception.CommonBaseException;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.models.auth.In;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
/**
|
|
@@ -22,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
* 3 * @Date: 2021/1/7 17:38
|
|
|
* 4
|
|
|
*/
|
|
|
+@Api(tags = "房源相关接口")
|
|
|
@RestController
|
|
|
@RequestMapping("fcb/house")
|
|
|
@Log4j2
|
|
@@ -30,17 +36,23 @@ public class HouseManagerController {
|
|
|
@Autowired
|
|
|
private TmHouseServiceImpl tmHouseService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TmAuditServiceImpl tmAuditService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TmEstateServiceImpl tmEstateService;
|
|
|
+
|
|
|
@GetMapping("/queryOrSearchList")
|
|
|
@ApiOperation(value = "根据条件拉取所有楼盘")
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "houseTitle", value = "房源名称", paramType = "query", required = true, dataType = "String"),
|
|
|
- @ApiImplicitParam(name = "status", value = "状态", paramType = "query", required = true, dataType = "Integer"),
|
|
|
+ @ApiImplicitParam(name = "houseTitle", value = "房源名称", paramType = "query", required = false, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "status", value = "状态: 0->草稿;1->待审核;2->已审核;3->未通过", paramType = "query", required = false, dataType = "Integer"),
|
|
|
@ApiImplicitParam(name = "type", value = "房源类型: 1->新房,2->二手房", paramType = "query", required = true, dataType = "String"),
|
|
|
@ApiImplicitParam(name = "pageNum", value = "当前页码", paramType = "query", required = true, dataType = "Long"),
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页大小", paramType = "query", required = true, dataType = "Long")
|
|
|
})
|
|
|
- public Result<Object> getHouseList(@PathVariable(required = false) String houseTitle,
|
|
|
- @PathVariable(required = false) Integer status,
|
|
|
+ public Result<Object> getHouseList(@RequestParam(required = false) String houseTitle,
|
|
|
+ @RequestParam(required = false) Integer status,
|
|
|
@RequestParam(name = "type") Integer type,
|
|
|
@RequestParam(name = "pageNum")Long pageNum,
|
|
|
@RequestParam(name = "pageSize")Long pageSize){
|
|
@@ -52,8 +64,8 @@ public class HouseManagerController {
|
|
|
|
|
|
|
|
|
@PostMapping("/addHouse")
|
|
|
- @ApiOperation(value = "创建房源")
|
|
|
- public Result<Object> addNewEstate(@RequestBody TmHouse tmHouse){
|
|
|
+ @ApiOperation(value = "创建房源-这里需要720或者四维看看微服务创建完成调用")
|
|
|
+ public Result<Object> addNewHouse(@RequestBody TmHouse tmHouse){
|
|
|
|
|
|
if(!StringUtils.isNoneBlank(tmHouse.getHouseTitle() , tmHouse.getEstateId())){
|
|
|
throw new CommonBaseException(ResultCodeEnum.D101 , "楼盘名称或者所属公司不能为空");
|
|
@@ -70,6 +82,28 @@ public class HouseManagerController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/updateVrLink")
|
|
|
+ @ApiOperation(value = "更新房源的VRLINK-这里需要720或者四维看看微服务创建完成调用")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "houseId", value = "房源ID", paramType = "query", required = false, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "vrLink", value = "场景vrlink", paramType = "query", required = false, dataType = "String"),
|
|
|
+ })
|
|
|
+ public Result<Object> updateVrLink(@RequestParam String houseId ,
|
|
|
+ @RequestParam String vrLink){
|
|
|
+ if(!StringUtils.isNoneBlank(houseId , vrLink)){
|
|
|
+ return Result.failure("房源ID或者VRLINK为空了");
|
|
|
+ }
|
|
|
+ TmHouse dbHouse = tmHouseService.getById(houseId);
|
|
|
+ if(null == dbHouse){
|
|
|
+ return Result.failure("房源不存在");
|
|
|
+ }
|
|
|
+ dbHouse.setVrLink(vrLink);
|
|
|
+ if(tmHouseService.updateHouse(dbHouse)){
|
|
|
+ return Result.success("更新成功");
|
|
|
+ }
|
|
|
+ return Result.failure("更新失败");
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/updateHouse")
|
|
|
@ApiOperation(value = "修改房源信息")
|
|
|
public Result<Object> updateEstate(@RequestBody TmHouse tmHouse){
|
|
@@ -88,5 +122,86 @@ public class HouseManagerController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/submitAudit")
|
|
|
+ @ApiOperation(value = "提交审核记录")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "houseId", value = "房源ID", paramType = "query", required = true, dataType = "String"),
|
|
|
+ })
|
|
|
+ public Result<Object> addNewAudit(@RequestParam String houseId){
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(houseId)){
|
|
|
+ return Result.failure("房源ID不能为空");
|
|
|
+ }
|
|
|
+ TmHouse dbHouse = tmHouseService.getById(houseId);
|
|
|
+ if(null == dbHouse){
|
|
|
+ return Result.failure("房源不存在");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(dbHouse.getEstateId())){
|
|
|
+ return Result.failure("房源未分配所属的楼盘不存在");
|
|
|
+ }
|
|
|
+ TmEstate tmEstate = tmEstateService.getById(dbHouse.getEstateId());
|
|
|
+ if(null == tmEstate){
|
|
|
+ return Result.failure("房源所属的楼盘不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ int insert = tmAuditService.addNewAudit(dbHouse , tmEstate);
|
|
|
+ if(insert == 1){
|
|
|
+ return Result.success();
|
|
|
+ }else{
|
|
|
+ return Result.failure("提交失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/dismissAudit")
|
|
|
+ @ApiOperation(value = "撤销审核记录")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "houseId", value = "房源ID", paramType = "query", required = true, dataType = "String"),
|
|
|
+ })
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Result<Object> dismissAudit(@RequestParam String houseId){
|
|
|
+ if(StringUtils.isBlank(houseId)){
|
|
|
+ return Result.failure("房源ID不能为空");
|
|
|
+ }
|
|
|
+ TmHouse dbHouse = tmHouseService.getById(houseId);
|
|
|
+ if(null == dbHouse || null == dbHouse.getAuditId()){
|
|
|
+ return Result.failure("房源不存在或者未提交审核");
|
|
|
+ }
|
|
|
+ dbHouse = null;
|
|
|
+ //抢房源的锁,去掉原来审核的
|
|
|
+ dbHouse = tmHouseService.selectForUpdate(houseId);
|
|
|
+ if(null == dbHouse){
|
|
|
+ return Result.failure("房源抢锁失败,无法撤销审核");
|
|
|
+ }
|
|
|
+ //走到这里,说明房源的锁已经抢到了
|
|
|
+ TmAudit tmAudit = tmAuditService.getById(dbHouse.getAuditId());
|
|
|
+ if(null == tmAudit){
|
|
|
+ return Result.failure("该房源未提交审核");
|
|
|
+ }
|
|
|
+ //开启事务,抢审批记录的锁
|
|
|
+ tmAudit = null;
|
|
|
+ tmAudit = tmAuditService.selectForUpdate(dbHouse.getAuditId());
|
|
|
+ if(null == tmAudit){
|
|
|
+ //抢锁失败,则快速返回,释放
|
|
|
+ return Result.failure("该房源正在审核,无法撤销");
|
|
|
+ }
|
|
|
+ //走到这里,说明审核的锁已经抢到了
|
|
|
+ //两个锁都抢到了,则可以开始做撤销动作了
|
|
|
+ dbHouse.setAuditId(null);
|
|
|
+ dbHouse.setAuditName(null);
|
|
|
+ dbHouse.setAuditTime(null);
|
|
|
+ if(!tmHouseService.updateHouse(dbHouse)){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "撤销房源的审批记录失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ tmAudit.setIsDelete(DeleteStatus.HAS_DELETE.getCode());
|
|
|
+ int updateAudit = tmAuditService.updateAudit(tmAudit);
|
|
|
+ if(updateAudit != 1){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "删除审批记录失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.success("撤销成功");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|