|
|
@@ -0,0 +1,108 @@
|
|
|
+package com.chuanghai.ihotel.controller;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
+import com.chuanghai.ihotel.anno.AdminLoginCheck;
|
|
|
+import com.chuanghai.ihotel.anno.ParamCheck;
|
|
|
+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.RequestHeader;
|
|
|
+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-08-17 15:38:01
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("ihotel/hotelStaff")
|
|
|
+public class HotelStaffController {
|
|
|
+ @Autowired
|
|
|
+ private HotelStaffService hotelStaffService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 员工列表
|
|
|
+ */
|
|
|
+ @AdminLoginCheck
|
|
|
+ @GetMapping("/list")
|
|
|
+ public CommonResult<PageUtils<HotelStaffEntity>> list(@RequestHeader("admin_token") String adminToken,
|
|
|
+ PageParam pageParam){
|
|
|
+ PageUtils page = hotelStaffService.queryPage(pageParam);
|
|
|
+
|
|
|
+ return CommonResult.ok().setResult(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 员工信息
|
|
|
+ */
|
|
|
+ @AdminLoginCheck
|
|
|
+ @GetMapping("/info/{id}")
|
|
|
+ public CommonResult<HotelStaffEntity> info(@RequestHeader("admin_token") String adminToken,
|
|
|
+ @PathVariable("id") Long id){
|
|
|
+ HotelStaffEntity hotelStaff = hotelStaffService.getById(id);
|
|
|
+
|
|
|
+ return CommonResult.ok().setResult(hotelStaff);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增员工
|
|
|
+ */
|
|
|
+ @ParamCheck(index = 2)
|
|
|
+ @AdminLoginCheck
|
|
|
+ @PostMapping("/save")
|
|
|
+ public CommonResult<String> save(@RequestHeader("admin_token") String adminToken,
|
|
|
+ @RequestBody HotelStaffEntity hotelStaff){
|
|
|
+ hotelStaffService.save(hotelStaff);
|
|
|
+
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改员工
|
|
|
+ */
|
|
|
+ @ParamCheck(index = 2)
|
|
|
+ @AdminLoginCheck
|
|
|
+ @PutMapping("/update")
|
|
|
+ public CommonResult<String> update(@RequestHeader("admin_token") String adminToken,
|
|
|
+ @RequestBody HotelStaffEntity hotelStaff){
|
|
|
+ boolean flag = hotelStaffService.updateById(hotelStaff);
|
|
|
+
|
|
|
+ if (flag) {
|
|
|
+ return CommonResult.ok();
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除员工
|
|
|
+ */
|
|
|
+ @AdminLoginCheck
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ public CommonResult<String> delete(@RequestHeader("admin_token") String adminToken,
|
|
|
+ @RequestBody Long[] ids){
|
|
|
+ boolean flag = hotelStaffService.removeByIds(Arrays.asList(ids));
|
|
|
+
|
|
|
+ if (flag) {
|
|
|
+ return CommonResult.ok();
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|