package cn.ezhizao.project.business.order.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
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;
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
import cn.ezhizao.project.business.order.domain.BizArchiveInputDetailProcess;
import cn.ezhizao.project.business.order.service.IBizArchiveInputDetailProcessService;
import cn.ezhizao.framework.web.controller.BaseController;
import cn.ezhizao.framework.web.domain.AjaxResult;
import cn.ezhizao.common.utils.poi.ExcelUtil;
import cn.ezhizao.framework.web.page.TableDataInfo;

/**
 * 订单流程Controller
 *
 * @author ruoyi
 * @date 2023-11-06
 */
@RestController
@RequestMapping("/business/process")
public class BizArchiveInputDetailProcessController extends BaseController
{
    @Resource
    private IBizArchiveInputDetailProcessService bizArchiveInputDetailProcessService;

    /**
     * 查询订单流程列表
     */
    @PreAuthorize("@ss.hasPermi('business:process:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizArchiveInputDetailProcess bizArchiveInputDetailProcess) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizArchiveInputDetailProcess);
        startPage();
        List<BizArchiveInputDetailProcess> list = bizArchiveInputDetailProcessService.getList(bizArchiveInputDetailProcess);
        return getDataTable(list);
    }

    /**
     * 导出订单流程列表
     */
    @PreAuthorize("@ss.hasPermi('business:process:export')")
    @Log(title = "订单流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizArchiveInputDetailProcess bizArchiveInputDetailProcess) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizArchiveInputDetailProcess);
        List<BizArchiveInputDetailProcess> list = bizArchiveInputDetailProcessService.getList(bizArchiveInputDetailProcess);
        ExcelUtil<BizArchiveInputDetailProcess> util = new ExcelUtil<BizArchiveInputDetailProcess>(BizArchiveInputDetailProcess.class);
        util.exportExcel(response, list, "订单流程数据");
    }

    /**
     * 获取订单流程详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:process:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizArchiveInputDetailProcessService.getById(id));
    }

    /**
     * 新增订单流程
     */
    @PreAuthorize("@ss.hasPermi('business:process:add')")
    @Log(title = "订单流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizArchiveInputDetailProcess bizArchiveInputDetailProcess) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizArchiveInputDetailProcess);
        return toAjax(bizArchiveInputDetailProcessService.save(bizArchiveInputDetailProcess));
    }

    /**
     * 修改订单流程
     */
    @PreAuthorize("@ss.hasPermi('business:process:edit')")
    @Log(title = "订单流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizArchiveInputDetailProcess bizArchiveInputDetailProcess) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizArchiveInputDetailProcess);
        return toAjax(bizArchiveInputDetailProcessService.updateById(bizArchiveInputDetailProcess));
    }

    /**
     * 删除订单流程
     */
    @PreAuthorize("@ss.hasPermi('business:process:remove')")
    @Log(title = "订单流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizArchiveInputDetailProcessService.removeBatchByIds(ids));
    }
}
