package com.bonus.canteen.core.kitchen.controller;

import com.bonus.canteen.core.kitchen.domain.KitchenStaffInfo;
import com.bonus.canteen.core.kitchen.service.IKitchenStaffInfoService;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * 厨房员工资料Controller
 * 
 * @author xsheng
 * @date 2025-06-16
 */
@Api(tags = "厨房员工资料接口")
@RestController
@RequestMapping("/kitchen_staff_info")
public class KitchenStaffInfoController extends BaseController {
    @Autowired
    private IKitchenStaffInfoService kitchenStaffInfoService;

    /**
     * 查询厨房员工资料列表
     */
    @ApiOperation(value = "查询厨房员工资料列表")
    //@RequiresPermissions("kitchen:info:list")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody KitchenStaffInfo kitchenStaffInfo) {
        startPage();
        List<KitchenStaffInfo> list = kitchenStaffInfoService.selectKitchenStaffInfoList(kitchenStaffInfo);
        return getDataTable(list);
    }

    /**
     * 导出厨房员工资料列表
     */
    @ApiOperation(value = "导出厨房员工资料列表")
    //@PreventRepeatSubmit
    //@RequiresPermissions("kitchen:info:export")
    @SysLog(title = "厨房员工资料", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出厨房员工资料")
    @PostMapping("/export")
    public void export(HttpServletResponse response, KitchenStaffInfo kitchenStaffInfo) {
        List<KitchenStaffInfo> list = kitchenStaffInfoService.selectKitchenStaffInfoList(kitchenStaffInfo);
        ExcelUtil<KitchenStaffInfo> util = new ExcelUtil<KitchenStaffInfo>(KitchenStaffInfo.class);
        util.exportExcel(response, list, "厨房员工资料数据");
    }

    /**
     * 获取厨房员工资料详细信息
     */
    @ApiOperation(value = "获取厨房员工资料详细信息")
    //@RequiresPermissions("kitchen:info:query")
    @GetMapping(value = "/{staffId}")
    public AjaxResult getInfo(@PathVariable("staffId") Long staffId) {
        return success(kitchenStaffInfoService.selectKitchenStaffInfoByStaffId(staffId));
    }

    /**
     * 新增厨房员工资料
     */
    @ApiOperation(value = "新增厨房员工资料")
    //@PreventRepeatSubmit
    //@RequiresPermissions("kitchen:info:add")
    @SysLog(title = "厨房员工资料", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增厨房员工资料")
    @PostMapping
    public AjaxResult add(@RequestBody KitchenStaffInfo kitchenStaffInfo) {
        try {
            return toAjax(kitchenStaffInfoService.insertKitchenStaffInfo(kitchenStaffInfo));
        } catch (Exception e) {
            return error(e.getMessage());
        }
    }

    /**
     * 修改厨房员工资料
     */
    @ApiOperation(value = "修改厨房员工资料")
    //@PreventRepeatSubmit
    //@RequiresPermissions("kitchen:info:edit")
    @SysLog(title = "厨房员工资料", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改厨房员工资料")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody KitchenStaffInfo kitchenStaffInfo) {
        try {
            return toAjax(kitchenStaffInfoService.updateKitchenStaffInfo(kitchenStaffInfo));
        } catch (Exception e) {
            return error(e.getMessage());
        }
    }

    /**
     * 删除厨房员工资料
     */
    @ApiOperation(value = "删除厨房员工资料")
    //@PreventRepeatSubmit
    //@RequiresPermissions("kitchen:info:remove")
    @SysLog(title = "厨房员工资料", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除厨房员工资料")
	@PostMapping("/del/{staffIds}")
    public AjaxResult remove(@PathVariable Long[] staffIds) {
        return toAjax(kitchenStaffInfoService.deleteKitchenStaffInfoByStaffIds(staffIds));
    }
}
