package cn.ezhizao.project.business.taskType.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.taskType.domain.BizTaskTypeDetail;
import cn.ezhizao.project.business.taskType.service.IBizTaskTypeDetailService;
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-07
 */
@RestController
@RequestMapping("/business/taskTypeDetail")
public class BizTaskTypeDetailController extends BaseController
{
    @Resource
    private IBizTaskTypeDetailService bizTaskTypeDetailService;

    /**
     * 查询任务项目流程列表
     */
    @PreAuthorize("@ss.hasPermi('business:taskTypeDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizTaskTypeDetail bizTaskTypeDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaskTypeDetail);
        startPage();
        List<BizTaskTypeDetail> list = bizTaskTypeDetailService.getList(bizTaskTypeDetail);
        return getDataTable(list);
    }

    /**
     * 导出任务项目流程列表
     */
    @PreAuthorize("@ss.hasPermi('business:taskTypeDetail:export')")
    @Log(title = "任务项目流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizTaskTypeDetail bizTaskTypeDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaskTypeDetail);
        List<BizTaskTypeDetail> list = bizTaskTypeDetailService.getList(bizTaskTypeDetail);
        ExcelUtil<BizTaskTypeDetail> util = new ExcelUtil<BizTaskTypeDetail>(BizTaskTypeDetail.class);
        util.exportExcel(response, list, "任务项目流程数据");
    }

    /**
     * 获取任务项目流程详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:taskTypeDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(bizTaskTypeDetailService.getById(id));
    }

    /**
     * 新增任务项目流程
     */
    @PreAuthorize("@ss.hasPermi('business:taskTypeDetail:add')")
    @Log(title = "任务项目流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizTaskTypeDetail bizTaskTypeDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaskTypeDetail);
        return toAjax(bizTaskTypeDetailService.save(bizTaskTypeDetail));
    }

    /**
     * 修改任务项目流程
     */
    @PreAuthorize("@ss.hasPermi('business:taskTypeDetail:edit')")
    @Log(title = "任务项目流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizTaskTypeDetail bizTaskTypeDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaskTypeDetail);
        return toAjax(bizTaskTypeDetailService.updateById(bizTaskTypeDetail));
    }

    /**
     * 删除任务项目流程
     */
    @PreAuthorize("@ss.hasPermi('business:taskTypeDetail:remove')")
    @Log(title = "任务项目流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Integer> ids)
    {
        return toAjax(bizTaskTypeDetailService.removeBatchByIds(ids));
    }
}
