package cn.ezhizao.project.business.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import cn.ezhizao.common.utils.poi.ExcelUtil;
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
import cn.ezhizao.framework.web.controller.BaseController;
import cn.ezhizao.framework.web.domain.AjaxResult;
import cn.ezhizao.framework.web.page.TableDataInfo;
import cn.ezhizao.project.business.domain.BizDayworkItemMaxHistory;
import cn.ezhizao.project.business.service.IBizDayworkItemMaxHistoryService;
import org.springframework.security.access.prepost.PreAuthorize;
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;


/**
 * 最高权限报工修改历史记录Controller
 *
 * @author ezhizao
 * @date 2024-08-03
 */
@RestController
@RequestMapping("/business/maxHistory")
public class BizDayworkItemMaxHistoryController extends BaseController
{
    @Resource
    private IBizDayworkItemMaxHistoryService bizDayworkItemMaxHistoryService;

    /**
     * 查询最高权限报工修改历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:maxHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDayworkItemMaxHistory bizDayworkItemMaxHistory) throws NoSuchFieldException, IllegalAccessException
    {
        List<BizDayworkItemMaxHistory> list = bizDayworkItemMaxHistoryService.getList(bizDayworkItemMaxHistory);
        return getDataTable(list);
    }

    /**
     * 导出最高权限报工修改历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:maxHistory:export')")
    @Log(title = "最高权限报工修改历史记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizDayworkItemMaxHistory bizDayworkItemMaxHistory) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizDayworkItemMaxHistory);
        List<BizDayworkItemMaxHistory> list = bizDayworkItemMaxHistoryService.getList(bizDayworkItemMaxHistory);
        ExcelUtil<BizDayworkItemMaxHistory> util = new ExcelUtil<BizDayworkItemMaxHistory>(BizDayworkItemMaxHistory.class);
        util.exportExcel(response, list, "最高权限报工修改历史记录数据");
    }

    /**
     * 获取最高权限报工修改历史记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:maxHistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizDayworkItemMaxHistoryService.getById(id));
    }

    /**
     * 新增最高权限报工修改历史记录
     */
    @PreAuthorize("@ss.hasPermi('business:maxHistory:add')")
    @Log(title = "最高权限报工修改历史记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizDayworkItemMaxHistory bizDayworkItemMaxHistory) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizDayworkItemMaxHistory);
        return toAjax(bizDayworkItemMaxHistoryService.save(bizDayworkItemMaxHistory));
    }

    /**
     * 修改最高权限报工修改历史记录
     */
    @PreAuthorize("@ss.hasPermi('business:maxHistory:edit')")
    @Log(title = "最高权限报工修改历史记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizDayworkItemMaxHistory bizDayworkItemMaxHistory) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizDayworkItemMaxHistory);
        return toAjax(bizDayworkItemMaxHistoryService.updateById(bizDayworkItemMaxHistory));
    }

    /**
     * 删除最高权限报工修改历史记录
     */
    @PreAuthorize("@ss.hasPermi('business:maxHistory:remove')")
    @Log(title = "最高权限报工修改历史记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizDayworkItemMaxHistoryService.removeBatchByIds(ids));
    }
}
