package com.test.hotel.controller; import com.test.hotel.entity.HouseBasicMsg; import com.test.hotel.service.HouseBasiceService; import com.test.hotel.utils.R; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; /** * @param * @author * @Description: TODO * @return * @date 2022/4/18 23:21 * @Version 1.0 */ @RestController @RequestMapping("houseBasice") public class HouseBasiceController { @Autowired private HouseBasiceService houseBasiceService; @PostMapping("/queryHouseBasicMsg") public R queryHouseBasicMsg(@RequestBody HouseBasicMsg houseBasicMsg){ List<HouseBasicMsg> list = houseBasiceService.queryHouseBasicMsg(houseBasicMsg); int total = houseBasiceService.total(houseBasicMsg); return R.ok().put("list",list).put("total",total); } @PostMapping("/addHouseBasicMsg") public void addHouseBasicMsg(@RequestBody HouseBasicMsg houseBasicMsg){ houseBasiceService.addHouseBasicMsg(houseBasicMsg); } @PostMapping("/getOne") public HouseBasicMsg getOne(@RequestBody HouseBasicMsg houseBasicMsg){ return houseBasiceService.getOne(houseBasicMsg); } @PostMapping("/updateHouseBasicMsg") public void updateHouseBasicMsg(@RequestBody HouseBasicMsg houseBasicMsg){ houseBasiceService.updateHouseBasicMsg(houseBasicMsg); } @GetMapping("/deleteHouseBasicMsg") public void deleteHouseBasicMsg(int id){ houseBasiceService.deleteHouseBasicMsg(id); } }
时间: 2024-03-15 08:42:23 浏览: 110
这是一个基于 SpringBoot 框架的后端控制器代码。该控制器定义了对房屋基本信息的增删改查等操作的接口。其中,使用了 @RestController 注解来标识该类是一个 REST 风格的控制器,而 @RequestMapping 注解则用于映射请求路径。该控制器中定义了五个接口,分别对应着查询、添加、获取单个信息、更新和删除操作。其中,@PostMapping 和 @GetMapping 注解分别用于处理 POST 和 GET 请求。在查询操作中,使用了 @RequestBody 注解来接收前端传来的 JSON 格式的数据。在返回结果时,使用了 R 类来封装返回的数据,其中 put 方法用于向 R 类中添加数据。在删除操作中,使用了 @GetMapping 注解,但是在实际使用中,应该使用 @DeleteMapping 注解来更好地符合 REST 风格的设计。
阅读全文