|
@@ -1,9 +1,19 @@
|
|
|
package kankan.daikan.core.controller;
|
|
|
|
|
|
+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 kankan.daikan.base.entity.TmHouse;
|
|
|
+import kankan.daikan.base.entity.TmProject;
|
|
|
+import kankan.daikan.base.service.impl.TmHouseServiceImpl;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@Api(tags = "看房房源相关接口")
|
|
|
@RestController
|
|
@@ -11,4 +21,68 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@Log4j2
|
|
|
public class HouseController extends BaseController{
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TmHouseServiceImpl houseService;
|
|
|
+
|
|
|
+ @ApiOperation("新增房源")
|
|
|
+ @PostMapping(value = "/addNew")
|
|
|
+ public Result<Object> addNewProject(@RequestBody TmHouse tmHouse){
|
|
|
+
|
|
|
+ if(!StringUtils.isNoneBlank(tmHouse.getTitle() , tmHouse.getSceneNum())){
|
|
|
+ return Result.failure("标题或者场景码不能为空");
|
|
|
+ }
|
|
|
+ if(null == tmHouse.getTemplateType()){
|
|
|
+ return Result.failure("模板类型不能为空");
|
|
|
+ }
|
|
|
+ int add = houseService.addNew(tmHouse);
|
|
|
+ if(add != 1){
|
|
|
+ return Result.failure("新增失败");
|
|
|
+ }
|
|
|
+ return Result.success("新增成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("修改房源")
|
|
|
+ @PostMapping(value = "/update")
|
|
|
+ public Result<Object> updateHouse(@RequestBody TmHouse tmHouse){
|
|
|
+
|
|
|
+ if(null == tmHouse || StringUtils.isBlank(tmHouse.getId())){
|
|
|
+ return Result.failure("缺少房源id等参数");
|
|
|
+ }
|
|
|
+ TmHouse dbHouse = houseService.getWithId(tmHouse.getId());
|
|
|
+ if(null == dbHouse){
|
|
|
+ return Result.failure("房源不存在");
|
|
|
+ }
|
|
|
+ if(!StringUtils.equals(dbHouse.getTitle() , tmHouse.getTitle())){
|
|
|
+ //TODO:修改了房源标题,需要更改项目标题
|
|
|
+
|
|
|
+ }
|
|
|
+ if(!StringUtils.equals(dbHouse.getSceneNum() , tmHouse.getSceneNum())){
|
|
|
+ //TODO:修改了场景码,需要更改项目场景码
|
|
|
+
|
|
|
+ }
|
|
|
+ int update = houseService.updateHouse(tmHouse);
|
|
|
+ if(update != 1){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "更新失败");
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getDetail")
|
|
|
+ @ApiOperation(value = "获取房源详情")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "houseId", value = "房源ID", paramType = "query", required = true, dataType = "String"),
|
|
|
+ })
|
|
|
+ public Result<Object> getDetail(@RequestParam("houseId") String houseId) {
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(houseId)) {
|
|
|
+ return Result.failure("房源ID不能为空");
|
|
|
+ }
|
|
|
+ TmHouse house = houseService.getWithId(houseId);
|
|
|
+ if(null == house){
|
|
|
+ return Result.failure("房源不存在");
|
|
|
+ }
|
|
|
+ return Result.success(house);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|