package com.chuanghai.ihotel.controller; import java.util.Arrays; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import com.chuanghai.ihotel.entity.HotelStaffEntity; import com.chuanghai.ihotel.service.HotelStaffService; import com.chuanghai.ihotel.common.utils.PageUtils; import com.chuanghai.ihotel.common.utils.CommonResult; import com.chuanghai.ihotel.common.utils.PageParam; /** * 酒店员工 * * @author codingliang * @email codingliang@gmail.com * @date 2022-07-27 10:02:04 */ @RestController @RequestMapping("hotelStaff") public class HotelStaffController { @Autowired private HotelStaffService hotelStaffService; /** * 列表 */ @GetMapping("/list") public CommonResult> list(PageParam pageParam){ PageUtils page = hotelStaffService.queryPage(pageParam); return CommonResult.ok().setResult(page); } /** * 信息 */ @GetMapping("/info/{id}") public CommonResult info(@PathVariable("id") Long id){ HotelStaffEntity hotelStaff = hotelStaffService.getById(id); return CommonResult.ok().setResult(hotelStaff); } /** * 保存 */ @PostMapping("/save") public CommonResult save(@RequestBody HotelStaffEntity hotelStaff){ hotelStaffService.save(hotelStaff); return CommonResult.ok(); } /** * 修改 */ @PutMapping("/update") public CommonResult update(@RequestBody HotelStaffEntity hotelStaff){ boolean flag = hotelStaffService.updateById(hotelStaff); if (flag) { return CommonResult.ok(); } else { return CommonResult.fail(); } } /** * 删除 */ @DeleteMapping("/delete") public CommonResult delete(@RequestBody Long[] ids){ boolean flag = hotelStaffService.removeByIds(Arrays.asList(ids)); if (flag) { return CommonResult.ok(); } else { return CommonResult.fail(); } } }