package com.hw.system.common.controller;

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

import com.hw.system.api.domain.common.WfProcessActivityAuth;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.system.common.service.IWfProcessActivityAuthService;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;

/**
 * 工单流程节点步骤权限Controller
 *
 * @author Open Platform
 * @date 2024-01-25
 */
@RestController
@RequestMapping("/wfProcessActivityAuth")
public class WfProcessActivityAuthController extends BaseController
{
    @Autowired
    private IWfProcessActivityAuthService wfProcessActivityAuthService;

    /**
     * 查询工单流程节点步骤权限列表
     */
    @RequiresPermissions("system:wfProcessActivityAuth:list")
    @GetMapping("/list")
    public TableDataInfo list(WfProcessActivityAuth wfProcessActivityAuth)
    {
        startPage();
        List<WfProcessActivityAuth> list = wfProcessActivityAuthService.selectWfProcessActivityAuthList(wfProcessActivityAuth);
        return getDataTable(list);
    }

    /**
     * 导出工单流程节点步骤权限列表
     */
    @RequiresPermissions("system:wfProcessActivityAuth:export")
    @Log(title = "工单流程节点步骤权限", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfProcessActivityAuth wfProcessActivityAuth)
    {
        List<WfProcessActivityAuth> list = wfProcessActivityAuthService.selectWfProcessActivityAuthList(wfProcessActivityAuth);
        ExcelUtil<WfProcessActivityAuth> util = new ExcelUtil<WfProcessActivityAuth>(WfProcessActivityAuth.class);
        util.exportExcel(response, list, "工单流程节点步骤权限数据");
    }

    /**
     * 获取工单流程节点步骤权限详细信息
     */
    @RequiresPermissions("system:wfProcessActivityAuth:query")
    @GetMapping(value = "/{processActivityAuthId}")
    public AjaxResult getInfo(@PathVariable("processActivityAuthId") Long processActivityAuthId)
    {
        return success(wfProcessActivityAuthService.selectWfProcessActivityAuthByProcessActivityAuthId(processActivityAuthId));
    }

    /**
     * 新增工单流程节点步骤权限
     */
    @RequiresPermissions("system:wfProcessActivityAuth:add")
    @Log(title = "工单流程节点步骤权限", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfProcessActivityAuth wfProcessActivityAuth)
    {
        return toAjax(wfProcessActivityAuthService.insertWfProcessActivityAuth(wfProcessActivityAuth));
    }

    /**
     * 修改工单流程节点步骤权限
     */
    @RequiresPermissions("system:wfProcessActivityAuth:edit")
    @Log(title = "工单流程节点步骤权限", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfProcessActivityAuth wfProcessActivityAuth)
    {
        return toAjax(wfProcessActivityAuthService.updateWfProcessActivityAuth(wfProcessActivityAuth));
    }

    /**
     * 删除工单流程节点步骤权限
     */
    @RequiresPermissions("system:wfProcessActivityAuth:remove")
    @Log(title = "工单流程节点步骤权限", businessType = BusinessType.DELETE)
	@DeleteMapping("/{processActivityAuthIds}")
    public AjaxResult remove(@PathVariable Long[] processActivityAuthIds)
    {
        return toAjax(wfProcessActivityAuthService.deleteWfProcessActivityAuthByProcessActivityAuthIds(processActivityAuthIds));
    }
    /**
     * 查询拥有权限的用户
     * */
    @RequiresPermissions("system:wfProcessActivityAuth:list")
    @GetMapping("/selectUserAuth")
    public TableDataInfo selectUserAuth(WfProcessActivityAuth wfProcessActivityAuth){
        startPage();
        List<WfProcessActivityAuth> wfProcessActivityAuths = wfProcessActivityAuthService.selectUserAuth(wfProcessActivityAuth);
        return getDataTable(wfProcessActivityAuths);
    }


}
