这是mongodb中示例数据
实体类
@Data
@Document("ItripHotel")
@Component(value = "ItripHotel")
public class ItripHotel{
@ApiModelProperty(value = "id")
@Id
private String id;
@ApiModelProperty(value = "酒店id")
private Double hotelId;
@ApiModelProperty(value = "酒店名")
private String hotelName;
@ApiModelProperty(value = "省code")
private String provinceCode;
@ApiModelProperty(value = "市code")
private String cityCode;
@ApiModelProperty(value = "区code")
private String districtCode;
@ApiModelProperty(value = "酒店图片")
private String imgsrc;
@ApiModelProperty(value = "酒店地址")
private String Address;
@ApiModelProperty(value = "酒店描述")
private String details;
@ApiModelProperty(value = "酒店房间数")
private String roomNumbers;
@ApiModelProperty(value = "逻辑删除(1:已删除,0:未删除)")
private Double isDeleted;
@ApiModelProperty(value = "其他参数")
@Transient //被该注解标注的,将不会被录入到数据库中。只作为普通的javaBean属性
private Map<String,Object> param = new HashMap<>();
}
控制层
@Api(tags = "酒店管理")
@RestController
@RequestMapping("/admin/hotel")
public class HotelController {
@Autowired
private HotelService hotelService;
//1 查询所有酒店
@ApiOperation(value = "获取所有酒店")
@GetMapping("findAll")
public Result findAllHotel() {
//调用service的方法
List<ItripHotel> list = hotelService.findAll();
return Result.ok(list);
}
//2 逻辑删除酒店
@ApiOperation(value = "逻辑删除酒店设置")
@DeleteMapping("deleteHotel/{id}")
public Result removeHotelSet(@PathVariable String id) {
boolean flag = hotelService.removeById(id);
if(flag) {
return Result.ok();
} else {
return Result.fail();
}
}
//3 条件查询带分页 這裡到時候看著改一改
@ApiOperation(value = "分页/带条件查询酒店")
@PostMapping("findPageItripHotel/{current}/{limit}")
public Result findPageItripHotel(@PathVariable Integer current,
@PathVariable Integer limit,
@RequestBody (required = false)
ItripHotelQueryVo itripHotelQueryVo) {
System.out.println("酒店查询"&