package com.stylefeng.guns.modular.code.controller;
|
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import com.stylefeng.guns.modular.system.dto.Host;
|
import com.stylefeng.guns.modular.system.dto.THouseResource;
|
import com.stylefeng.guns.modular.system.model.HouseResource;
|
import com.stylefeng.guns.modular.system.model.HouseType;
|
import com.stylefeng.guns.modular.system.service.IHouseResourceService;
|
import com.stylefeng.guns.modular.system.service.IHouseTypeService;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import com.stylefeng.guns.modular.system.warpper.req.AddHouseReq;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.repository.query.Param;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Date;
|
import java.util.List;
|
|
@Controller
|
@RequestMapping("/base/house")
|
public class HouseController {
|
@Autowired
|
private IHouseTypeService houseTypeService;
|
|
|
@Autowired
|
private IHouseResourceService houseResourceService;
|
|
|
@ResponseBody
|
@PostMapping("/addHouse/add")
|
@ApiOperation(value = "发布房源", tags = {"后台-房源管理"})
|
public ResultUtil addHouse(@RequestBody AddHouseReq req){
|
return houseResourceService.addHouse(req);
|
}
|
|
|
@ResponseBody
|
@GetMapping("/getHouseType")
|
@ApiOperation(value = "获取房源类型", tags = {"后台-房源管理"})
|
public ResultUtil<List<HouseType>> getHouseType(){
|
List<HouseType> houseTypes = houseTypeService.selectList(null);
|
return ResultUtil.success(houseTypes);
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/addHouseType")
|
@ApiOperation(value = "增加房源类型", tags = {"后台-房源管理"})
|
public ResultUtil addHouseType(HouseType houseType){
|
houseType.setInsertTime(new Date());
|
houseTypeService.insert(houseType);
|
return ResultUtil.success("增加成功");
|
}
|
|
@ResponseBody
|
@DeleteMapping("/deleteHouseType")
|
@ApiOperation(value = "删除房源类型", tags = {"后台-房源管理"})
|
public ResultUtil deleteHouseType(Integer id){
|
houseTypeService.deleteById(id);
|
return ResultUtil.success("删除成功");
|
}
|
|
@ResponseBody
|
@GetMapping("/pre/edit")
|
@ApiOperation(value = "编辑房源前", tags = {"后台-房源管理"})
|
public AddHouseReq preEdit(Integer id){
|
HouseResource houseResource = houseResourceService.selectById(id);
|
AddHouseReq addHouseReq = new AddHouseReq();
|
BeanUtils.copyProperties(houseResource,addHouseReq);
|
return addHouseReq;
|
|
}
|
|
|
@ResponseBody
|
@PutMapping("/edit")
|
@ApiOperation(value = "编辑房源", tags = {"后台-房源管理"})
|
public ResultUtil edit(@RequestBody AddHouseReq req){
|
return houseResourceService.editHouse(req);
|
}
|
|
|
@ResponseBody
|
@GetMapping("/list")
|
@ApiOperation(value = "列表", tags = {"后台-房源管理"},response = THouseResource.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
|
@ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
|
@ApiImplicitParam(name = "cellName", value = "小区名称", dataType = "String", paramType = "query"),
|
@ApiImplicitParam(name = "dataType", value = "房屋类型(1=出租,2=卖房)", dataType = "Integer", paramType = "query"),
|
@ApiImplicitParam(name = "isManage", value = "1后台2房东3中介", dataType = "Integer", paramType = "query"),
|
@ApiImplicitParam(name = "name", value = "姓名", dataType = "String", paramType = "query"),
|
@ApiImplicitParam(name = "saleAmount", value = "售卖金额区间'-'分隔", dataType = "String", paramType = "query"),
|
@ApiImplicitParam(name = "status", value = "状态1=正常,2=冻结", dataType = "Integer", paramType = "query")
|
})
|
public PageInfo<THouseResource> list(@RequestParam int pageNum,
|
@RequestParam int pageSize,
|
String cellName,
|
Integer dataType,
|
Integer isManage,
|
String name,
|
String saleAmount,
|
Integer status){
|
|
|
PageHelper.startPage(pageNum,pageSize);
|
List<THouseResource> houseResources =houseResourceService.list(cellName,dataType,isManage,name,saleAmount,status);
|
PageInfo<THouseResource> info=new PageInfo<>(houseResources);
|
System.err.println(info);
|
return info;
|
}
|
|
|
@ResponseBody
|
@GetMapping("/au/list")
|
@ApiOperation(value = "审核列表", tags = {"后台-房源管理"},response = THouseResource.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
|
@ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
|
@ApiImplicitParam(name = "cellName", value = "小区名称", dataType = "String", paramType = "query"),
|
@ApiImplicitParam(name = "dataType", value = "房屋类型(1=出租,2=卖房)", dataType = "Integer", paramType = "query"),
|
@ApiImplicitParam(name = "isManage", value = "1后台2房东3中介", dataType = "Integer", paramType = "query"),
|
@ApiImplicitParam(name = "name", value = "姓名", dataType = "String", paramType = "query"),
|
@ApiImplicitParam(name = "saleAmount", value = "售卖金额区间'-'分隔", dataType = "String", paramType = "query"),
|
@ApiImplicitParam(name = "size", value = "面积", dataType = "Integer", paramType = "query")
|
})
|
public PageInfo<THouseResource> auList(@RequestParam int pageNum,
|
@RequestParam int pageSize,
|
String cellName,
|
Integer dataType,
|
Integer isManage,
|
String name,
|
String saleAmount,
|
Integer id,String size){
|
|
|
PageHelper.startPage(pageNum,pageSize);
|
List<THouseResource> houseResources =houseResourceService.aulist(id,cellName,dataType,isManage,name,saleAmount,size);
|
PageInfo<THouseResource> info=new PageInfo<>(houseResources);
|
System.err.println(info);
|
return info;
|
}
|
|
|
@ResponseBody
|
@PutMapping("/change")
|
@ApiOperation(value = "(0=下架,1=上架,2=删除,3通过审核,4拒绝审核)", tags = {"后台-房源管理"})
|
public ResultUtil change(Integer id,Integer status){
|
HouseResource houseResource = houseResourceService.selectById(id);
|
|
if (status==0||status==1){
|
houseResource.setStatus(status);
|
}else if (status==2){
|
houseResource.setIsDelete(1);
|
}else if (status ==3){
|
houseResource.setAuthStatus(2);
|
}else if (status == 4){
|
houseResource.setAuthStatus(3);
|
}
|
houseResourceService.updateById(houseResource);
|
|
return ResultUtil.success("操作成功");
|
|
|
}
|
|
|
|
|
|
}
|