package com.cyl.manager.staff.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cyl.manager.oms.pojo.vo.ManagerOrderDetailVO;
import com.cyl.manager.staff.domain.StaffImage;
import com.cyl.manager.staff.service.IStaffImageService;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员信息Controller
 * 
 * @author ruoyi
 * @date 2023-12-26
 */
@RestController
@RequestMapping("/system/image")
public class StaffImageController extends BaseController
{
    @Autowired
    private IStaffImageService staffImageService;

    /**
     * 查询人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:image:list')")
    @GetMapping("/list")
    public TableDataInfo list(StaffImage staffImage)
    {
        startPage();
        List<StaffImage> list = staffImageService.selectStaffImageList(staffImage);
        return getDataTable(list);
    }

    /**
     * 导出人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:image:export')")
    @Log(title = "人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StaffImage staffImage) throws IOException {
        List<StaffImage> list = staffImageService.selectStaffImageList(staffImage);
        ExcelUtil<StaffImage> util = new ExcelUtil<StaffImage>(StaffImage.class);
        util.exportExcel(response, list, "人员信息数据");
    }

    /**
     * 获取人员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:image:query')")
    @GetMapping(value = "/{id}")
    public ResponseEntity<StaffImage> getInfo(@PathVariable("id") Long id)
    {
        return ResponseEntity.ok(staffImageService.selectStaffImageById(id));
    }

    /**
     * 新增人员信息
     */
    @PreAuthorize("@ss.hasPermi('system:image:add')")
    @Log(title = "人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StaffImage staffImage)
    {
        return toAjax(staffImageService.insertStaffImage(staffImage));
    }

    /**
     * 修改人员信息
     */
    @PreAuthorize("@ss.hasPermi('system:image:edit')")
    @Log(title = "人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StaffImage staffImage)
    {
        return toAjax(staffImageService.updateStaffImage(staffImage));
    }

    /**
     * 删除人员信息
     */
    @PreAuthorize("@ss.hasPermi('system:image:remove')")
    @Log(title = "人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(staffImageService.deleteStaffImageByIds(ids));
    }
}
